Tcl test cases depend on hash order
Closed / Fixed218943ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:08:25
OriginalBugID: 2862 Bug
Version: 8.2
SubmitDate: '1999-09-21'
LastModified: '2000-04-03'
Severity: LOW
Status: Released
Submitter: techsupp
ChangedBy: hobbs
OS: Linux
OSVersion: RedHat
Machine: Other
FixedDate: '2000-04-03'
FixedInVersion: 8.3.1
ClosedDate: '2000-10-25'
Name:
mo
Extensions:
Itcl
Comments:
Adding this patch has the added benefit that if you ever change the
hashtable implementation of Tcl in the future, the test cases will
pass without changes.
ReproducibleScript:
I ran into some problems with the way Tcl test cases check results of
tests
that depend on the hash order for variable and methlods. When run in Tcl
these tests pass, but when run in Jacl they fail because Jacl's
Hashtable
uses a different Hashtable algo. This patch fixes the test cases so that
they pass in both Tcl and Jacl.
Patch:
Index: tests/foreach.test
===================================================================
RCS file: /cvsroot/tcl/tests/foreach.test,v
retrieving revision 1.3
diff -u -r1.3 foreach.test
--- foreach.test1999/04/16 00:47:271.3
+++ foreach.test1999/09/21 21:44:59
@@ -156,8 +156,8 @@
return $l
}
array set x {0 zero 1 one 2 two 3 three}
- foo x
-} {{0 zero} {1 one} {2 two} {3 three}}
+ lsort [foo x]
+} [lsort {{0 zero} {1 one} {2 two} {3 three}}]
test foreach-4.1 {noncompiled foreach and shared variable or value list objects that are converted to another type} {
catch {unset x}
Index: tests/namespace-old.test
===================================================================
RCS file: /cvsroot/tcl/tests/namespace-old.test,v
retrieving revision 1.3
diff -u -r1.3 namespace-old.test
--- namespace-old.test1999/04/16 00:47:311.3
+++ namespace-old.test1999/09/21 21:44:59
@@ -743,13 +743,13 @@
proc cmd1 {x y} {
return [expr $x+$y]
}
- list [catch {namespace import test_ns_import::cmd?} msg] $msg \
+ list [catch {namespace import test_ns_import::cmd1} msg] $msg \
[cmd1 3 5]
} {1 {can't import command "cmd1": already exists} 8}
test namespace-old-9.16 {use "-force" option to override existing commands} {
list [cmd1 3 5] \
- [namespace import -force test_ns_import::cmd?] \
+ [namespace import -force test_ns_import::cmd1] \
[cmd1 3 5]
} {8 {} {cmd1: 3 5}}
Index: tests/namespace.test
===================================================================
RCS file: /cvsroot/tcl/tests/namespace.test,v
retrieving revision 1.4
diff -u -r1.4 namespace.test
--- namespace.test1999/04/16 00:47:311.4
+++ namespace.test1999/09/21 21:44:59
@@ -102,8 +102,8 @@
namespace eval test_ns_2:: {}
namespace eval test_ns_3:: {}
}
- namespace children ::test_ns_1
-} {::test_ns_1::test_ns_2 ::test_ns_1::test_ns_3}
+ lsort [namespace children ::test_ns_1]
+} [lsort {::test_ns_1::test_ns_2 ::test_ns_1::test_ns_3}]
test namespace-6.5 {Tcl_CreateNamespace, relative ns names now only looked up in current ns} {
set trigger {
namespace eval test_ns_2 {namespace current}
@@ -188,10 +188,10 @@
namespace import ::test_ns_export::*
proc p {} {return foo}
}
- list [info commands test_ns_import::*] \
+ list [lsort [info commands test_ns_import::*]] \
[namespace delete test_ns_export] \
[info commands test_ns_import::*]
-} {{::test_ns_import::p ::test_ns_import::cmd1 ::test_ns_import::cmd2} {} ::test_ns_import::p}
+} [list [lsort {::test_ns_import::p ::test_ns_import::cmd1 ::test_ns_import::cmd2}] {} ::test_ns_import::p]
test namespace-9.1 {Tcl_Import, empty import pattern} {
catch {eval namespace delete [namespace children :: test_ns_*]}
@@ -262,12 +262,12 @@
namespace import ::test_ns_export::*
proc p {} {return [cmd1 123]}
set l {}
- lappend l [info commands ::test_ns_import::*]
+ lappend l [lsort [info commands ::test_ns_import::*]]
namespace forget ::test_ns_export::cmd1
- lappend l [info commands ::test_ns_import::*]
+ lappend l [lsort [info commands ::test_ns_import::*]]
lappend l [catch {cmd1 777} msg] $msg
}
-} {{::test_ns_import::p ::test_ns_import::cmd1} ::test_ns_import::p 1 {invalid command name "cmd1"}}
+} [list [lsort {::test_ns_import::p ::test_ns_import::cmd1}] ::test_ns_import::p 1 {invalid command name "cmd1"}]
test namespace-11.1 {TclGetOriginalCommand, check if not imported cmd} {
catch {eval namespace delete [namespace children :: test_ns_*]}
@@ -325,9 +325,9 @@
}
namespace eval test_ns_1 {
list $::v $::test_ns_2::v $::test_ns_1::test_ns_2::v \
- [namespace children :: test_ns_*]
+ [lsort [namespace children :: test_ns_*]]
}
-} {10 30 20 {::test_ns_1 ::test_ns_2}}
+} [list 10 30 20 [lsort {::test_ns_1 ::test_ns_2}]]
test namespace-14.2 {TclGetNamespaceForQualName, invalid absolute names} {
namespace eval test_ns_1 {
list [catch {set ::test_ns_777::v} msg] $msg \
@@ -800,8 +800,8 @@
namespace eval test_ns_2 {
namespace import -force ::test_ns_1::*
}
- list [info commands test_ns_2::*] [test_ns_2::cmd3 hello]
-} {{::test_ns_2::cmd1 ::test_ns_2::cmd3} {cmd3: hello}}
+ list [lsort [info commands test_ns_2::*]] [test_ns_2::cmd3 hello]
+} [list [lsort {::test_ns_2::cmd1 ::test_ns_2::cmd3}] {cmd3: hello}]
test namespace-26.6 {NamespaceExportCmd, no patterns means return export list} {
namespace eval test_ns_1 {
namespace export
@@ -814,8 +814,8 @@
namespace eval test_ns_2 {
namespace import ::test_ns_1::*
}
- list [info commands test_ns_2::*] [test_ns_2::cmd4 hello]
-} {{::test_ns_2::cmd4 ::test_ns_2::cmd1 ::test_ns_2::cmd3} {cmd4: hello}}
+ list [lsort [info commands test_ns_2::*]] [test_ns_2::cmd4 hello]
+} [list [lsort {::test_ns_2::cmd4 ::test_ns_2::cmd1 ::test_ns_2::cmd3}] {cmd4: hello}]
test namespace-27.1 {NamespaceForgetCmd, no args} {
catch {eval namespace delete [namespace children :: test_ns_*]}
Index: tests/var.test
===================================================================
RCS file: /cvsroot/tcl/tests/var.test,v
retrieving revision 1.5
diff -u -r1.5 var.test
--- var.test1999/04/16 00:47:361.5
+++ var.test1999/09/21 21:44:59
@@ -342,16 +342,16 @@
namespace eval test_ns_var {
variable two 2
}
- list [info vars test_ns_var::*] \
+ list [lsort [info vars test_ns_var::*]] \
[namespace eval test_ns_var {set two}]
-} {{::test_ns_var::two ::test_ns_var::one} 2}
+} [list [lsort {::test_ns_var::two ::test_ns_var::one}] 2]
test var-7.4 {Tcl_VariableObjCmd, list of vars} {
namespace eval test_ns_var {
variable three 3 four 4
}
- list [info vars test_ns_var::*] \
+ list [lsort [info vars test_ns_var::*]] \
[namespace eval test_ns_var {expr $three+$four}]
-} {{::test_ns_var::four ::test_ns_var::three ::test_ns_var::two ::test_ns_var::one} 7}
+} [list [lsort {::test_ns_var::four ::test_ns_var::three ::test_ns_var::two ::test_ns_var::one}] 7]
test var-7.5 {Tcl_VariableObjCmd, value for last var is optional} {
catch {unset a}
catch {unset five}
@@ -400,28 +400,28 @@
variable y
variable z
}
- lappend a [info vars test_ns_var2::*]
+ lappend a [lsort [info vars test_ns_var2::*]]
lappend a [info exists test_ns_var2::x] [info exists test_ns_var2::y] \
[info exists test_ns_var2::z]
lappend a [list [catch {set test_ns_var2::y} msg] $msg]
- lappend a [info vars test_ns_var2::*]
+ lappend a [lsort [info vars test_ns_var2::*]]
lappend a [info exists test_ns_var2::y] [info exists test_ns_var2::z]
lappend a [set test_ns_var2::y hello]
lappend a [info exists test_ns_var2::y] [info exists test_ns_var2::z]
lappend a [list [catch {unset test_ns_var2::y} msg] $msg]
- lappend a [info vars test_ns_var2::*]
+ lappend a [lsort [info vars test_ns_var2::*]]
lappend a [info exists test_ns_var2::y] [info exists test_ns_var2::z]
lappend a [list [catch {unset test_ns_var2::z} msg] $msg]
lappend a [namespace delete test_ns_var2]
set a
-} {{::test_ns_var2::x ::test_ns_var2::y ::test_ns_var2::z} 1 0 0\
+} [list [lsort {::test_ns_var2::x ::test_ns_var2::y ::test_ns_var2::z}] 1 0 0\
{1 {can't read "test_ns_var2::y": no such variable}}\
-{::test_ns_var2::x ::test_ns_var2::y ::test_ns_var2::z} 0 0\
+[lsort {::test_ns_var2::x ::test_ns_var2::y ::test_ns_var2::z}] 0 0\
hello 1 0\
{0 {}}\
-{::test_ns_var2::x ::test_ns_var2::z} 0 0\
+[lsort {::test_ns_var2::x ::test_ns_var2::z}] 0 0\
{1 {can't unset "test_ns_var2::z": no such variable}}\
-{}}
+{}]
test var-7.10 {Tcl_VariableObjCmd, variable cmd inside proc creates local link var} {
namespace eval test_ns_var {
proc p {} {
PatchFiles:
tests/foreach.test
tests/namespace-old.test
tests/namespace.test
tests/var.test
All but namespace-old.test patched as given (the other two seemed
to not be lsort related - should work as advertised).
-- 04/03/2000 hobbs
welch Closed ticket [218943ffff].
[History diff]2000-10-26 08:32:14
dgp Ticket [218943ffff]: 3 changes
[History diff]2001-04-06 02:34:35
Log in (anonymous is fine) to add a comment.