From 8e8fcf1dd73c785f6901cf53ce17380099d15bd1 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 18 Jan 2026 00:49:33 +0900 Subject: implement pipe operator --- src/root.zig | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/root.zig') diff --git a/src/root.zig b/src/root.zig index e4df465..b89b54f 100644 --- a/src/root.zig +++ b/src/root.zig @@ -79,4 +79,15 @@ test "addition" { try testRun("579", allocator, "null", "123 + 456"); try testRun("35", allocator, "{\"a\":12,\"b\":23}", ".a + .b"); try testRun("12", allocator, "[1,2,3]", ".[1] + 10"); + try testRun("6", allocator, "null", "1 + 2 + 3"); +} + +test "pipe operator" { + var debug_allocator = std.heap.DebugAllocator(.{}).init; + defer std.debug.assert(debug_allocator.deinit() == .ok); + const allocator = debug_allocator.allocator(); + + try testRun("123", allocator, "{\"a\":{\"b\":123}}", ".a | .b"); + try testRun("584", allocator, "null", "123 + 456 | . + 5"); + try testRun("10", allocator, "null", "1 | . + 2 | . + 3 | . | 4 + ."); } -- cgit v1.3-1-g0d28