aboutsummaryrefslogtreecommitdiff
path: root/tests/type/map/testscript
blob: 7b90ddd613735ea4b9006e3c08b74755476a25f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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