diff options
author | ericm <ericm> | 2000-08-25 20:39:31 (GMT) |
---|---|---|
committer | ericm <ericm> | 2000-08-25 20:39:31 (GMT) |
commit | f97152e392c85c9bd4b78be2bb666328b7044928 (patch) | |
tree | c69a36203d04a0e5c5ed4330b83a25a757695724 /tests | |
parent | da5194713b3c8a85943b8b731534a32a398981a9 (diff) | |
download | tcl-f97152e392c85c9bd4b78be2bb666328b7044928.zip tcl-f97152e392c85c9bd4b78be2bb666328b7044928.tar.gz tcl-f97152e392c85c9bd4b78be2bb666328b7044928.tar.bz2 |
* tests/trace.test: Extended array tracing tests.
* doc/trace.n: Clarified information about when array traces will
be fired.
* generic/tclVar.c (Tcl_ArrayObjCmd): Corrected call to CallTraces
(for TCL_TRACE_ARRAY) to only be called when the variable is
either an array or is undefined, to ensure that array traces do
not fire for scalar variables.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/trace.test | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/tests/trace.test b/tests/trace.test index 11da1a9..66ec08f 100644 --- a/tests/trace.test +++ b/tests/trace.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: trace.test,v 1.8 2000/08/25 02:04:29 ericm Exp $ +# RCS: @(#) $Id: trace.test,v 1.9 2000/08/25 20:39:32 ericm Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -285,39 +285,58 @@ test trace-4.9 {trace unsets on whole arrays} { # Array tracing on variables test trace-5.1 {array traces fire on accesses via [array]} { catch {unset x} + set x(b) 2 trace add variable x array traceArray2 set ::info {} array set x {a 1} - set info + set ::info } {x {} array} test trace-5.2 {array traces do not fire on normal accesses} { catch {unset x} + set x(b) 2 trace add variable x array traceArray2 set ::info {} set x(a) 1 set x(b) $x(a) - set info + set ::info } {} -test trace-5.3 {array traces outlive variable} { +test trace-5.3 {array traces do not outlive variable} { catch {unset x} trace add variable x array traceArray2 set ::info {} set x(a) 1 unset x array set x {a 1} - set info + set ::info } {} test trace-5.4 {array traces properly listed in trace information} { catch {unset x} trace add variable x array traceArray2 - trace list variable x + set result [trace list variable x] + set result } [list [list array traceArray2]] test trace-5.5 {array traces properly listed in trace information} { catch {unset x} trace variable x a traceArray2 - trace vinfo x + set result [trace vinfo x] + set result } [list [list a traceArray2]] - +test trace-5.6 {array traces don't fire on scalar variables} { + catch {unset x} + set x foo + trace add variable x array traceArray2 + set ::info {} + catch {array set x {a 1}} + set ::info +} {} +test trace-5.7 {array traces fire for undefined variables} { + catch {unset x} + trace add variable x array traceArray2 + set ::info {} + array set x {a 1} + set ::info +} {x {} array} + # Trace multiple trace types at once. test trace-5.1 {multiple ops traced at once} { |