File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
main/java/com/github/sidhant92/boolparser/parser/antlr
test/java/com/github/sidhant92/boolparser/application Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ public void exitArithmeticExpression(BooleanExpressionParser.ArithmeticExpressio
62
62
63
63
@ Override
64
64
public void exitUnaryArithmeticExpression (BooleanExpressionParser .UnaryArithmeticExpressionContext ctx ) {
65
- final Node leafNode = !currentNodes .isEmpty () ? currentNodes .pop () : mapTypesExpressionContext (
65
+ final Node leafNode = !currentNodes .isEmpty () && currentNodes . peek () instanceof ArithmeticNode ? currentNodes .pop () : mapTypesExpressionContext (
66
66
(BooleanExpressionParser .TypesExpressionContext ) ctx .exp );
67
67
currentNodes .add (ArithmeticNode .builder ().left (leafNode ).operator (Operator .UNARY ).build ());
68
68
super .enterUnaryArithmeticExpression (ctx );
Original file line number Diff line number Diff line change @@ -587,6 +587,15 @@ public void testComparisonWithArithmeticFalseCondition1() {
587
587
assertFalse (booleanOptional .get ());
588
588
}
589
589
590
+ @ Test
591
+ public void testNegativeComparison () {
592
+ final Map <String , Object > data = new HashMap <>();
593
+ data .put ("a" , -6 );
594
+ final Try <Boolean > resultOptional = booleanExpressionEvaluator .evaluate ("a > -10 AND a < -2" , data );
595
+ assertTrue (resultOptional .isSuccess ());
596
+ assertEquals (resultOptional .get (), true );
597
+ }
598
+
590
599
@ Test
591
600
public void testNullCheck () {
592
601
final Map <String , Object > data = new HashMap <>();
You can’t perform that action at this time.
0 commit comments