tests: socket.test check for ipv6 support
[jimtcl.git] / tests / exists.test
blob79f9da0b5330cb31ec76f0dc24e3a8025d0b433e
1 source [file dirname [info script]]/testing.tcl
3 needs cmd exists
4 testCmdConstraints lambda
6 test exists-1.1 "Exists var" {
7         set a 1
8         exists a
9 } 1
11 test exists-1.2 "Exists var" {
12         unset -nocomplain b
13         exists b
14 } 0
16 test exists-1.3 "Exists -var" {
17         exists -var a
18 } 1
20 test exists-1.4 "Exists -var" {
21         exists -var b
22 } 0
24 test exists-1.5 "Exists in proc" {
25         proc a {name} { exists $name }
26         a ::a
27 } 1
29 test exists-1.6 "Exists in proc" {
30         a ::b
31 } 0
33 test exists-1.7 "Exists in proc" {
34         a name
35 } 1
37 test exists-1.8 "Exists in proc" {
38         a none
39 } 0
41 test exists-1.9 "Exists -proc" {
42         exists -proc a
43 } 1
45 test exists-1.10 "Exists -proc" {
46         exists -proc bogus
47 } 0
49 test exists-1.11 "Exists -proc" {
50         exists -proc info
51 } 0
53 test exists-1.12 "Exists -command" {
54         exists -command a
55 } 1
57 test exists-1.13 "Exists -command" {
58         exists -command info
59 } 1
61 test exists-1.14 "Exists -command" {
62         exists -command bogus
63 } 0
65 test exists-1.15 "Exists local lambda after exit" lambda {
66         proc a {} {
67                 local lambda {} {dummy}
68         }
69         exists -proc [a]
70 } 0
72 test exists-1.16 "Exists local lambda" lambda {
73         proc a {} {
74                 exists -proc [local lambda {} {dummy}]
75         }
76         a
77 } 1
79 test exists-1.17 {exists usage} -body {
80         exists -dummy blah
81 } -returnCodes error -result {bad option "-dummy": must be -alias, -command, -proc, or -var}
83 test exists-1.18 {exists usage} -body {
84         exists abc def ghi
85 } -returnCodes error -result {wrong # args: should be "exists ?option? name"}
87 testreport