OSDN Git Service

Updated to tcl 8.4.1
[pf3gnuchains/sourceware.git] / tcl / tests / var.test
index 0529b09..af09c0b 100644 (file)
@@ -18,7 +18,7 @@
 #
 
 if {[lsearch [namespace children] ::tcltest] == -1} {
-    package require tcltest
+    package require tcltest 2.2
     namespace import -force ::tcltest::*
 }
 
@@ -173,6 +173,9 @@ test var-1.18 {TclLookupVar, resurrect array element via upvar to deleted array:
        set result
     }
 } {0 2 1 {can't set "foo": upvar refers to element in deleted array}}
+test var-1.19 {TclLookupVar, right error message when parsing variable name} {
+    list [catch {[format set] thisvar(doesntexist)} msg] $msg
+} {1 {can't read "thisvar(doesntexist)": no such variable}}
 
 test var-2.1 {Tcl_LappendObjCmd, create var if new} {
     catch {unset x}
@@ -258,7 +261,7 @@ test var-3.9 {MakeUpvar, my var has invalid ns name} {
     catch {unset aaaaa}
     set aaaaa 789789
     list [catch {upvar #0 aaaaa test_ns_fred::lnk} msg] $msg
-} {1 {bad variable name "test_ns_fred::lnk": unknown namespace}}
+} {1 {can't create "test_ns_fred::lnk": parent namespace doesn't exist}}
 
 if {[info commands testgetvarfullname] != {}} {
     test var-4.1 {Tcl_GetVariableName, global variable} {
@@ -324,6 +327,16 @@ test var-6.3 {Tcl_GlobalObjCmd, variable named {} qualified by a namespace name}
     }
     p
 } {24}
+test var-6.4 {Tcl_GlobalObjCmd, variable name matching :*} {
+    # Test for Tcl Bug 480176
+    set :v broken
+    proc p {} {
+       global :v
+       set :v fixed
+    }
+    p
+    set :v
+} {fixed}
 
 test var-7.1 {Tcl_VariableObjCmd, create and initialize one new ns variable} {
     catch {namespace delete test_ns_var}
@@ -473,6 +486,14 @@ test var-7.15 {Tcl_VariableObjCmd, array element parameter} {
     } res
     set res
 } "can't define \"arrayvar(1)\": name refers to an element in an array"
+test var-7.16 {Tcl_VariableObjCmd, no args} {
+    list [catch {variable} msg] $msg
+} {1 {wrong # args: should be "variable ?name value...? name ?value?"}}
+test var-7.17 {Tcl_VariableObjCmd, no args} {
+    namespace eval test_ns_var {
+       list [catch {variable} msg] $msg
+    }
+} {1 {wrong # args: should be "variable ?name value...? name ?value?"}}
 
 test var-8.1 {TclDeleteVars, "unset" traces are called with fully-qualified var names} {
     catch {namespace delete test_ns_var}
@@ -645,6 +666,10 @@ test var-13.1 {Tcl_UnsetVar2, unset array with trace set on element} {
     set x "If you see this, it worked"
 } "If you see this, it worked"
 
+test var-14.1 {array names syntax} -body {
+    array names foo bar baz snafu
+} -returnCodes 1 -match glob -result *
+
 catch {namespace delete ns}
 catch {unset arr}
 catch {unset v}
@@ -663,4 +688,3 @@ catch {unset aaaaa}
 # cleanup
 ::tcltest::cleanupTests
 return
-