From 4dbed10befe4bfb386f24577ee925e744540e207 Mon Sep 17 00:00:00 2001 From: Kalle Stenflo Date: Wed, 11 Nov 2015 22:22:03 +0100 Subject: [PATCH] Added tests for issue #141 --- .../test/java/com/jayway/jsonpath/FilterTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/json-path/src/test/java/com/jayway/jsonpath/FilterTest.java b/json-path/src/test/java/com/jayway/jsonpath/FilterTest.java index 45d08ca1..af6ec17f 100644 --- a/json-path/src/test/java/com/jayway/jsonpath/FilterTest.java +++ b/json-path/src/test/java/com/jayway/jsonpath/FilterTest.java @@ -670,4 +670,16 @@ public class FilterTest extends BaseTest { assertThat(filter).isEqualTo(parsed); } + + @Test + public void testFilterWithOrShortCircuit1() throws Exception { + Object json = Configuration.defaultConfiguration().jsonProvider().parse( "{\"firstname\":\"Bob\",\"surname\":\"Smith\",\"age\":30}"); + assertThat(Filter.parse("[?((@.firstname == 'Bob' || @.firstname == 'Jane') && @.surname == 'Doe')]").apply(createPredicateContext(json))).isFalse(); + } + + @Test + public void testFilterWithOrShortCircuit2() throws Exception { + Object json = Configuration.defaultConfiguration().jsonProvider().parse("{\"firstname\":\"Bob\",\"surname\":\"Smith\",\"age\":30}"); + assertThat(Filter.parse("[?((@.firstname == 'Bob' || @.firstname == 'Jane') && @.surname == 'Smith')]").apply(createPredicateContext(json))).isTrue(); + } }