diff options
| author | andy <andrew.m.goth@gmail.com> | 2016-12-10 21:11:52 (GMT) |
|---|---|---|
| committer | andy <andrew.m.goth@gmail.com> | 2016-12-10 21:11:52 (GMT) |
| commit | bdf46a65d175b2e13c4862ec2b58aa22fddbcd4e (patch) | |
| tree | cfc87af1469b14e4ac1782da2b7e16553ae0088a | |
| parent | b8dafd94bad10b203f8cca6536d13bc84acce00d (diff) | |
| download | tcl-bdf46a65d175b2e13c4862ec2b58aa22fddbcd4e.zip tcl-bdf46a65d175b2e13c4862ec2b58aa22fddbcd4e.tar.gz tcl-bdf46a65d175b2e13c4862ec2b58aa22fddbcd4e.tar.bz2 | |
Add [array size] tests
| -rw-r--r-- | tests/array.test | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/tests/array.test b/tests/array.test index 3f43926..6555366 100644 --- a/tests/array.test +++ b/tests/array.test @@ -147,13 +147,13 @@ proc test {def} { } # Build variable initialization, linkage, and finalization snippets. - set initial [list namespace eval ::TestVar [join [list\ + set initial [list namespace eval ::TestVars [join [list\ [list variable {*}$scalars]\ {*}[lmap {var val} $arrays {list variable $var}]\ {*}[lmap {var val} $arrays {list array set $var $val}]] \n]] set linkage [join [lmap var [dict get $def link]\ - {list variable ::TestVar::$var}] \n] - set final [list namespace delete ::TestVar] + {list variable ::TestVars::$var}] \n] + set final [list namespace delete ::TestVars] # Update scripts. dict set def setup $initial\n$linkage\n[dict get $def setup] @@ -484,6 +484,42 @@ test { result {{} 6 ( 3 () 5 )( 4 ) 2 { a b } 1} } +# array-4.*: array size. +test { + name array-4.1 + desc {empty array} + {array a} {} + body {array size a} + result 0 +} +test { + name array-4.2 + desc {single-element array} + {array a} {e 1} + body {array size a} + result 1 +} +test { + name array-4.3 + desc {thousand-element array} + body {for {set i 0} {$i < 1000} {incr i} {set a($i) $i}; array size a} + result 1000 +} +test { + name array-4.4 + desc {increasing array size} + {array a} {e 1} + body {list [array size a] [set a(f) {}] [array size a]} + result {1 {} 2} +} +test { + name array-4.5 + desc {decrasing array size} + {array a} {e 1 f 2} + body {list [array size a] [unset a(f)] [array size a]} + result {2 {} 1} +} + # Cleanup. foreach namespace [namespace children] { if {$namespace ni $namespaces} { |
