home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tcl8.0 / tests / pid.test < prev    next >
Encoding:
Text File  |  1997-08-15  |  1.6 KB  |  53 lines  |  [TEXT/ALFA]

  1. # Commands covered:  pid
  2. #
  3. # This file contains a collection of tests for one or more of the Tcl
  4. # built-in commands.  Sourcing this file into Tcl runs the tests and
  5. # generates output for errors.  No output means no errors were found.
  6. #
  7. # Copyright (c) 1991-1993 The Regents of the University of California.
  8. # Copyright (c) 1994-1995 Sun Microsystems, Inc.
  9. #
  10. # See the file "license.terms" for information on usage and redistribution
  11. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  12. #
  13. # SCCS: @(#) pid.test 1.12 96/04/12 11:14:43
  14.  
  15. # If pid is not defined just return with no error
  16. # Some platforms may not have the pid command implemented
  17. if {[info commands pid] == ""} {
  18.     puts "pid is not implemented for this machine"
  19.     return
  20. }
  21.  
  22. if {[string compare test [info procs test]] == 1} then {source defs}
  23.  
  24. catch {removeFile test1}
  25.  
  26. test pid-1.1 {pid command} {
  27.     regexp {(^[0-9]+$)|(^0x[0-9a-fA-F]+$)} [pid]
  28. } 1
  29. test pid-1.2 {pid command} {unixOrPc unixExecs} {
  30.     set f [open {| echo foo | cat >test1} w]
  31.     set pids [pid $f]
  32.     close $f
  33.     catch {removeFile test1}
  34.     list [llength $pids] [regexp {^[0-9]+$} [lindex $pids 0]] \
  35.        [regexp {^[0-9]+$} [lindex $pids 1]] \
  36.        [expr {[lindex $pids 0] == [lindex $pids 1]}]
  37. } {2 1 1 0}
  38. test pid-1.3 {pid command} {
  39.     set f [open test1 w]
  40.     set pids [pid $f]
  41.     close $f
  42.     set pids
  43. } {}
  44. test pid-1.4 {pid command} {
  45.     list [catch {pid a b} msg] $msg
  46. } {1 {wrong # args: should be "pid ?channelId?"}}
  47. test pid-1.5 {pid command} {
  48.     list [catch {pid gorp} msg] $msg
  49. } {1 {can not find channel named "gorp"}}
  50.  
  51. catch {removeFile test1}
  52. concat {}
  53.