3 # Copyright (C) 2004-2007, The Perl Foundation.
6 # the following lines re-execute this as a tcl script
7 # the \ at the end of these lines makes them a comment in tcl \
8 use lib qw(languages/tcl/lib tcl/lib lib ../lib ../../lib); # \
12 source lib/test_more.tcl
19 } {foo whee bar} {middle of ""}
25 } {whee bar} {beginning of ""}
31 } {bar whee} {end of ""}
43 } whee {array, entire word}
49 } {can't read "a(b)": variable isn't array} {try to use scalar as array}
55 } {can't read "a": variable is array} {try to use array as scalar}
61 } 44 {${} substitute an array item}
67 } foo {explicit global}
70 namespace eval lib { variable version 0.1 }
72 } 0.1 {absolute namespace var}
78 } foo {write to explicit global}
81 namespace eval lib { variable version }
82 set ::lib::version 0.1
84 } 0.1 {write to absolute namespace var}
88 array set array {test ok}
91 } ok {variable index into array}
96 } {can't read "bar": no such variable} {invalid variable as key}
102 } ok {single $ as index}
108 set b $foo([set key])
109 } ok {use ) as a key}
114 array set array {a 1 b 2 c 3}
116 set b $array([set foo)
117 } {missing close-bracket} {missing ] in subcommand as key}
122 array set array {a 1 b 2 c 3}
124 set b $array([set foo]a)
125 } {can't read "array(ba)": no such element in array} {invalid key}
129 array set array {a 1 b 2 c 3}
131 set b $array([set )])
132 } 2 {use literal ) inside the array key}
136 namespace eval foo { proc bar {} { return ok } }
139 } ok {namespace variable with escaped colon}
146 namespace eval test {
147 is [set foo::y] 7 {foo::y relative}
148 is [set x] 5 {x relative}