Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
Merge pull request #66 from ciobis/fix-boolean-negation
Browse files Browse the repository at this point in the history
Fix parsing for boolean expressions starting with negation
  • Loading branch information
iconara authored Dec 4, 2021
2 parents f119644 + 93701c6 commit c9cb9f3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ expression
| expression bracketSpecifier # bracketedExpression
| bracketSpecifier # bracketExpression
| expression COMPARATOR expression # comparisonExpression
| '!' expression # notExpression
| expression '&&' expression # andExpression
| expression '||' expression # orExpression
| identifier # identifierExpression
| '!' expression # notExpression
| '(' expression ')' # parenExpression
| wildcard # wildcardExpression
| multiSelectList # multiSelectListExpression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,32 @@ public void bareNegatedExpression() {
assertThat(actual, is(expected));
}

@Test
public void negatedBooleansTripleConjunctionExpression() {
Expression<Object> expected = And(
And(
Negate(Property("foo")),
Negate(Property("bar"))
),
Negate(Property("buzz"))
);
Expression<Object> actual = compile("!foo && !bar && !buzz");
assertThat(actual, is(expected));
}

@Test
public void negatedBooleansTripleDisjunctionExpression() {
Expression<Object> expected = Or(
Or(
Negate(Property("foo")),
Negate(Property("bar"))
),
Negate(Property("buzz"))
);
Expression<Object> actual = compile("!foo || !bar || !buzz");
assertThat(actual, is(expected));
}

@Test
public void negatedSelectionExpression() {
Expression<Object> expected = Sequence(
Expand Down

0 comments on commit c9cb9f3

Please sign in to comment.