diff options
author | Steve Bennett <steveb@workware.net.au> | 2011-01-24 15:24:15 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2011-05-09 10:29:47 +1000 |
commit | 0afe23b8aa7d9f695be7ba2ff0350c97df6cb669 (patch) | |
tree | 4b96280079361a23b8413dc72204e8e2b4c5d652 /tests/procref.test | |
parent | 24bbe8f092cabff79c990a9ecca030002b9acb6d (diff) | |
download | jimtcl-0afe23b8aa7d9f695be7ba2ff0350c97df6cb669.zip jimtcl-0afe23b8aa7d9f695be7ba2ff0350c97df6cb669.tar.gz jimtcl-0afe23b8aa7d9f695be7ba2ff0350c97df6cb669.tar.bz2 |
Automatic proc upref with & syntax
e.g. proc a {&b &c} ...
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'tests/procref.test')
-rw-r--r-- | tests/procref.test | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/procref.test b/tests/procref.test new file mode 100644 index 0000000..63206d5 --- /dev/null +++ b/tests/procref.test @@ -0,0 +1,56 @@ +# Tests auto-upref with the "&name" syntax + +source [file dirname [info script]]/testing.tcl + +needs constraint jim + +proc a1 {&b c} { + append b b + append c c +} + +proc a2 {&b {dummy 3} &c} { + append b b + append c c +} + +proc a3 {&b(c)} { + append b(c) b_c +} + +# This is treated as a normal var "&b" +proc a4 {{&b x}} { + append &b B +} + +set B 1 +set C 1 + +test procref-1.1 {Basic test} { + a1 B $C + set B +} {1b} + +test procref-1.2 {Basic test} { + a1 B $C + set B +} {1bb} + +test procref-1.3 {Unset var} { + catch {a1 unsetB $C} +} 1 + +test procref-1.4 {Left and right args are refs} { + a2 B C + list $B $C +} {1bbb 1c} + +test procref-1.5 {Invalid arg} { + catch {a3 B} +} 1 + +test procref-1.6 {Default arg as ref} { + a4 +} xB + +testreport |