summaryrefslogtreecommitdiffstats
path: root/tests/append.test
diff options
context:
space:
mode:
authorandreas_kupries <akupries@shaw.ca>2010-09-01 20:35:32 (GMT)
committerandreas_kupries <akupries@shaw.ca>2010-09-01 20:35:32 (GMT)
commit9cfbf9b3c024db75159b03c1eb94a0bf0b9bfb10 (patch)
tree6e87bc05f40a7a62222bac4871c8f6ec5cc1d675 /tests/append.test
parent95a09f18c6704c0f2dcd4f62122f1cadfe828988 (diff)
downloadtcl-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/append.test')
-rw-r--r--tests/append.test54
1 files changed, 53 insertions, 1 deletions
diff --git a/tests/append.test b/tests/append.test
index eb76c94..3c000df 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.11 2008/09/08 10:49:04 dkf Exp $
+# RCS: @(#) $Id: append.test,v 1.12 2010/09/01 20:35:33 andreas_kupries Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest 2
@@ -239,6 +239,58 @@ test append-7.5 {append var does not trigger read trace} -setup {
info exists ::result
} -result {0}
+
+
+# New tests for bug 3057639 to show off the more consistent behaviour
+# of lappend in both direct-eval and bytecompiled code paths (see
+# appendComp.test for the compiled variants). lappend now behaves like
+# append. 9.0/1 lappend - 9.2/3 append
+
+test append-9.0 {bug 3057639, lappend direct eval, 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 "no such variable"
+ }
+ }
+ trace add variable myvar read nonull
+ list [catch {
+ lappend myvar(key) "new value"
+ } msg] $msg
+} {0 {{new value}}}
+
+test append-9.1 {bug 3057639, lappend direct eval, read trace on non-existing env element} {
+ catch {unset ::env(__DUMMY__)}
+ list [catch {
+ lappend ::env(__DUMMY__) "new value"
+ } msg] $msg
+} {0 {{new value}}}
+
+test append-9.2 {bug 3057639, append direct eval, 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 "no such variable"
+ }
+ }
+ trace add variable myvar read nonull
+ list [catch {
+ append myvar(key) "new value"
+ } msg] $msg
+} {0 {new value}}
+
+test append-9.3 {bug 3057639, append direct eval, read trace on non-existing env element} {
+ catch {unset ::env(__DUMMY__)}
+ list [catch {
+ append ::env(__DUMMY__) "new value"
+ } msg] $msg
+} {0 {new value}}
+
+
catch {unset i x result y}
catch {rename foo ""}