diff options
author | andreas_kupries <akupries@shaw.ca> | 2010-09-01 20:35:32 (GMT) |
---|---|---|
committer | andreas_kupries <akupries@shaw.ca> | 2010-09-01 20:35:32 (GMT) |
commit | 9cfbf9b3c024db75159b03c1eb94a0bf0b9bfb10 (patch) | |
tree | 6e87bc05f40a7a62222bac4871c8f6ec5cc1d675 /tests/appendComp.test | |
parent | 95a09f18c6704c0f2dcd4f62122f1cadfe828988 (diff) | |
download | tcl-9cfbf9b3c024db75159b03c1eb94a0bf0b9bfb10.zip tcl-9cfbf9b3c024db75159b03c1eb94a0bf0b9bfb10.tar.gz tcl-9cfbf9b3c024db75159b03c1eb94a0bf0b9bfb10.tar.bz2 |
* generic/tclExecute.c: [Bug 3057639]. Applied patch by Jeff to
* generic/tclVar.c: make the behaviour of lappend in bytecompiled
* tests/append.test: mode consistent with direct-eval and 'append'
* tests/appendComp.test: generally. Added tests (append*-9.*)
showing the difference.
Diffstat (limited to 'tests/appendComp.test')
-rw-r--r-- | tests/appendComp.test | 81 |
1 files changed, 75 insertions, 6 deletions
diff --git a/tests/appendComp.test b/tests/appendComp.test index 90b2af5..9523d2d 100644 --- a/tests/appendComp.test +++ b/tests/appendComp.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: appendComp.test,v 1.12 2008/10/14 18:49:47 dgp Exp $ +# RCS: @(#) $Id: appendComp.test,v 1.13 2010/09/01 20:35:33 andreas_kupries Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -268,7 +268,7 @@ test appendComp-7.2 {lappend var triggers read trace, index var} -setup { return $::result } bar -} -result {myvar {} r} +} -result {myvar {} r} -constraints {bug-3057639} test appendComp-7.3 {lappend var triggers read trace, stack var} -setup { unset -nocomplain ::result unset -nocomplain ::myvar @@ -280,7 +280,7 @@ test appendComp-7.3 {lappend var triggers read trace, stack var} -setup { return $::result } bar -} -result {::myvar {} r} +} -result {::myvar {} r} -constraints {bug-3057639} test appendComp-7.4 {lappend var triggers read trace, array var} -setup { catch {unset ::result} } -body { @@ -293,7 +293,7 @@ test appendComp-7.4 {lappend var triggers read trace, array var} -setup { return $::result } bar -} -result {myvar b r} +} -result {myvar b r} -constraints {bug-3057639} test appendComp-7.5 {lappend var triggers read trace, array var} -setup { catch {unset ::result} } -body { @@ -318,7 +318,7 @@ test appendComp-7.6 {lappend var triggers read trace, array var exists} -setup { return $::result } bar -} -result {myvar b r} +} -result {myvar b r} -constraints {bug-3057639} test appendComp-7.7 {lappend var triggers read trace, array stack var} -setup { catch {unset ::myvar} catch {unset ::result} @@ -330,7 +330,7 @@ test appendComp-7.7 {lappend var triggers read trace, array stack var} -setup { return $::result } bar -} -result {::myvar b r} +} -result {::myvar b r} -constraints {bug-3057639} test appendComp-7.8 {lappend var triggers read trace, array stack var} -setup { catch {unset ::myvar} catch {unset ::result} @@ -369,6 +369,75 @@ test appendComp-8.1 {defer error to runtime} -setup { interp delete slave } -result {} + +# New tests for bug 3057639 to show off the more consistent behaviour +# of lappend in both direct-eval and bytecompiled code paths (see +# append.test for the direct-eval variants). lappend now behaves like +# append. 9.0/1 lappend - 9.2/3 append. + +# Note also the tests above now constrained by bug-3057639, these +# changed behaviour with the triggering of read traces in bc mode +# gone. + +# Going back to the tests below. The direct-eval tests are ok before +# and after patch (no read traces run for lappend, append). The +# compiled tests are failing for lappend (9.0/1) before the patch, +# showing how it invokes read traces in the compiled path. The append +# tests are good (9.2/3). After the patch the failues are gone. + +test appendComp-9.0 {bug 3057639, lappend compiled, read trace on non-existing array variable element} { + catch {unset myvar} + array set myvar {} + proc nonull {var key val} { + upvar 1 $var lvar + if {![info exists lvar($key)]} { + return -code error "BOOM. no such variable" + } + } + trace add variable myvar read nonull + proc foo {} { + lappend ::myvar(key) "new value" + } + list [catch { foo } msg] $msg +} {0 {{new value}}} + + +test appendComp-9.1 {bug 3057639, lappend direct eval, read trace on non-existing env element} { + catch {unset ::env(__DUMMY__)} + proc foo {} { + lappend ::env(__DUMMY__) "new value" + } + list [catch { foo } msg] $msg +} {0 {{new value}}} + + + +test appendComp-9.2 {bug 3057639, append compiled, read trace on non-existing array variable element} { + catch {unset myvar} + array set myvar {} + proc nonull {var key val} { + upvar 1 $var lvar + if {![info exists lvar($key)]} { + return -code error "BOOM. no such variable" + } + } + trace add variable myvar read nonull + proc foo {} { + append ::myvar(key) "new value" + } + list [catch { foo } msg] $msg +} {0 {new value}} + + +test appendComp-9.3 {bug 3057639, append direct eval, read trace on non-existing env element} { + catch {unset ::env(__DUMMY__)} + proc foo {} { + append ::env(__DUMMY__) "new value" + } + list [catch { foo } msg] $msg +} {0 {new value}} + + catch {unset i x result y} catch {rename foo ""} catch {rename bar ""} |