Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void exitArithmeticExpression(BooleanExpressionParser.ArithmeticExpressio

@Override
public void exitUnaryArithmeticExpression(BooleanExpressionParser.UnaryArithmeticExpressionContext ctx) {
final Node leafNode = !currentNodes.isEmpty() ? currentNodes.pop() : mapTypesExpressionContext(
final Node leafNode = !currentNodes.isEmpty() && currentNodes.peek() instanceof ArithmeticNode ? currentNodes.pop() : mapTypesExpressionContext(
(BooleanExpressionParser.TypesExpressionContext) ctx.exp);
currentNodes.add(ArithmeticNode.builder().left(leafNode).operator(Operator.UNARY).build());
super.enterUnaryArithmeticExpression(ctx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,15 @@ public void testComparisonWithArithmeticFalseCondition1() {
assertFalse(booleanOptional.get());
}

@Test
public void testNegativeComparison() {
final Map<String, Object> data = new HashMap<>();
data.put("a", -6);
final Try<Boolean> resultOptional = booleanExpressionEvaluator.evaluate("a > -10 AND a < -2", data);
assertTrue(resultOptional.isSuccess());
assertEquals(resultOptional.get(), true);
}

@Test
public void testNullCheck() {
final Map<String, Object> data = new HashMap<>();
Expand Down