aboutsummaryrefslogtreecommitdiff
path: root/test.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'test.tcl')
-rw-r--r--test.tcl60
1 files changed, 57 insertions, 3 deletions
diff --git a/test.tcl b/test.tcl
index ac45d4c..9f0a312 100644
--- a/test.tcl
+++ b/test.tcl
@@ -1,4 +1,4 @@
-# $Id: test.tcl,v 1.26 2005/03/24 13:58:05 antirez Exp $
+# $Id: test.tcl,v 1.27 2005/03/28 16:57:36 antirez Exp $
#
# This are Tcl tests imported into Jim. Tests that will probably not be passed
# in the long term are usually removed (for example all the tests about
@@ -28,8 +28,6 @@ proc test {id descr script expectedResult} {
}
}
-proc error {msg} { return -code error $msg }
-
################################################################################
# SET
################################################################################
@@ -4140,6 +4138,62 @@ test range-5.0 {lindex llength range test} {
} {164150}
################################################################################
+# SCOPE
+################################################################################
+test scope-1.0 {Non existing var} {
+ catch {unset x}
+ scope x {
+ set x 10
+ set y [+ $x 1]
+ }
+ list [info exists x] $y
+} {0 11}
+
+test scope-1.1 {Existing var restore} {
+ set x 100
+ scope x {
+ for {set x 0} {$x < 10} {incr x} {}
+ }
+ set x
+} {100}
+
+test scope-1.2 {Mix of 1.0 and 1.1 tests} {
+ catch {unset x}
+ set y 10
+ scope {x y} {
+ set y 100
+ set x 200
+ }
+ list [info exists x] $y
+} {0 10}
+
+test scope-1.3 {Array element} {
+ set x "a 1 b 2"
+ scope x(a) {
+ set x(a) Hello!
+ }
+ set x(a)
+} {1}
+
+test scope-1.4 {Non existing array element} {
+ catch {unset x}
+ scope x(a) {
+ set x(a) Hello!
+ }
+ info exists x(a)
+} {0}
+
+test scope-1.5 {Array element and var contaning the dict modifications} {
+ set x "a 1 b 2"
+ scope {x(a) x} {
+ set x "foo"
+ }
+ set x
+} {a 1 b 2}
+
+catch {unset y}
+
+################################################################################
# JIM REGRESSION TESTS
################################################################################
test regression-1.0 {Rename against procedures with static vars} {