Trim bootstrap jimsh
[jimtcl.git] / tests / exists.test
blob11e8781c3ccf4bc56c28a1e7c991f9efa5fa1b01
1 source [file dirname [info script]]/testing.tcl
3 needs cmd exists
4 testConstraint lambda [expr {[info commands lambda] ne {}}]
6 test exists-1.1 "Exists var" {
7         set a 1
8         exists a
9 } 1
11 test exists-1.1 "Exists var" {
12         unset -nocomplain b
13         exists b
14 } 0
16 test exists-1.1 "Exists -var" {
17         exists -var a
18 } 1
20 test exists-1.1 "Exists -var" {
21         exists -var b
22 } 0
24 test exists-1.1 "Exists in proc" {
25         proc a {name} { exists $name }
26         a ::a
27 } 1
29 test exists-1.1 "Exists in proc" {
30         a ::b
31 } 0
33 test exists-1.1 "Exists in proc" {
34         a name
35 } 1
37 test exists-1.1 "Exists in proc" {
38         a none
39 } 0
41 test exists-1.1 "Exists -proc" {
42         exists -proc a
43 } 1
45 test exists-1.1 "Exists -proc" {
46         exists -proc bogus
47 } 0
49 test exists-1.1 "Exists -proc" {
50         exists -proc info
51 } 0
53 test exists-1.1 "Exists -command" {
54         exists -command a
55 } 1
57 test exists-1.1 "Exists -command" {
58         exists -command info
59 } 1
61 test exists-1.1 "Exists -command" {
62         exists -command bogus
63 } 0
65 test exists-1.1 "Exists local lambda after exit" lambda {
66         proc a {} {
67                 local lambda {} {dummy}
68         }
69         exists -proc [a]
70 } 0
72 test exists-1.1 "Exists local lambda" lambda {
73         proc a {} {
74                 exists -proc [local lambda {} {dummy}]
75         }
76         a
77 } 1
79 testreport