aboutsummaryrefslogtreecommitdiff
path: root/tests/type
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-02-20 08:57:32 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-02-20 16:01:40 +0200
commitc2d2a1ac0ac41a068c4bf09f8236a61d576e74f5 (patch)
tree32fe50dc4f95772493f4242ce40fb0afd01c0bb6 /tests/type
parent88640e677fa0695783eac68014d7d8d5bc42d117 (diff)
Add custom subscript, iterate functions for vector and set value types
Diffstat (limited to 'tests/type')
-rw-r--r--tests/type/map/testscript5
-rw-r--r--tests/type/set/testscript11
-rw-r--r--tests/type/vector/buildfile4
-rw-r--r--tests/type/vector/testscript57
4 files changed, 73 insertions, 4 deletions
diff --git a/tests/type/map/testscript b/tests/type/map/testscript
index 7b90ddd..1c6224a 100644
--- a/tests/type/map/testscript
+++ b/tests/type/map/testscript
@@ -34,9 +34,11 @@ EOO
$* <<EOI >>EOO
m = [string_map] a@1 b@2 c@3
print ($m[b])
+print $type($m[b])
print ($m[z])
EOI
2
+string
[null]
EOO
@@ -45,6 +47,9 @@ EOO
$* <<EOI >>EOO
for p: [string_map] a@1 b@2 c@3
print $first($p) $second($p)
+
+for p: [string_map, null]
+ fail bad
EOI
a 1
b 2
diff --git a/tests/type/set/testscript b/tests/type/set/testscript
index 3897220..da5e181 100644
--- a/tests/type/set/testscript
+++ b/tests/type/set/testscript
@@ -44,9 +44,12 @@ EOO
:
$* <<EOI >>EOO
for s: [string_set] a b c
- print $s
+ print $type($s) $s
+
+for s: [string_set, null]
+ fail bad
EOI
-a
-b
-c
+string a
+string b
+string c
EOO
diff --git a/tests/type/vector/buildfile b/tests/type/vector/buildfile
new file mode 100644
index 0000000..5b2aa0e
--- /dev/null
+++ b/tests/type/vector/buildfile
@@ -0,0 +1,4 @@
+# file : tests/type/vector/buildfile
+# license : MIT; see accompanying LICENSE file
+
+./: testscript $b
diff --git a/tests/type/vector/testscript b/tests/type/vector/testscript
new file mode 100644
index 0000000..9b3aaba
--- /dev/null
+++ b/tests/type/vector/testscript
@@ -0,0 +1,57 @@
+# file : tests/type/vector/testscript
+# license : MIT; see accompanying LICENSE file
+
+# See also tests in function/*/ (size(), find(), etc).
+
+.include ../../common.testscript
+
+: basics
+:
+$* <<EOI >>EOO
+v = [strings] b c
+print $v
+v += d
+print $v
+v =+ a
+print $v
+EOI
+b c
+b c d
+a b c d
+EOO
+
+: type
+:
+$* <<EOI >>EOO
+v = [strings]
+print $type($v)
+EOI
+strings
+EOO
+
+: subscript
+:
+$* <<EOI >>EOO
+v = [strings] a b c
+print ($v[1])
+print $type($v[1])
+print ($v[3])
+EOI
+b
+string
+[null]
+EOO
+
+: iteration
+:
+$* <<EOI >>EOO
+for s: [strings] a b c
+ print $type($s) $s
+
+for s: [strings, null]
+ fail bad
+EOI
+string a
+string b
+string c
+EOO