aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2013-12-12 14:07:36 +1000
committerSteve Bennett <steveb@workware.net.au>2013-12-21 01:30:03 +1000
commit0cbbaaff6a5bfc61640ce6997b203ed23219841c (patch)
treedf17afab2f89fc8875a56546d55fd8c3048429a9 /tests
parent63bc08c2ec6e1744eed22160f8b7fd1078a9b49f (diff)
downloadjimtcl-0cbbaaff6a5bfc61640ce6997b203ed23219841c.zip
jimtcl-0cbbaaff6a5bfc61640ce6997b203ed23219841c.tar.gz
jimtcl-0cbbaaff6a5bfc61640ce6997b203ed23219841c.tar.bz2
Fix hash table order dependency in various tests
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile2
-rw-r--r--tests/apply.test10
-rw-r--r--tests/misc.test12
-rw-r--r--tests/testing.tcl7
-rw-r--r--tests/upvar.test4
5 files changed, 24 insertions, 11 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 2c168ea..6380571 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,7 +1,7 @@
jimsh ?= ../jimsh
test:
- @for i in *.test; do LD_LIBRARY_PATH=..:$(LD_LIBRARY_PATH) $(jimsh) $$i; done
+ @set -e; for i in *.test; do LD_LIBRARY_PATH=..:$(LD_LIBRARY_PATH) $(jimsh) $$i; done
clean:
rm -f gorp.file2 gorp.file sleepx test1 exec.tmp1
diff --git a/tests/apply.test b/tests/apply.test
index 1087fec..abf6438 100644
--- a/tests/apply.test
+++ b/tests/apply.test
@@ -89,7 +89,7 @@ test apply-6.3 {info level} tcl {
set applyBody {
set res {}
- foreach v [info locals] {
+ foreach v [lsort [info locals]] {
if {$v eq "res"} continue
lappend res [list $v [set $v]]
}
@@ -101,10 +101,10 @@ test apply-8.1 {args treatment} {
} {{args {1 2 3}}}
test apply-8.2 {args treatment} {
apply [list {x args} $applyBody] 1 2
-} {{x 1} {args 2}}
+} {{args 2} {x 1}}
test apply-8.3 {args treatment} {
apply [list {x args} $applyBody] 1 2 3
-} {{x 1} {args {2 3}}}
+} {{args {2 3}} {x 1}}
test apply-8.4 {default values} {
apply [list {{x 1} {y 2}} $applyBody]
} {{x 1} {y 2}}
@@ -122,10 +122,10 @@ test apply-8.8 {default values} {
} {{x 1} {y 3}}
test apply-8.9 {default values} {
apply [list {x {y 2} args} $applyBody] 1
-} {{x 1} {y 2} {args {}}}
+} {{args {}} {x 1} {y 2}}
test apply-8.10 {default values} {
apply [list {x {y 2} args} $applyBody] 1 3
-} {{x 1} {y 3} {args {}}}
+} {{args {}} {x 1} {y 3}}
::tcltest::cleanupTests
return
diff --git a/tests/misc.test b/tests/misc.test
index 925283e..9a9ac35 100644
--- a/tests/misc.test
+++ b/tests/misc.test
@@ -531,7 +531,13 @@ test lset-1.1 "lset with bad var" {
test dict-1.1 "dict to string" {
set a [dict create abc \\ def \"]
set x x$a
-} "xabc \\\\ def {\"}"
+ # The order of keys in the dictionary is random
+ if {$x eq "xabc \\\\ def {\"}" || $x eq "xdef {\"} abc \\\\"} {
+ return ok
+ } else {
+ return "failed: \"$x\""
+ }
+} ok
test channels-1.1 {info channels} {
lsort [info channels]
@@ -557,7 +563,7 @@ test eval-list-1.1 {Lost string rep with list} {
test info-statics-1.1 {info statics commands} {
set x 1
proc a {} {x {y 2}} {}
- info statics a
-} {x 1 y 2}
+ lsort [info statics a]
+} {1 2 x y}
testreport
diff --git a/tests/testing.tcl b/tests/testing.tcl
index c5e311d..30aecee 100644
--- a/tests/testing.tcl
+++ b/tests/testing.tcl
@@ -1,6 +1,7 @@
# Common code
set testinfo(verbose) 0
set testinfo(numpass) 0
+set testinfo(stoponerror) 0
set testinfo(numfail) 0
set testinfo(numskip) 0
set testinfo(numtests) 0
@@ -12,6 +13,9 @@ set bindir [file dirname [info nameofexecutable]]
if {[lsearch $argv "-verbose"] >= 0 || [info exists env(testverbose)]} {
incr testinfo(verbose)
}
+if {[lsearch $argv "-stoponerror"] >= 0 || [info exists env(stoponerror)]} {
+ incr testinfo(stoponerror)
+}
proc needs {type what {packages {}}} {
if {$type eq "constraint"} {
@@ -194,6 +198,9 @@ proc test {id descr args} {
puts ""
incr ::testinfo(numfail)
lappend ::testinfo(failed) [list $id $descr $source $expected $result]
+ if {$::testinfo(stoponerror)} {
+ exit 1
+ }
}
proc ::tcltest::cleanupTests {} {
diff --git a/tests/upvar.test b/tests/upvar.test
index 8d95c1d..261f7b9 100644
--- a/tests/upvar.test
+++ b/tests/upvar.test
@@ -142,7 +142,7 @@ test upvar-3.5 {unsetting array elements with upvar} {
set a(1) first
set a(2) second
p2
- array names a
+ lsort [array names a]
}
proc p2 {} {upvar a(0) x; unset x}
p1
@@ -153,7 +153,7 @@ test upvar-3.6 {unsetting then resetting array elements with upvar} {
set a(1) first
set a(2) second
p2
- list [array names a] [catch {set a(0)} msg] $msg
+ list [lsort [array names a]] [catch {set a(0)} msg] $msg
}
proc p2 {} {upvar a(0) x; unset x; set x 12345}
p1