diff options
author | Evan Hunter <evan@ozhiker.com> | 2016-10-06 22:19:26 +0100 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2016-10-12 09:26:58 +1000 |
commit | 80032e22c35eb24d2df11843a723caa7c7160d29 (patch) | |
tree | f813e53f67fb094ae43b8be64331e9a35ed523a0 /tests/array.test | |
parent | 73176c908b681a9500af84abfa2f7f6234f3f913 (diff) | |
download | jimtcl-80032e22c35eb24d2df11843a723caa7c7160d29.zip jimtcl-80032e22c35eb24d2df11843a723caa7c7160d29.tar.gz jimtcl-80032e22c35eb24d2df11843a723caa7c7160d29.tar.bz2 |
Array fixes and tests
Changed 'array exists' to actually check if the variable is an array
(matches tclsh)
Fix Jim_DictInfo to avoid using printf() and make output match tclsh
Added some more tests for array command - checked these work with tclsh
Diffstat (limited to 'tests/array.test')
-rw-r--r-- | tests/array.test | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/array.test b/tests/array.test index ba88147..423276b 100644 --- a/tests/array.test +++ b/tests/array.test @@ -85,4 +85,50 @@ test array-1.14 "access array via unset var" -body { expr {$a($b) + 4} } -returnCodes error -result {can't read "b": no such variable} +test array-1.15 "array unset non-variable" -body { + array unset nonvariable 4 +} -result {} + +test array-1.16 "array names non-variable" -body { + array names nonvariable +} -result {} + +test array-1.17 "array get non-variable" -body { + array get nonvariable +} -result {} + +# This seems like incorrect behaviour, but it matches tclsh +test array-1.18 "array size non-array" -body { + set x 1 + array size x +} -result {0} + +# This seems like incorrect behaviour, but it matches tclsh +test array-1.19 "array unset non-array" -body { + set x 6 + array unset x 4 +} -result {} + +test array-1.20 "array stat" -body { + set output [array stat a] + regexp "1 entries in table.*number of buckets with 1 entries: 1" $output +} -result {1} + +test array-1.21 "array stat non-array" -body { + array stat badvariable +} -returnCodes error -result {"badvariable" isn't an array} + +test array-1.22 "array set non-even args" -body { + array set x { + 1 one + 2 two + 3 +} +} -returnCodes error -result {list must have an even number of elements} + +test array-1.23 "array exists non-array" -body { + set x 4 + array exists x +} -result {0} + testreport |