From fda13fefa083f9cc6489d55d21aab8ca0300e783 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 28 Jan 2026 22:45:29 +0900 Subject: implement array construction --- src/root.zig | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'src/root.zig') 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]]]"); +} -- cgit v1.3-1-g0d28