diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-01-28 22:45:29 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-01-28 22:45:29 +0900 |
| commit | fda13fefa083f9cc6489d55d21aab8ca0300e783 (patch) | |
| tree | e4fcb14d3ed4e59db1fc4efb16801093c6deb31a /src/root.zig | |
| parent | 9ddb831241a150e83fa18d1f681c264118c91fbc (diff) | |
| download | zgjq-fda13fefa083f9cc6489d55d21aab8ca0300e783.tar.gz zgjq-fda13fefa083f9cc6489d55d21aab8ca0300e783.tar.zst zgjq-fda13fefa083f9cc6489d55d21aab8ca0300e783.zip | |
implement array construction
Diffstat (limited to 'src/root.zig')
| -rw-r--r-- | src/root.zig | 55 |
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]]]"); +} |
