aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2023-02-24 12:59:56 +1000
committerSteve Bennett <steveb@workware.net.au>2023-02-24 13:02:31 +1000
commit7eb6fdddafb7ee98afd8dc170a23bfbb32708994 (patch)
tree9cfdb2dc8baffea9d0c58286b06be4c3c550f62d /tests
parent23603d8c3d482a9f92a949c9da1c71a0c8e68343 (diff)
downloadjimtcl-7eb6fdddafb7ee98afd8dc170a23bfbb32708994.zip
jimtcl-7eb6fdddafb7ee98afd8dc170a23bfbb32708994.tar.gz
jimtcl-7eb6fdddafb7ee98afd8dc170a23bfbb32708994.tar.bz2
dict with: return script result
Previously dict with returned the new dict value. Also fix an issue in the case where a dict element mirrors the name of the dictionary. Fixes: #241 Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'tests')
-rw-r--r--tests/dict.test12
-rw-r--r--tests/dict2.test9
2 files changed, 19 insertions, 2 deletions
diff --git a/tests/dict.test b/tests/dict.test
index f77d95e..0c2c395 100644
--- a/tests/dict.test
+++ b/tests/dict.test
@@ -114,6 +114,18 @@ test dict-5.2 {Dict with} {
}
dictsort [a]
} {a B}
+test dict-5.3 {Dict with return value} {
+ proc a {} {
+ set x [dict create a b c d]
+ dict with x {
+ set a B
+ unset c
+ # dict with should return the script return value
+ set retvalue ok
+ }
+ }
+ a
+} {ok}
test dict-22.1 {dict with command} {
list [catch {dict with} msg] $msg
diff --git a/tests/dict2.test b/tests/dict2.test
index 99cf605..573d17a 100644
--- a/tests/dict2.test
+++ b/tests/dict2.test
@@ -1272,8 +1272,13 @@ test dict-23.4 {dict with usage} -body {
} -returnCodes error -result {wrong # args: should be "dict with dictVar ?key ...? script"}
test dict-23.5 {dict with badvar} -constraints jim -body {
- dict with dictnulls {lsort [info locals]}
-} -returnCodes ok -result [list ab\0c de\0f \0ghi kl\0m]
+ proc a {dict} {
+ dict with dict {
+ lsort [info locals]
+ }
+ }
+ a $dictnulls
+} -returnCodes ok -result [list \0ghi ab\0c dict]
test dict-23.6 {dict with baddict} -body {
dict with dictbad {}