aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/root.zig
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-01-25 22:10:05 +0900
committernsfisis <nsfisis@gmail.com>2026-01-25 22:10:05 +0900
commit57f06b7309aad18d83e9ecb04d7c59ccea527f17 (patch)
treea15454411e2dbd5fc9f6aa92b78a079e88b4ab14 /src/root.zig
parent8263832eb8c23968f0cfea15b5cb1bfa3546d540 (diff)
downloadzgjq-57f06b7309aad18d83e9ecb04d7c59ccea527f17.tar.gz
zgjq-57f06b7309aad18d83e9ecb04d7c59ccea527f17.tar.zst
zgjq-57f06b7309aad18d83e9ecb04d7c59ccea527f17.zip
implement and/or operators
Diffstat (limited to 'src/root.zig')
-rw-r--r--src/root.zig38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/root.zig b/src/root.zig
index 123dc7e..b612d89 100644
--- a/src/root.zig
+++ b/src/root.zig
@@ -216,3 +216,41 @@ test "comparison operators" {
try testRun("true", "{\"a\":\"abd\",\"b\":\"abc\"}", ".a > .b");
try testRun("true", "{\"a\":\"abc\",\"b\":\"abc\"}", ".a >= .b");
}
+
+test "and operator" {
+ try testRun("true", "null", "true and true");
+ try testRun("false", "null", "true and false");
+ try testRun("false", "null", "false and true");
+ try testRun("false", "null", "false and false");
+
+ try testRun("false", "null", "null and true");
+ try testRun("false", "null", "true and null");
+
+ try testRun("true", "null", "1 and 1");
+ try testRun("false", "null", "1 and false");
+ try testRun("true", "null", "\"hello\" and true");
+
+ try testRun("true", "{\"a\":true,\"b\":true}", ".a and .b");
+ try testRun("false", "{\"a\":true,\"b\":false}", ".a and .b");
+ try testRun("false", "{\"a\":false,\"b\":true}", ".a and .b");
+}
+
+test "or operator" {
+ try testRun("true", "null", "true or true");
+ try testRun("true", "null", "true or false");
+ try testRun("true", "null", "false or true");
+ try testRun("false", "null", "false or false");
+
+ try testRun("true", "null", "null or true");
+ try testRun("true", "null", "true or null");
+ try testRun("false", "null", "null or false");
+ try testRun("false", "null", "false or null");
+
+ try testRun("true", "null", "1 or false");
+ try testRun("true", "null", "false or 1");
+ try testRun("false", "null", "false or false");
+
+ try testRun("true", "{\"a\":true,\"b\":false}", ".a or .b");
+ try testRun("true", "{\"a\":false,\"b\":true}", ".a or .b");
+ try testRun("false", "{\"a\":false,\"b\":false}", ".a or .b");
+}