1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# Commands covered: trace
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands. Sourcing this file into Tcl runs the tests and
# generates output for errors. No output means no errors were found.
#
# Copyright (c) 1991-1993 The Regents of the University of California.
# Copyright (c) 1994 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# 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 $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
namespace import -force ::tcltest::*
}
proc traceScalar {name1 name2 op} {
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# Commands covered: trace
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands. Sourcing this file into Tcl runs the tests and
# generates output for errors. No output means no errors were found.
#
# Copyright (c) 1991-1993 The Regents of the University of California.
# Copyright (c) 1994 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# 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.9 2000/08/25 20:39:32 ericm Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
namespace import -force ::tcltest::*
}
proc traceScalar {name1 name2 op} {
|
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
|
unset x
set info
} {x {} unset}
# Array tracing on variables
test trace-5.1 {array traces fire on accesses via [array]} {
catch {unset x}
trace add variable x array traceArray2
set ::info {}
array set x {a 1}
set info
} {x {} array}
test trace-5.2 {array traces do not fire on normal accesses} {
catch {unset x}
trace add variable x array traceArray2
set ::info {}
set x(a) 1
set x(b) $x(a)
set info
} {}
test trace-5.3 {array traces 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
} {}
test trace-5.4 {array traces properly listed in trace information} {
catch {unset x}
trace add variable x array traceArray2
trace list variable x
} [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
} [list [list a traceArray2]]
# Trace multiple trace types at once.
test trace-5.1 {multiple ops traced at once} {
catch {unset x}
set info {}
trace add variable x {read write unset} traceProc
catch {set x}
|
>
|
>
|
|
|
|
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
|
unset x
set info
} {x {} unset}
# 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
} {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
} {}
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
} {}
test trace-5.4 {array traces properly listed in trace information} {
catch {unset x}
trace add variable x array traceArray2
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
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} {
catch {unset x}
set info {}
trace add variable x {read write unset} traceProc
catch {set x}
|