From 728b7fa80aea4541ad86bafd0d84c92e478a58a8 Mon Sep 17 00:00:00 2001 From: James Prior Date: Tue, 5 Mar 2024 08:11:07 +0000 Subject: [PATCH] Test that `&&` binds more tightly than `||` --- tests/filter.json | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/filter.json b/tests/filter.json index 3bf14e1..9491103 100644 --- a/tests/filter.json +++ b/tests/filter.json @@ -799,6 +799,44 @@ [1, 2], [2, 1] ] + }, + { + "name": "and binds more tightly than or", + "selector" : "$[?@.a || @.b && @.b]", + "document" : [{"a": 1}], + "result": [ + {"a": 1} + ] + }, + { + "name": "left to right evaluation", + "selector" : "$[?@.b && @.b || @.a]", + "document" : [{"a": 1}], + "result": [ + {"a": 1} + ] + }, + { + "name": "group terms, left", + "selector" : "$[?(@.a || @.b) && @.a]", + "document" : [{"a": 1}], + "result": [ + {"a": 1} + ] + }, + { + "name": "group terms, right", + "selector" : "$[?@.a && (@.b || @.a)]", + "document" : [{"a": 1}], + "result": [ + {"a": 1} + ] + }, + { + "name": "group terms, or before and", + "selector" : "$[?(@.a || @.b) && @.b]", + "document" : [{"a": 1}], + "result": [] } ] }