aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/root.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/root.zig')
-rw-r--r--src/root.zig12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/root.zig b/src/root.zig
index f2cc29a..b1f8614 100644
--- a/src/root.zig
+++ b/src/root.zig
@@ -124,6 +124,18 @@ test "comma operator" {
try testRunMultiple(&.{ "12", "34", "56" }, "{\"a\":12,\"b\":34,\"c\":56}", ".a,.b,.c");
}
+test "optional index" {
+ try testRun("1", "[1,2,3]", ".[0]?");
+ try testRun("null", "[1,2,3]", ".[5]?");
+ try testRun("null", "null", ".[0]?");
+ try testRun("null", "123", ".[0]?");
+
+ try testRun("123", "{\"a\":123}", ".a?");
+ try testRun("null", "{\"a\":123}", ".b?");
+ try testRun("null", "null", ".a?");
+ try testRun("null", "[1,2,3]", ".a?");
+}
+
test "comparison operators" {
try testRun("true", "null", "1 == 1");
try testRun("false", "null", "1 == 2");