Artifact
ea5b4e266b06f6d897d439f480209b47a649c771:
Attachment "atrace.tcl" to
ticket [bb6108bb67]
added by
aspect
2015-10-04 23:58:19.
(unpublished)
package require tcltest
namespace import tcltest::*
test array-trace-mod-1 "array read trace order with modify in trace" -body {
unset -nocomplain y
set y(foo) 1
trace add variable y read {apply {{args} {
variable y
puts "In trace2 [list $args]: $y(foo)"; puts [array get y] ; puts "End trace2"
}}}
trace add variable y read {apply {{args} {
variable y
puts "In trace1 [list $args]: $y(foo)"; set y(foo) 2; puts "End trace1"
}}}
puts "y = [array get y]"
} -output "In trace1 {y foo read}: 1
End trace1
In trace2 {y foo read}: 2
foo 2
End trace2
y = foo 2
"
test array-trace-mod-2 "array read trace order with modify in trace" -body {
unset -nocomplain y
set y(foo) 1
trace add variable y read {apply {{args} {
variable y
puts "In trace2 [list $args]: $y(foo)"; puts [array get y] ; puts "End trace2"
}}}
trace add variable y read {apply {{args} {
variable y
puts "In trace1 [list $args]: $y(foo)"; set y(bar) 2; puts "End trace1"
}}}
puts "y = [array get y]"
} -output "In trace1 {y foo read}: 1
End trace1
In trace2 {y foo read}: 2
foo 2
End trace2
y = foo 1 bar 2
"