diff options
author | Steve Bennett <steveb@workware.net.au> | 2011-11-11 16:03:40 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2011-11-18 07:59:19 +1000 |
commit | c7f5c1516468bc44bd61e556adebbdf4e5f39e13 (patch) | |
tree | be02e2aac6bbf9d7ce07eaba467c629698bc5a8f /tests | |
parent | f41fd056f21b4f39f946a914ae71994525026029 (diff) | |
download | jimtcl-c7f5c1516468bc44bd61e556adebbdf4e5f39e13.zip jimtcl-c7f5c1516468bc44bd61e556adebbdf4e5f39e13.tar.gz jimtcl-c7f5c1516468bc44bd61e556adebbdf4e5f39e13.tar.bz2 |
Improvements to variable caching and resolution
Cache the correct callframe id for ::global vars
Move variable creation out into JimCreateVariable()
Fix some cases of upvar/global with ::global vars
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/upvar.test | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/upvar.test b/tests/upvar.test index 91594b0..4b919a2 100644 --- a/tests/upvar.test +++ b/tests/upvar.test @@ -300,6 +300,10 @@ test upvar-8.10 {upvar will create element alias for new array element} { array set upvarArray {} catch {upvar 0 upvarArray(elem) upvarArrayElemAlias} } {0} +test upvar-8.11 {error upvar array element} { + proc a {} { upvar a b(1) } + list [catch {a} msg] $msg +} {1 {bad variable name "b(1)": upvar won't create a scalar variable that looks like an array element}} test upvar-9.1 {global redefine} { proc p1 {} { global x; global x } p1 @@ -319,6 +323,22 @@ test upvar-9.4 {upvar links to static} jim { proc p2 {} {{a 3}} { list [p1] $a } p2 } {4 4} +test upvar-9.5 {upvar via global namespace} { + set x 2 + unset -nocomplain y + # Links ::y to ::x + proc p1 {} { upvar x ::y; incr ::y -1 } + p1 + list $x $y +} {1 1} + +test upvar-9.6 {upvar via global namespace} { + set x 2 + unset -nocomplain x + # Links ::x to ::x + proc p1 {} { upvar x ::x; incr ::x } + list [catch p1 msg] $msg +} {1 {can't upvar from variable to itself}} catch {unset a} |