📄 set-old.test
字号:
list [lsort [array names a *xy]] [lsort [array names a]]} {{axy bxy} {axy bxy no xxx}}test set-old-8.27 {array command, names option, array doesn't exist yet but has compiler-allocated procedure slot} { proc foo {x} { if {$x==1} { return [array names a] } set a(x) 123 } list [catch {foo 1} msg] $msg} {0 {}}test set-old-8.28 {array command, nextelement option} { list [catch {array nextelement a} msg] $msg} {1 {wrong # args: should be "array nextelement arrayName searchId"}}test set-old-8.29 {array command, nextelement option} { catch {unset a} list [catch {array nextelement a b} msg] $msg} {1 {"a" isn't an array}}test set-old-8.30 {array command, nextelement option, array doesn't exist yet but has compiler-allocated procedure slot} { proc foo {x} { if {$x==1} { return [array nextelement a b] } set a(x) 123 } list [catch {foo 1} msg] $msg} {1 {"a" isn't an array}}test set-old-8.31 {array command, set option} { list [catch {array set a} msg] $msg} {1 {wrong # args: should be "array set arrayName list"}}test set-old-8.32 {array command, set option} { list [catch {array set a 1 2} msg] $msg} {1 {wrong # args: should be "array set arrayName list"}}test set-old-8.33 {array command, set option} { list [catch {array set a "a \{ c"} msg] $msg} {1 {unmatched open brace in list}}test set-old-8.34 {array command, set option} { catch {unset a} set a 44 list [catch {array set a {a b c d}} msg] $msg} {1 {can't set "a(a)": variable isn't array}}test set-old-8.35 {array command, set option} { catch {unset a} set a(xx) yy array set a {b c d e} lsort [array get a]} {b c d e xx yy}test set-old-8.36 {array command, set option, array doesn't exist yet but has compiler-allocated procedure slot} { proc foo {x} { if {$x==1} { return [array set a {x 0}] } set a(x) } list [catch {foo 1} msg] $msg} {0 {}}test set-old-8.37 {array command, set option} { catch {unset aVaRnAmE} array set aVaRnAmE {} list [info exists aVaRnAmE] [catch {set aVaRnAmE} msg] $msg} {1 1 {can't read "aVaRnAmE": variable is array}}test set-old-8.37.1 {array command, set scalar} { catch {unset aVaRnAmE} set aVaRnAmE 1 list [catch {array set aVaRnAmE {}} msg] $msg} {1 {can't array set "aVaRnAmE": variable isn't array}}test set-old-8.37.2 {array command, set alias} { catch {unset aVaRnAmE} upvar 0 aVaRnAmE anAliAs array set anAliAs {} list [array exists aVaRnAmE] [catch {set anAliAs} msg] $msg} {1 1 {can't read "anAliAs": variable is array}}test set-old-8.37.3 {array command, set element alias} { catch {unset aVaRnAmE} list [catch {upvar 0 aVaRnAmE(elem) elemAliAs}] \ [catch {array set elemAliAs {}} msg] $msg} {0 1 {can't array set "elemAliAs": variable isn't array}}test set-old-8.37.4 {array command, empty set with populated array} { catch {unset aVaRnAmE} array set aVaRnAmE [list e1 v1 e2 v2] array set aVaRnAmE {} array set aVaRnAmE [list e3 v3] list [lsort [array names aVaRnAmE]] [catch {set aVaRnAmE(e2)} msg] $msg} {{e1 e2 e3} 0 v2}test set-old-8.37.5 {array command, set with non-existent namespace} { list [catch {array set bogusnamespace::var {}} msg] $msg} {1 {can't set "bogusnamespace::var": parent namespace doesn't exist}}test set-old-8.37.6 {array command, set with non-existent namespace} { list [catch {array set bogusnamespace::var {a b}} msg] $msg} {1 {can't set "bogusnamespace::var": parent namespace doesn't exist}}test set-old-8.37.7 {array command, set with non-existent namespace} { list [catch {array set bogusnamespace::var(0) {a b}} msg] $msg} {1 {can't set "bogusnamespace::var(0)": variable isn't array}}test set-old-8.38 {array command, size option} { catch {unset a} array size a} {0}test set-old-8.39 {array command, size option} { list [catch {array size a 4} msg] $msg} {1 {wrong # args: should be "array size arrayName"}}test set-old-8.40 {array command, size option} { catch {unset a} array size a} {0}test set-old-8.41 {array command, size option} { catch {unset a} set a(22) 3; set a(Textual_name) 44; set "a(name with spaces)" xxx list [catch {array size a} msg] $msg} {0 3}test set-old-8.42 {array command, size option} { catch {unset a} set a(22) 3; set a(xx) 44; set a(y) xxx unset a(22) a(y) a(xx) list [catch {array size a} msg] $msg} {0 0}test set-old-8.43 {array command, size option} { catch {unset a} set a(22) 3; trace var a(33) rwu ignore list [catch {array size a} msg] $msg} {0 1}test set-old-8.44 {array command, size option, array doesn't exist yet but has compiler-allocated procedure slot} { proc foo {x} { if {$x==1} { return [array size a] } set a(x) 123 } list [catch {foo 1} msg] $msg} {0 0}test set-old-8.45 {array command, startsearch option} { list [catch {array startsearch a b} msg] $msg} {1 {wrong # args: should be "array startsearch arrayName"}}test set-old-8.46 {array command, startsearch option} { catch {unset a} list [catch {array startsearch a} msg] $msg} {1 {"a" isn't an array}}test set-old-8.47 {array command, startsearch option, array doesn't exist yet but has compiler-allocated procedure slot} { catch {rename p ""} proc p {x} { if {$x==1} { return [array startsearch a] } set a(x) 123 } list [catch {p 1} msg] $msg} {1 {"a" isn't an array}}test set-old-8.48 {array command, statistics option} { catch {unset a} set a(abc) 1 set a(def) 2 set a(ghi) 3 set a(jkl) 4 set a(mno) 5 set a(pqr) 6 set a(stu) 7 set a(vwx) 8 set a(yz) 9 array statistics a} "9 entries in table, 4 bucketsnumber of buckets with 0 entries: 0number of buckets with 1 entries: 0number of buckets with 2 entries: 3number of buckets with 3 entries: 1number of buckets with 4 entries: 0number of buckets with 5 entries: 0number of buckets with 6 entries: 0number of buckets with 7 entries: 0number of buckets with 8 entries: 0number of buckets with 9 entries: 0number of buckets with 10 or more entries: 0average search distance for entry: 1.7"test set-old-8.49 {array command, array names -exact on glob pattern} { catch {unset a} set a(1*2) 1 list [catch {array names a -exact 1*2} msg] $msg} {0 1*2}test set-old-8.48 {array command, array names -glob on glob pattern} { catch {unset a} set a(1*2) 1 set a(12) 1 set a(11) 1 list [catch {lsort [array names a -glob 1*2]} msg] $msg} {0 {1*2 12}}test set-old-8.49 {array command, array names -regexp on regexp pattern} { catch {unset a} set a(1*2) 1 set a(12) 1 set a(11) 1 list [catch {lsort [array names a -regexp ^1]} msg] $msg} {0 {1*2 11 12}}test set-old-8.50 {array command, array names -regexp} { catch {unset a} set a(-glob) 1 set a(-regexp) 1 set a(-exact) 1 list [catch {array names a -regexp} msg] $msg} {0 -regexp}test set-old-8.51 {array command, array names -exact} { catch {unset a} set a(-glob) 1 set a(-regexp) 1 set a(-exact) 1 list [catch {array names a -exact} msg] $msg} {0 -exact}test set-old-8.52 {array command, array names -glob} { catch {unset a} set a(-glob) 1 set a(-regexp) 1 set a(-exact) 1 list [catch {array names a -glob} msg] $msg} {0 -glob}test set-old-8.53 {array command, array statistics on a non-array} { catch {unset a} list [catch {array statistics a} msg] $msg} [list 1 "\"a\" isn't an array"]test set-old-9.1 {ids for array enumeration} { catch {unset a} set a(a) 1 list [array star a] [array star a] [array done a s-1-a; array star a] \ [array done a s-2-a; array d a s-3-a; array start a]} {s-1-a s-2-a s-3-a s-1-a}test set-old-9.2 {array enumeration} { catch {unset a} set a(a) 1 set a(b) 1 set a(c) 1 set x [array startsearch a] lsort [list [array nextelement a $x] [array ne a $x] [array next a $x] \ [array next a $x] [array next a $x]]} {{} {} a b c}test set-old-9.3 {array enumeration} { catch {unset a} set a(a) 1 set a(b) 1 set a(c) 1 set x [array startsearch a] set y [array startsearch a] set z [array startsearch a] lsort [list [array nextelement a $x] [array ne a $x] \ [array next a $y] [array next a $z] [array next a $y] \ [array next a $z] [array next a $y] [array next a $z] \ [array next a $y] [array next a $z] [array next a $x] \ [array next a $x]]} {{} {} {} a a a b b b c c c}test set-old-9.4 {array enumeration: stopping searches} { catch {unset a} set a(a) 1 set a(b) 1 set a(c) 1 set x [array startsearch a] set y [array startsearch a] set z [array startsearch a] lsort [list [array next a $x] [array next a $x] [array next a $y] \ [array done a $z; array next a $x] \ [array done a $x; array next a $y] [array next a $y]]} {a a b b c c}test set-old-9.5 {array enumeration: stopping searches} { catch {unset a} set a(a) 1 set x [array startsearch a] array done a $x list [catch {array next a $x} msg] $msg} {1 {couldn't find search "s-1-a"}}test set-old-9.6 {array enumeration: searches automatically stopped} { catch {unset a} set a(a) 1 set x [array startsearch a] set y [array startsearch a] set a(b) 1 list [catch {array next a $x} msg] $msg \ [catch {array next a $y} msg2] $msg2} {1 {couldn't find search "s-1-a"} 1 {couldn't find search "s-2-a"}}test set-old-9.7 {array enumeration: searches automatically stopped} { catch {unset a} set a(a) 1 set x [array startsearch a] set y [array startsearch a] set a(a) 2 list [catch {array next a $x} msg] $msg \ [catch {array next a $y} msg2] $msg2} {0 a 0 a}test set-old-9.8 {array enumeration: searches automatically stopped} { catch {unset a} set a(a) 1 set a(c) 2 set x [array startsearch a] set y [array startsearch a] catch {unset a(c)} list [catch {array next a $x} msg] $msg \ [catch {array next a $y} msg2] $msg2} {1 {couldn't find search "s-1-a"} 1 {couldn't find search "s-2-a"}}test set-old-9.9 {array enumeration: searches automatically stopped} { catch {unset a} set a(a) 1 set x [array startsearch a] set y [array startsearch a] catch {unset a(c)} list [catch {array next a $x} msg] $msg \ [catch {array next a $y} msg2] $msg2} {0 a 0 a}test set-old-9.10 {array enumeration: searches automatically stopped} { catch {unset a} set a(a) 1 set x [array startsearch a] set y [array startsearch a] trace var a(b) r {} list [catch {array next a $x} msg] $msg \ [catch {array next a $y} msg2] $msg2} {1 {couldn't find search "s-1-a"} 1 {couldn't find search "s-2-a"}}test set-old-9.11 {array enumeration: searches automatically stopped} { catch {unset a} set a(a) 1 set x [array startsearch a] set y [array startsearch a] trace var a(a) r {} list [catch {array next a $x} msg] $msg \ [catch {array next a $y} msg2] $msg2} {0 a 0 a}test set-old-9.12 {array enumeration with traced undefined elements} { catch {unset a} set a(a) 1 trace var a(b) r {} set x [array startsearch a] lsort [list [array next a $x] [array next a $x]]} {{} a}test set-old-10.1 {array enumeration errors} { list [catch {array start} msg] $msg} {1 {wrong # args: should be "array option arrayName ?arg ...?"}}test set-old-10.2 {array enumeration errors} { list [catch {array start a b} msg] $msg} {1 {wrong # args: should be "array startsearch arrayName"}}test set-old-10.3 {array enumeration errors} { catch {unset a} list [catch {array start a} msg] $msg} {1 {"a" isn't an array}}test set-old-10.4 {array enumeration errors} { catch {unset a} set a(a) 1 set x [array startsearch a] list [catch {array next a} msg] $msg} {1 {wrong # args: should be "array nextelement arrayName searchId"}}test set-old-10.5 {array enumeration errors} { catch {unset a} set a(a) 1 set x [array startsearch a] list [catch {array next a b c} msg] $msg} {1 {wrong # args: should be "array nextelement arrayName searchId"}}test set-old-10.6 {array enumeration errors} { catch {unset a} set a(a) 1 set x [array startsearch a] list [catch {array next a a-1-a} msg] $msg} {1 {illegal search identifier "a-1-a"}}test set-old-10.7 {array enumeration errors} { catch {unset a} set a(a) 1 set x [array startsearch a] list [catch {array next a sx1-a} msg] $msg} {1 {illegal search identifier "sx1-a"}}test set-old-10.8 {array enumeration errors} { catch {unset a} set a(a) 1 set x [array startsearch a] list [catch {array next a s--a} msg] $msg} {1 {illegal search identifier "s--a"}}test set-old-10.9 {array enumeration errors} { catch {unset a} set a(a) 1 set x [array startsearch a] list [catch {array next a s-1-b} msg] $msg} {1 {search identifier "s-1-b" isn't for variable "a"}}test set-old-10.10 {array enumeration errors} { catch {unset a} set a(a) 1 set x [array startsearch a] list [catch {array next a s-1ba} msg] $msg} {1 {illegal search identifier "s-1ba"}}test set-old-10.11 {array enumeration errors} { catch {unset a} set a(a) 1 set x [array startsearch a] list [catch {array next a s-2-a} msg] $msg} {1 {couldn't find search "s-2-a"}}test set-old-10.12 {array enumeration errors} { list [catch {array done a} msg] $msg} {1 {wrong # args: should be "array donesearch arrayName searchId"}}test set-old-10.13 {array enumeration errors} { list [catch {array done a b c} msg] $msg} {1 {wrong # args: should be "array donesearch arrayName searchId"}}test set-old-10.14 {array enumeration errors} { list [catch {array done a b} msg] $msg} {1 {illegal search identifier "b"}}test set-old-10.15 {array enumeration errors} { list [catch {array anymore a} msg] $msg} {1 {wrong # args: should be "array anymore arrayName searchId"}}test set-old-10.16 {array enumeration errors} { list [catch {array any a b c} msg] $msg} {1 {wrong # args: should be "array anymore arrayName searchId"}}test set-old-10.17 {array enumeration errors} { catch {unset a} set a(0) 44 list [catch {array any a bogus} msg] $msg} {1 {illegal search identifier "bogus"}}# Array enumeration with "anymore" optiontest set-old-11.1 {array anymore option} { catch {unset a} set a(a) 1 set a(b) 2 set a(c) 3 array startsearch a lsort [list [array anymore a s-1-a] [array next a s-1-a] \ [array anymore a s-1-a] [array next a s-1-a] \ [array anymore a s-1-a] [array next a s-1-a] \ [array anymore a s-1-a] [array next a s-1-a]]} {{} 0 1 1 1 a b c}test set-old-11.2 {array anymore option} { catch {unset a} set a(a) 1 set a(b) 2 set a(c) 3 array startsearch a lsort [list [array next a s-1-a] [array next a s-1-a] \ [array anymore a s-1-a] [array next a s-1-a] \ [array next a s-1-a] [array anymore a s-1-a]]} {{} 0 1 a b c}# Special check to see that the value of a variable is handled correctly# if it is returned as the result of a procedure (must not free the variable# string while deleting the call frame). Errors will only be detected if# a memory consistency checker such as Purify is being used.test set-old-12.1 {cleanup on procedure return} { proc foo {} { set x 12345 } foo} 12345test set-old-12.2 {cleanup on procedure return} { proc foo {} { set x(1) 23456 } foo} 23456# Must delete variables when done, since these arrays get used as# scalars by other tests.catch {unset a}catch {unset b}catch {unset c}catch {unset aVaRnAmE}# cleanup::tcltest::cleanupTestsreturn
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -