diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/function/string/testscript | 10 | ||||
-rw-r--r-- | tests/type/map/buildfile | 4 | ||||
-rw-r--r-- | tests/type/map/testscript | 65 |
3 files changed, 77 insertions, 2 deletions
diff --git a/tests/function/string/testscript b/tests/function/string/testscript index 364ce42..a363cc3 100644 --- a/tests/function/string/testscript +++ b/tests/function/string/testscript @@ -43,8 +43,10 @@ : size : { - $* <'print $size([string] abc)' >'3' : basics - $* <'print $size([string] )' >'0' : zero + $* <'print $size([string] abc)' >'3' : basics + $* <'print $size([string] )' >'0' : zero + $* <'print $size([strings] a b c)' >'3' : strings + $* <'print $size([string_map] a@1 b@2 c@3)' >'3' : string_map } : find @@ -62,3 +64,7 @@ $* <'print $find_index([strings] x y z, Y)' >'3' : basics-false $* <'print $find_index([strings] x y z, Y, icase)' >'1' : icase } + +: keys +: +$* <'print $keys([string_map] a@1 b@2 c@3)' >'a b c' diff --git a/tests/type/map/buildfile b/tests/type/map/buildfile new file mode 100644 index 0000000..7f2cdcf --- /dev/null +++ b/tests/type/map/buildfile @@ -0,0 +1,4 @@ +# file : tests/type/map/buildfile +# license : MIT; see accompanying LICENSE file + +./: testscript $b diff --git a/tests/type/map/testscript b/tests/type/map/testscript new file mode 100644 index 0000000..7b90ddd --- /dev/null +++ b/tests/type/map/testscript @@ -0,0 +1,65 @@ +# file : tests/type/map/testscript +# license : MIT; see accompanying LICENSE file + +# See also tests in function/*/ (size(), keys()). + +.include ../../common.testscript + +: basics +: +$* <<EOI >>EOO +m = [string_map] a@0 b@2 a@1 +print $m +m += c@3 b@0 +print $m +m =+ d@4 b@1 +print $m +EOI +a@1 b@2 +a@1 b@0 c@3 +a@1 b@0 c@3 d@4 +EOO + +: type +: +$* <<EOI >>EOO +m = [string_map] +print $type($m) +EOI +string_map +EOO + +: subscript +: +$* <<EOI >>EOO +m = [string_map] a@1 b@2 c@3 +print ($m[b]) +print ($m[z]) +EOI +2 +[null] +EOO + +: iteration +: +$* <<EOI >>EOO +for p: [string_map] a@1 b@2 c@3 + print $first($p) $second($p) +EOI +a 1 +b 2 +c 3 +EOO + +: iteration-index +: +$* <<EOI >>EOO +m = [string_map] a@1 b@2 c@3 +k = $keys($m) +for i: $integer_sequence(0, $size($k)) + print $i ($k[$i]) ($m[($k[$i])]) # @@ TMP: nested subscript +EOI +0 a 1 +1 b 2 +2 c 3 +EOO |