summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorsbron <tclcore@tclcode.com>2022-08-24 11:19:14 (GMT)
committersbron <tclcore@tclcode.com>2022-08-24 11:19:14 (GMT)
commit42dd6088a6a1dd034174d0f9ec84f2f22c9a6e4d (patch)
treea925b1eacc227691c468ea62f675e449a67189aa /tests
parent2d455c75b957f96586b3ca1d1b83b4b9a3283c55 (diff)
downloadtcl-42dd6088a6a1dd034174d0f9ec84f2f22c9a6e4d.zip
tcl-42dd6088a6a1dd034174d0f9ec84f2f22c9a6e4d.tar.gz
tcl-42dd6088a6a1dd034174d0f9ec84f2f22c9a6e4d.tar.bz2
Add tests for the TIP #634 functionality.
Diffstat (limited to 'tests')
-rw-r--r--tests/upvar.test45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/upvar.test b/tests/upvar.test
index c31eaa1..268bb17 100644
--- a/tests/upvar.test
+++ b/tests/upvar.test
@@ -207,6 +207,51 @@ test upvar-5.3 {traces involving upvars} {
p1 foo bar
set x
} {{x1 {} u} x1}
+test upvar-5.4 {read trace on upvar array element} -body {
+ proc p1 {a b} {
+ array set foo {c 22 d 33}
+ trace add variable foo {read write unset} tproc
+ p2
+ trace remove variable foo {read write unset} tproc
+ }
+ proc p2 {} {
+ upvar foo(c) x1
+ set x1
+ }
+ set x ---
+ p1 foo bar
+ set x
+} -result {{x1 {} read} x1}
+test upvar-5.5 {write trace on upvar array element} -body {
+ proc p1 {a b} {
+ array set foo {c 22 d 33}
+ trace add variable foo {read write unset} tproc
+ p2
+ trace remove variable foo {read write unset} tproc
+ }
+ proc p2 {} {
+ upvar foo(c) x1
+ set x1 22
+ }
+ set x ---
+ p1 foo bar
+ set x
+} -result {{x1 {} write} x1}
+test upvar-5.6 {unset trace on upvar array element} -body {
+ proc p1 {a b} {
+ array set foo {c 22 d 33}
+ trace add variable foo {read write unset} tproc
+ p2
+ trace remove variable foo {read write unset} tproc
+ }
+ proc p2 {} {
+ upvar foo(c) x1
+ unset x1
+ }
+ set x ---
+ p1 foo bar
+ set x
+} -result {{x1 {} unset} x1}
test upvar-6.1 {retargeting an upvar} {
proc p1 {} {