diff options
Diffstat (limited to 'tests/set.test')
-rw-r--r-- | tests/set.test | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/tests/set.test b/tests/set.test index ce1d31a..18119f5 100644 --- a/tests/set.test +++ b/tests/set.test @@ -9,14 +9,17 @@ # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. -# -# RCS: @(#) $Id: set.test,v 1.9 2004/11/03 17:16:05 dgp Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 namespace import -force ::tcltest::* } +::tcltest::loadTestedCommands +catch [list package require -exact Tcltest [info patchlevel]] + +testConstraint testset2 [llength [info commands testset2]] + catch {unset x} catch {unset i} @@ -190,9 +193,9 @@ test set-1.22 {TclCompileSetCmd: doing assignment, large int} { } 200000 test set-1.23 {TclCompileSetCmd: doing assignment, formatted int != int} { set i 25 - set i 000012345 ;# an octal literal == 5349 decimal + set i 0o00012345 ;# an octal literal == 5349 decimal list $i [incr i] -} {000012345 5350} +} {0o00012345 5350} test set-1.24 {TclCompileSetCmd: too many arguments} { set i 10 @@ -233,7 +236,8 @@ test set-1.26 {TclCompileSetCmd: various array constructs} { {b c} foo 51}]; # " just a matching end quote test set-2.1 {set command: runtime error, bad variable name} { - list [catch {set {"foo}} msg] $msg $errorInfo + unset -nocomplain {"foo} + list [catch {set {"foo}} msg] $msg $::errorInfo } {1 {can't read ""foo": no such variable} {can't read ""foo": no such variable while executing "set {"foo}"}} @@ -251,7 +255,7 @@ test set-2.4 {set command: runtime error, readonly variable} -body { proc readonly args {error "variable is read-only"} set x 123 trace var x w readonly - list [catch {set x 1} msg] $msg $errorInfo + list [catch {set x 1} msg] $msg $::errorInfo } -match glob -result {1 {can't set "x": variable is read-only} {*variable is read-only while executing * @@ -464,9 +468,9 @@ test set-3.22 {uncompiled set command: doing assignment, large int} { test set-3.23 {uncompiled set command: doing assignment, formatted int != int} { set z set $z i 25 - $z i 000012345 ;# an octal literal == 5349 decimal + $z i 0o00012345 ;# an octal literal == 5349 decimal list $i [incr i] -} {000012345 5350} +} {0o00012345 5350} test set-3.24 {uncompiled set command: too many arguments} { set z set @@ -476,8 +480,9 @@ test set-3.24 {uncompiled set command: too many arguments} { } {wrong # args: should be "set varName ?newValue?"} test set-4.1 {uncompiled set command: runtime error, bad variable name} { + unset -nocomplain {"foo} set z set - list [catch {$z {"foo}} msg] $msg $errorInfo + list [catch {$z {"foo}} msg] $msg $::errorInfo } {1 {can't read ""foo": no such variable} {can't read ""foo": no such variable while executing "$z {"foo}"}} @@ -498,7 +503,7 @@ test set-4.4 {uncompiled set command: runtime error, readonly variable} -body { proc readonly args {error "variable is read-only"} $z x 123 trace var x w readonly - list [catch {$z x 1} msg] $msg $errorInfo + list [catch {$z x 1} msg] $msg $::errorInfo } -match glob -result {1 {can't set "x": variable is read-only} {*variable is read-only while executing * @@ -512,6 +517,18 @@ test set-4.6 {set command: runtime error, basic array operations} { list [catch {$z a} msg] $msg } {1 {can't read "a": variable is array}} +test set-5.1 {error on malformed array name} testset2 { + unset -nocomplain z + catch {testset2 z(a) b} msg + catch {testset2 z(b) a} msg1 + list $msg $msg1 +} {{can't read "z(a)(b)": variable isn't array} {can't read "z(b)(a)": variable isn't array}} + +# In a mem-debug build, this test will crash unless Bug 3602706 is fixed. +test set-5.2 {Bug 3602706} -body { + testset2 ::tcl_platform not-in-there +} -returnCodes error -result * -match glob + # cleanup catch {unset a} catch {unset b} |