summaryrefslogtreecommitdiffstats
path: root/tests/dict.test
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dict.test')
-rw-r--r--tests/dict.test44
1 files changed, 30 insertions, 14 deletions
diff --git a/tests/dict.test b/tests/dict.test
index 1515675..59b600e 100644
--- a/tests/dict.test
+++ b/tests/dict.test
@@ -14,6 +14,13 @@ if {"::tcltest" ni [namespace children]} {
namespace import -force ::tcltest::*
}
+catch {
+ ::tcltest::loadTestedCommands
+ package require -exact tcl::test [info patchlevel]
+}
+
+testConstraint testobj [llength [info commands testobj]]
+
# Used for constraining memory leak tests
testConstraint memory [llength [info commands memory]]
if {[testConstraint memory]} {
@@ -27,6 +34,7 @@ if {[testConstraint memory]} {
expr {$end - $tmp}
}
}
+
test dict-1.1 {dict command basic syntax} -returnCodes error -body {
dict
@@ -138,8 +146,16 @@ test dict-3.15 {compiled dict get error cleanliness - Bug 2431847} -body {
dict get $a(z) d
}}
} -returnCodes error -result {key "d" not known in dictionary}
-test dict-3.16 {dict/list shimmering - Bug 3004007} {set l [list p 1 p 2 q 3];dict get $l q;set l} {p 1 p 2 q 3}
-test dict-3.17 {dict/list shimmering - Bug 3004007} {set l [list p 1 p 2 q 3];dict get $l q;llength $l} 6
+test dict-3.16 {dict/list shimmering - Bug 3004007} testobj {
+ set l [list p 1 p 2 q 3]
+ dict get $l q
+ list $l [testobj objtype $l]
+} {{p 1 p 2 q 3} dict}
+test dict-3.17 {dict/list shimmering - Bug 3004007} testobj {
+ set l [list p 1 p 2 q 3]
+ dict get $l q
+ list [llength $l] [testobj objtype $l]
+} {6 dict}
test dict-4.1 {dict replace command} {
dict replace {a b c d}
@@ -657,20 +673,20 @@ test dict-14.13 {dict for command: script results} {
error "return didn't go far enough"
}}
} ok,a,b
-test dict-14.14 {dict for command: handle representation loss} -body {
+test dict-14.14 {dict for command: handle representation loss} -constraints testobj -body {
set dictVar {a b c d e f g h}
set keys {}
set values {}
dict for {k v} $dictVar {
- if {[llength $dictVar]} {
+ if {[string length $dictVar]} {
lappend keys $k
lappend values $v
}
}
- list [lsort $keys] [lsort $values]
+ list [lsort $keys] [lsort $values] [testobj objtype $dictVar]
} -cleanup {
unset dictVar keys values k v
-} -result {{a c e g} {b d f h}}
+} -result {{a c e g} {b d f h} string}
test dict-14.15 {dict for command: keys are unique and iterated over once only} -setup {
unset -nocomplain accum
array set accum {}
@@ -1802,33 +1818,33 @@ test dict-24.13 {dict map command: script results} {
error "return didn't go far enough"
}}
} ok,a,b
-test dict-24.14 {dict map command: handle representation loss} -setup {
+test dict-24.14 {dict map command: handle representation loss} -constraints testobj -setup {
set keys {}
set values {}
} -body {
set dictVar {a b c d e f g h}
list [dict size [dict map {k v} $dictVar {
- if {[llength $dictVar]} {
+ if {[string length $dictVar]} {
lappend keys $k
lappend values $v
return -level 0 $k
}
- }]] [lsort $keys] [lsort $values]
+ }]] [lsort $keys] [lsort $values] [testobj objtype $dictVar]
} -cleanup {
unset dictVar keys values k v
-} -result {4 {a c e g} {b d f h}}
-test dict-24.14a {dict map command: handle representation loss} -body {
+} -result {4 {a c e g} {b d f h} string}
+test dict-24.14a {dict map command: handle representation loss} -constraints testobj -body {
apply {{} {
set dictVar {a b c d e f g h}
list [dict size [dict map {k v} $dictVar {
- if {[llength $dictVar]} {
+ if {[string length $dictVar]} {
lappend keys $k
lappend values $v
return -level 0 $k
}
- }]] [lsort $keys] [lsort $values]
+ }]] [lsort $keys] [lsort $values] [testobj objtype $dictVar]
}}
-} -result {4 {a c e g} {b d f h}}
+} -result {4 {a c e g} {b d f h} string}
test dict-24.15 {dict map command: keys are unique and iterated over once only} -setup {
unset -nocomplain accum
array set accum {}