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 @@ -155,19 +155,22 @@ private ArithmeticFunctionNode mapArithmeticFunctionExpressionContext(BooleanExp

private ComparisonNode mapComparatorExpressionContext(BooleanExpressionParser.ComparatorExpressionContext ctx) {
final Operator operator = Operator.getOperatorFromSymbol(ctx.op.getText()).orElse(Operator.EQUALS);
if (!(ctx.right instanceof BooleanExpressionParser.TypesExpressionContext) && !currentNodes.isEmpty()) {
final Node value = currentNodes.pop();
return new ComparisonNode(mapContextToNode(ctx.left), value, operator, DataType.INTEGER);
} else {
if (ctx.left instanceof BooleanExpressionParser.ParentExpressionContext && !currentNodes.isEmpty()) {

if (!currentNodes.isEmpty() && ((ctx.right instanceof BooleanExpressionParser.ParentExpressionContext || ctx.left instanceof BooleanExpressionParser.ParentExpressionContext) || !(currentNodes.peek() instanceof ComparisonNode || currentNodes.peek() instanceof BooleanNode))) {
if (ctx.left instanceof BooleanExpressionParser.TypesExpressionContext) {
final DataType dataType = getDataType(ctx.left.getStart());
final Node value = mapContextToNode(ctx.left);
return new ComparisonNode(value, currentNodes.pop(), operator, dataType);
} else if (ctx.right instanceof BooleanExpressionParser.TypesExpressionContext) {
final DataType dataType = getDataType(ctx.right.getStart());
final Node value = mapContextToNode(ctx.right);
return new ComparisonNode(currentNodes.pop(), value, operator, dataType);
}
final DataType dataType = getDataType(ctx.right.getStart());
final Node value = mapContextToNode(ctx.right);
return new ComparisonNode(mapContextToNode(ctx.left), value, operator, dataType);
}

final DataType dataType = getDataType(ctx.right.getStart());
final Node value = mapContextToNode(ctx.right);
return new ComparisonNode(mapContextToNode(ctx.left), value, operator, dataType);
}

private ArithmeticNode mapArithmeticExpressionContext(BooleanExpressionParser.ArithmeticExpressionContext ctx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,16 @@ public void testComparisonWithArithmeticFalseCondition1() {
assertFalse(booleanOptional.get());
}

@Test
public void testBooleanComparison() {
final Map<String, Object> data = new HashMap<>();
data.put("age", true);
data.put("a", 20);
final Try<Boolean> booleanOptional = booleanExpressionEvaluator.evaluate("age = (5 > 3)", data);
assertTrue(booleanOptional.isSuccess());
assertTrue(booleanOptional.get());
}

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