diff options
author | hobbs <hobbs@noemail.net> | 2001-07-03 23:39:23 (GMT) |
---|---|---|
committer | hobbs <hobbs@noemail.net> | 2001-07-03 23:39:23 (GMT) |
commit | 5d12178bd52ae26fd29b3619776baac3f35a3f98 (patch) | |
tree | dcaf29b97ef354eaf70143913d3e167f050a83d2 /tests/append.test | |
parent | 0eb4c2284279bf6db514d3bee8b105dd12f72473 (diff) | |
download | tcl-5d12178bd52ae26fd29b3619776baac3f35a3f98.zip tcl-5d12178bd52ae26fd29b3619776baac3f35a3f98.tar.gz tcl-5d12178bd52ae26fd29b3619776baac3f35a3f98.tar.bz2 |
* tests/append.test:
* tests/appendComp.test: added tests for read trace triggering for
append and lappend.
FossilOrigin-Name: 42348667cb98c705f978221e20047292e25d281b
Diffstat (limited to 'tests/append.test')
-rw-r--r-- | tests/append.test | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/tests/append.test b/tests/append.test index a96d977..58c0de7 100644 --- a/tests/append.test +++ b/tests/append.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: append.test,v 1.6 2001/05/17 02:18:53 hobbs Exp $ +# RCS: @(#) $Id: append.test,v 1.7 2001/07/03 23:39:24 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -131,6 +131,18 @@ test append-4.17 {lappend command} { catch {unset x} lappend x } {} +test append-4.18 {lappend command} { + catch {unset x} + lappend x {} +} {{}} +test append-4.19 {lappend command} { + catch {unset x} + lappend x(0) +} {} +test append-4.20 {lappend command} { + catch {unset x} + lappend x(0) abc +} {abc} proc check {var size} { set l [llength $var] @@ -146,6 +158,7 @@ proc check {var size} { return ok } test append-5.1 {long lappends} { + catch {unset x} set x "" for {set i 0} {$i < 300} {set i [expr $i+1]} { lappend x "item $i" @@ -173,6 +186,42 @@ test append-7.1 {lappend-created var and error in trace on that var} { lappend x 1 list [info exists x] [catch {set x} msg] $msg } {0 1 {can't read "x": no such variable}} +test append-7.2 {lappend var triggers read trace} { + catch {unset myvar} + catch {unset ::result} + trace variable myvar r foo + proc foo {args} {append ::result $args} + lappend myvar a + list [catch {set ::result} msg] $msg +} {0 {myvar {} r}} +test append-7.3 {lappend var triggers read trace, array var} { + # The behavior of read triggers on lappend changed in 8.0 to + # not trigger them, and was changed back in 8.4. + catch {unset myvar} + catch {unset ::result} + trace variable myvar r foo + proc foo {args} {append ::result $args} + lappend myvar(b) a + list [catch {set ::result} msg] $msg +} {0 {myvar b r}} +test append-7.4 {lappend var triggers read trace, array var exists} { + catch {unset myvar} + catch {unset ::result} + set myvar(0) 1 + trace variable myvar r foo + proc foo {args} {append ::result $args} + lappend myvar(b) a + list [catch {set ::result} msg] $msg +} {0 {myvar b r}} +test append-7.5 {append var does not trigger read trace} { + catch {unset myvar} + catch {unset ::result} + trace variable myvar r foo + proc foo {args} {append ::result $args} + append myvar a + info exists ::result +} {0} + catch {unset i x result y} catch {rename foo ""} |