diff options
author | Steve Bennett <steveb@workware.net.au> | 2010-10-26 10:09:57 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2010-12-02 09:04:54 +1000 |
commit | 064ec299a9f7b1016ed7c24e5a014d94271281b3 (patch) | |
tree | 65925898533b35a1e730f0dfb5eee57de7c5328a /tests | |
parent | d160ac7e0cdd776e46c502ab1ad33aa5366acc99 (diff) | |
download | jimtcl-064ec299a9f7b1016ed7c24e5a014d94271281b3.zip jimtcl-064ec299a9f7b1016ed7c24e5a014d94271281b3.tar.gz jimtcl-064ec299a9f7b1016ed7c24e5a014d94271281b3.tar.bz2 |
Add the [exists] command
Especially simplifies checking for the existence of procs.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/exists.test | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/tests/exists.test b/tests/exists.test new file mode 100644 index 0000000..ae35a87 --- /dev/null +++ b/tests/exists.test @@ -0,0 +1,78 @@ +source [file dirname [info script]]/testing.tcl + +needs cmd exists + +test exists-1.1 "Exists var" { + set a 1 + exists a +} 1 + +test exists-1.1 "Exists var" { + unset -nocomplain b + exists b +} 0 + +test exists-1.1 "Exists -var" { + exists -var a +} 1 + +test exists-1.1 "Exists -var" { + exists -var b +} 0 + +test exists-1.1 "Exists in proc" { + proc a {name} { exists $name } + a ::a +} 1 + +test exists-1.1 "Exists in proc" { + a ::b +} 0 + +test exists-1.1 "Exists in proc" { + a name +} 1 + +test exists-1.1 "Exists in proc" { + a none +} 0 + +test exists-1.1 "Exists -proc" { + exists -proc a +} 1 + +test exists-1.1 "Exists -proc" { + exists -proc bogus +} 0 + +test exists-1.1 "Exists -proc" { + exists -proc info +} 0 + +test exists-1.1 "Exists -command" { + exists -command a +} 1 + +test exists-1.1 "Exists -command" { + exists -command info +} 1 + +test exists-1.1 "Exists -command" { + exists -command bogus +} 0 + +test exists-1.1 "Exists local lambda after exit" { + proc a {} { + local lambda {} {dummy} + } + exists -proc [a] +} 0 + +test exists-1.1 "Exists local lambda" { + proc a {} { + exists -proc [local lambda {} {dummy}] + } + a +} 1 + +testreport |