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
6262
6363 @ Override
6464 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 (
6666 (BooleanExpressionParser .TypesExpressionContext ) ctx .exp );
6767 currentNodes .add (ArithmeticNode .builder ().left (leafNode ).operator (Operator .UNARY ).build ());
6868 super .enterUnaryArithmeticExpression (ctx );
Original file line number Diff line number Diff line change @@ -587,6 +587,15 @@ public void testComparisonWithArithmeticFalseCondition1() {
587587 assertFalse (booleanOptional .get ());
588588 }
589589
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+
590599 @ Test
591600 public void testNullCheck () {
592601 final Map <String , Object > data = new HashMap <>();
You can’t perform that action at this time.
0 commit comments