aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/function/json/testscript13
-rw-r--r--tests/type/json/testscript44
-rw-r--r--tests/type/map/testscript2
-rw-r--r--tests/type/set/testscript2
4 files changed, 58 insertions, 3 deletions
diff --git a/tests/function/json/testscript b/tests/function/json/testscript
index b7134a8..54e524f 100644
--- a/tests/function/json/testscript
+++ b/tests/function/json/testscript
@@ -37,7 +37,7 @@ object
object
EOO
-: size
+: value-size
:
$* <<EOI >>EOO
print $value_size([json] null)
@@ -244,3 +244,14 @@ EOO
<stdin>:1:6: info: while calling json.load(<untyped>)
EOE
}
+
+: size
+:
+{
+ $* <'print $size([json_set] a b b)' >'2' : json-set
+ $* <'print $size([json_map] a@1 b@2 b@3)' >'2' : json-map
+}
+
+: keys
+:
+$* <'print $keys([json_map] 2@([json] a@1 b@2 c@3) 1@([json] 1 2 3))' >'[1,2]'
diff --git a/tests/type/json/testscript b/tests/type/json/testscript
index 0e9af95..6dd6316 100644
--- a/tests/type/json/testscript
+++ b/tests/type/json/testscript
@@ -451,3 +451,47 @@
abc
EOO
}
+
+: json-map
+:
+{
+ : basics
+ :
+ $* <<EOI >>EOO
+ m = [json_map] 2@([json] a@1 b@2) 1@([json] 1 2) 0@([json] null) -1@null
+ print $m
+ for p: $m
+ print $first($p) $second($p)
+ print ($m[1])
+ print $type($m[1])
+ print ($m[2][b])
+ EOI
+ -1@"" 0@"" 1@[1,2] 2@{"a":1,"b":2}
+ -1 ""
+ 0 ""
+ 1 [1,2]
+ 2 {"a":1,"b":2}
+ [1,2]
+ json
+ 2
+ EOO
+}
+
+: json-set
+:
+{
+ : basics
+ :
+ $* <<EOI >>EOO
+ s = [json_set] ([json] x@1 y@2) ([json] a@1 b@2)
+ print $s
+ for v: $s
+ print $type($v) $v
+ print ($s[([json] y@2 x@1)])
+ EOI
+ {"a":1,"b":2} {"x":1,"y":2}
+ json {"a":1,"b":2}
+ json {"x":1,"y":2}
+ true
+ EOO
+}
diff --git a/tests/type/map/testscript b/tests/type/map/testscript
index 1c6224a..29f5ed4 100644
--- a/tests/type/map/testscript
+++ b/tests/type/map/testscript
@@ -1,7 +1,7 @@
# file : tests/type/map/testscript
# license : MIT; see accompanying LICENSE file
-# See also tests in function/*/ (size(), keys()).
+# See also tests in function/*/ (size(), keys()), type/json/ (json_map).
.include ../../common.testscript
diff --git a/tests/type/set/testscript b/tests/type/set/testscript
index da5e181..aca4c2d 100644
--- a/tests/type/set/testscript
+++ b/tests/type/set/testscript
@@ -1,7 +1,7 @@
# file : tests/type/set/testscript
# license : MIT; see accompanying LICENSE file
-# See also tests in function/*/ (size()).
+# See also tests in function/*/ (size()), type/json/ (json_set).
.include ../../common.testscript