aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/root.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/root.zig')
-rw-r--r--src/root.zig55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/root.zig b/src/root.zig
index 7aee514..e61ed1f 100644
--- a/src/root.zig
+++ b/src/root.zig
@@ -275,3 +275,58 @@ test "alternative operator" {
try testRun("[]", "[]", ". // \"default\"");
try testRun("{}", "{}", ". // \"default\"");
}
+
+test "array constructor" {
+ try testRun(
+ \\[
+ \\ 1,
+ \\ 2,
+ \\ 3
+ \\]
+ , "null", "[1,2,3]");
+ try testRun(
+ \\[
+ \\ 1,
+ \\ 2
+ \\]
+ , "{\"a\":1,\"b\":2}", "[.a, .b]");
+ try testRun(
+ \\[
+ \\ 3
+ \\]
+ , "null", "[1 + 2]");
+ try testRun(
+ \\[
+ \\ 1,
+ \\ 2,
+ \\ 3
+ \\]
+ , "[1,2,3]", "[.[0], .[1], .[2]]");
+ try testRun(
+ \\[
+ \\ [
+ \\ 1,
+ \\ 2,
+ \\ 3
+ \\ ]
+ \\]
+ , "[1,2,3]", "[.]");
+ try testRun(
+ \\[
+ \\ true,
+ \\ false
+ \\]
+ , "null", "[true, false]");
+ try testRun(
+ \\[
+ \\ 1,
+ \\ [
+ \\ 1,
+ \\ [
+ \\ 1,
+ \\ 2
+ \\ ]
+ \\ ]
+ \\]
+ , "{\"a\":1,\"b\":2}", "[.a, [.a, [.a, .b]]]");
+}