summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/cmdIL.test38
-rw-r--r--tests/compile.test55
-rw-r--r--tests/event.test4
-rw-r--r--tests/info.test14
-rw-r--r--tests/io.test1
-rw-r--r--tests/set-old.test23
-rw-r--r--tests/unixNotfy.test1
-rw-r--r--tests/upvar.test5
8 files changed, 132 insertions, 9 deletions
diff --git a/tests/cmdIL.test b/tests/cmdIL.test
index 5b56105..71ec774 100644
--- a/tests/cmdIL.test
+++ b/tests/cmdIL.test
@@ -251,3 +251,41 @@ test cmdIL-4.22 {DictionaryCompare procedure, case} {
test cmdIL-4.23 {DictionaryCompare procedure, case} {
lsort -dictionary {ABcd AbCd}
} {ABcd AbCd}
+test cmdIL-4.24 {DefaultCompare procedure, signed characters} {
+ set l [lsort [list "abc\200" "abc"]]
+ set viewlist {}
+ foreach s $l {
+ set viewelem ""
+ set len [string length $s]
+ for {set i 0} {$i < $len} {incr i} {
+ set c [string index $s $i]
+ scan $c %c d
+ if {$d > 0 && $d < 128} {
+ append viewelem $c
+ } else {
+ append viewelem "\\[format %03o $d]"
+ }
+ }
+ lappend viewlist $viewelem
+ }
+ set viewlist
+} [list "abc" "abc\\200"]
+test cmdIL-4.25 {DictionaryCompare procedure, signed characters} {
+ set l [lsort -dictionary [list "abc\200" "abc"]]
+ set viewlist {}
+ foreach s $l {
+ set viewelem ""
+ set len [string length $s]
+ for {set i 0} {$i < $len} {incr i} {
+ set c [string index $s $i]
+ scan $c %c d
+ if {$d > 0 && $d < 128} {
+ append viewelem $c
+ } else {
+ append viewelem "\\[format %03o $d]"
+ }
+ }
+ lappend viewlist $viewelem
+ }
+ set viewlist
+} [list "abc" "abc\\200"]
diff --git a/tests/compile.test b/tests/compile.test
index 9e30fb3..4720d35 100644
--- a/tests/compile.test
+++ b/tests/compile.test
@@ -69,7 +69,35 @@ test compile-2.4 {TclCompileDollarVar: global scalar name with ::s} {
list [p] $::a(1) [expr {[lsearch -exact [info globals] a] != 0}]
} {1 1 1}
-test compile-3.1 {TclCompileSetCmd: global scalar names with ::s} {
+test compile-1.16 {TclCompileForCmd: command substituted test expression} {
+ set i 0
+ set j 0
+ # Should be "forever"
+ for {} [expr $i < 3] {} {
+ set j [incr i]
+ if {$j > 3} break
+ }
+ set j
+} {4}
+
+test compile-3.1 {TclCompileForeachCmd: exception stack} {
+ proc foreach-exception-test {} {
+ foreach array(index) [list 1 2 3] break
+ foreach array(index) [list 1 2 3] break
+ foreach scalar [list 1 2 3] break
+ }
+ list [catch foreach-exception-test result] $result
+} {0 {}}
+test compile-3.2 {TclCompileForeachCmd: non-local variables} {
+ set ::foo 1
+ proc foreach-test {} {
+ foreach ::foo {1 2 3} {}
+ }
+ foreach-test
+ set ::foo
+} 3
+
+test compile-4.1 {TclCompileSetCmd: global scalar names with ::s} {
catch {unset x}
catch {unset y}
set x 123
@@ -80,7 +108,7 @@ test compile-3.1 {TclCompileSetCmd: global scalar names with ::s} {
list $::x [expr {[lsearch -exact [info globals] x] != 0}] \
[p] $::y [expr {[lsearch -exact [info globals] y] != 0}]
} {123 1 789 789 1}
-test compile-3.2 {TclCompileSetCmd: global array names with ::s} {
+test compile-4.2 {TclCompileSetCmd: global array names with ::s} {
catch {unset a}
set ::a(1) 2
proc p {} {
@@ -89,7 +117,7 @@ test compile-3.2 {TclCompileSetCmd: global array names with ::s} {
}
list $::a(1) [p] [set ::a($::a(1)) 3] $::a(1) [expr {[lsearch -exact [info globals] a] != 0}]
} {2 1 3 3 1}
-test compile-3.3 {TclCompileSetCmd: namespace var names with ::s} {
+test compile-4.3 {TclCompileSetCmd: namespace var names with ::s} {
catch {namespace delete test_ns_compile}
catch {unset x}
namespace eval test_ns_compile {
@@ -101,17 +129,28 @@ test compile-3.3 {TclCompileSetCmd: namespace var names with ::s} {
list $::x $::test_ns_compile::arr(1)
} {hello 123}
-test compile-4.1 {CollectArgInfo: binary data} {
+test compile-1.15 {TclCompileWhileCmd: command substituted test expression} {
+ set i 0
+ set j 0
+ # Should be "forever"
+ while [expr $i < 3] {
+ set j [incr i]
+ if {$j > 3} break
+ }
+ set j
+} {4}
+
+test compile-5.1 {CollectArgInfo: binary data} {
list [catch "string length \000foo" msg] $msg
} {0 4}
-test compile-4.2 {CollectArgInfo: binary data} {
+test compile-5.2 {CollectArgInfo: binary data} {
list [catch "string length foo\000" msg] $msg
} {0 4}
-test compile-4.3 {CollectArgInfo: handle "]" at end of command properly} {
+test compile-5.3 {CollectArgInfo: handle "]" at end of command properly} {
set x ]
} {]}
-test compile-5.1 {UpdateStringOfByteCode: called for duplicate of compiled empty object} {
+test compile-6.1 {UpdateStringOfByteCode: called for duplicate of compiled empty object} {
proc p {} {
set x {}
eval $x
@@ -126,3 +165,5 @@ catch {namespace delete test_ns_compile}
catch {unset x}
catch {unset y}
catch {unset a}
+
+return
diff --git a/tests/event.test b/tests/event.test
index 027f7e0..e8d0462 100644
--- a/tests/event.test
+++ b/tests/event.test
@@ -384,8 +384,8 @@ test event-11.5 {Tcl_VwaitCmd procedure: round robin scheduling, 2 sources} {soc
puts $s foobar
close $s
}
- set s1 [socket -server accept 5000]
- set s2 [socket 127.0.0.1 5000]
+ set s1 [socket -server accept 5001]
+ set s2 [socket 127.0.0.1 5001]
close $s1
set x 0
set y 0
diff --git a/tests/info.test b/tests/info.test
index 784dad1..38cb8ee 100644
--- a/tests/info.test
+++ b/tests/info.test
@@ -449,6 +449,13 @@ test info-12.6 {info locals vs unset compiled locals} {
}
lsort [t1 {a b c c d e f}]
} {a b c d e f}
+test info-12.7 {info locals with temporary variables} {
+ proc t1 {} {
+ foreach a {b c} {}
+ info locals
+ }
+ t1
+} {a}
test info-13.1 {info nameofexecutable option} {
list [catch {info nameofexecutable foo} msg] $msg
@@ -558,6 +565,13 @@ test info-19.3 {info vars option} {
test info-19.4 {info vars option} {
list [catch {info vars a b} msg] $msg
} {1 {wrong # args: should be "info vars ?pattern?"}}
+test info-19.5 {info vars with temporary variables} {
+ proc t1 {} {
+ foreach a {b c} {}
+ info vars
+ }
+ t1
+} {a}
test info-20.1 {miscellaneous error conditions} {
list [catch {info} msg] $msg
diff --git a/tests/io.test b/tests/io.test
index 1cde686..e2a48dd 100644
--- a/tests/io.test
+++ b/tests/io.test
@@ -5122,6 +5122,7 @@ test io-33.1 {ChannelTimerProc} {
testchannelevent $f set 0 none
after idle {set y done}
vwait y
+ close $f
lappend result $y
} {2 done}
diff --git a/tests/set-old.test b/tests/set-old.test
index a101e7b..12944f3 100644
--- a/tests/set-old.test
+++ b/tests/set-old.test
@@ -474,6 +474,29 @@ test set-old-8.37 {array command, set option} {
array set aVaRnAmE {}
list [info exists aVaRnAmE] [catch {set aVaRnAmE} msg] $msg
} {1 1 {can't read "aVaRnAmE": variable is array}}
+test set-old-8.37.1 {array command, set scalar} {
+ catch {unset aVaRnAmE}
+ set aVaRnAmE 1
+ list [catch {array set aVaRnAmE {}} msg] $msg
+} {1 {can't array set "aVaRnAmE": variable isn't array}}
+test set-old-8.37.2 {array command, set alias} {
+ catch {unset aVaRnAmE}
+ upvar 0 aVaRnAmE anAliAs
+ array set anAliAs {}
+ list [array exists aVaRnAmE] [catch {set anAliAs} msg] $msg
+} {1 1 {can't read "anAliAs": variable is array}}
+test set-old-8.37.3 {array command, set element alias} {
+ catch {unset aVaRnAmE}
+ list [catch {upvar 0 aVaRnAmE(elem) elemAliAs}] \
+ [catch {array set elemAliAs {}} msg] $msg
+} {0 1 {can't array set "elemAliAs": variable isn't array}}
+test set-old-8.37.4 {array command, empty set with populated array} {
+ catch {unset aVaRnAmE}
+ array set aVaRnAmE [list e1 v1 e2 v2]
+ array set aVaRnAmE {}
+ array set aVaRnAmE [list e3 v3]
+ list [lsort [array names aVaRnAmE]] [catch {set aVaRnAmE(e2)} msg] $msg
+} {{e1 e2 e3} 0 v2}
test set-old-8.38 {array command, size option} {
catch {unset a}
array size a
diff --git a/tests/unixNotfy.test b/tests/unixNotfy.test
index 5ed5f12..bc08ad9 100644
--- a/tests/unixNotfy.test
+++ b/tests/unixNotfy.test
@@ -47,3 +47,4 @@ test unixNotfy-1.2 {Tcl_DeleteFileHandler} {
} {1 {can't wait for variable "x": would wait forever}}
file delete foo
+file delete foo2
diff --git a/tests/upvar.test b/tests/upvar.test
index d9548b0..cb89b56 100644
--- a/tests/upvar.test
+++ b/tests/upvar.test
@@ -327,6 +327,11 @@ test upvar-8.9 {upvar won't create namespace variable that refers to procedure v
}
list [catch {MakeLink 1} msg] $msg
} {1 {bad variable name "a": upvar won't create namespace variable that refers to procedure variable}}
+test upvar-8.10 {upvar will create element alias for new array element} {
+ catch {unset upvarArray}
+ array set upvarArray {}
+ catch {upvar 0 upvarArray(elem) upvarArrayElemAlias}
+} {0}
if {[info commands testupvar] != {}} {
test upvar-9.1 {Tcl_UpVar2 procedure} {