summaryrefslogtreecommitdiff
path: root/tests/misc.test
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2010-12-15 23:52:59 +1000
committerSteve Bennett <steveb@workware.net.au>2010-12-15 23:52:59 +1000
commit4f988c521cf54e2353ed4933fefcca4cb778bcdb (patch)
tree7fa2d653bf52ab8cec3aee5f6d63aed7cb6a4895 /tests/misc.test
parent89250b07b814d1634c2ca8d83212cea582c1440a (diff)
Fix an object sharing bug for arrays
Commands which modify variables in place such as append, lappend, incr and lset did not correctly account for modifying a shared array through an array element (dict sugar). Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'tests/misc.test')
-rw-r--r--tests/misc.test28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/misc.test b/tests/misc.test
index f9a2de7..f259185 100644
--- a/tests/misc.test
+++ b/tests/misc.test
@@ -338,4 +338,32 @@ test parsevar-1.1 "Variables should include double colons" {
set x
} 2
+test sharing-1.1 "Problems with ref sharing in arrays: lappend" {
+ set a {a 1 c 2}
+ set b $a
+ lappend b(c) 3
+ set a(c)
+} 2
+
+test sharing-1.2 "Problems with ref sharing in arrays: append" {
+ set a {a 1 c 2}
+ set b $a
+ append b(c) 3
+ set a(c)
+} 2
+
+test sharing-1.3 "Problems with ref sharing in arrays: incr" {
+ set a {a 1 c 2}
+ set b $a
+ incr b(c)
+ set a(c)
+} 2
+
+test sharing-1.4 "Problems with ref sharing in arrays: lset" {
+ set a {a 1 c {2 3}}
+ set b $a
+ lset b(c) 1 x
+ set a(c)
+} {2 3}
+
testreport