1 source [file dirname [info script]]/testing.tcl
13 test array-1.1 "array exists - true" {
17 test array-1.2 "array exists - false" {
21 test array-1.3 "array size" {
25 test array-1.4 "array size - nonexistant" {
29 test array-1.5 "array get" {
31 foreach {name value} [array get a] {
32 lappend result $name $value
35 } {1 2 22 3 one three {twenty two} two}
37 test array-1.6 "array get - pattern" {
39 foreach {name value} [array get a 2*] {
40 lappend result $name $value
43 } {2 22 {twenty two} two}
45 test array-1.7 "array names" {
49 test array-1.8 "array get - pattern" {
50 lsort [array names a 2*]
54 array set b [array get a]
56 test array-1.9 "array set - replace" {
57 array set b {22 twenty-two}
61 test array-1.10 "array unset - pattern" {
66 test array-1.11 "array unset - all" {
68 list [array size b] [array exists b]
71 test array-1.12 "array set to invalid variable" -body {
75 } -returnCodes error -result {can't set "a(1)": variable isn't array}
77 test array-1.13 "unset missing array element" -body {
81 } -returnCodes error -result {can't unset "a(2)": no such element in array}
83 test array-1.14 "access array via unset var" -body {
86 } -returnCodes error -result {can't read "b": no such variable}