use of org.drools.mvel.parser.ast.expr.HalfBinaryExpr in project drools by kiegroup.
the class DroolsMvelParserTest method testAndWithImplicitParameter3.
@Test
public void testAndWithImplicitParameter3() {
String expr = "age == 2 && == 3 || == 4";
Expression expression = parseExpression(parser, expr).getExpr();
BinaryExpr comboExpr = ((BinaryExpr) expression);
assertEquals(Operator.OR, comboExpr.getOperator());
assertEquals(Operator.AND, ((BinaryExpr) (comboExpr.getLeft())).getOperator());
BinaryExpr first = ((BinaryExpr) ((BinaryExpr) comboExpr.getLeft()).getLeft());
assertEquals("age", toString(first.getLeft()));
assertEquals("2", toString(first.getRight()));
assertEquals(Operator.EQUALS, first.getOperator());
HalfBinaryExpr second = (HalfBinaryExpr) ((BinaryExpr) comboExpr.getLeft()).getRight();
assertEquals("3", toString(second.getRight()));
assertEquals(HalfBinaryExpr.Operator.EQUALS, second.getOperator());
HalfBinaryExpr third = (HalfBinaryExpr) comboExpr.getRight();
assertEquals("4", toString(third.getRight()));
assertEquals(HalfBinaryExpr.Operator.EQUALS, third.getOperator());
}
use of org.drools.mvel.parser.ast.expr.HalfBinaryExpr in project drools by kiegroup.
the class DroolsMvelParserTest method testAndWithImplicitParameterAndParenthesis.
@Test
public void testAndWithImplicitParameterAndParenthesis() {
String expr = "value (> 1 && < 2)";
Expression expression = parseExpression(parser, expr).getExpr();
BinaryExpr comboExpr = ((BinaryExpr) expression);
assertEquals(Operator.AND, comboExpr.getOperator());
BinaryExpr first = (BinaryExpr) comboExpr.getLeft();
assertEquals("value", toString(first.getLeft()));
assertEquals("1", toString(first.getRight()));
assertEquals(Operator.GREATER, first.getOperator());
HalfBinaryExpr second = (HalfBinaryExpr) comboExpr.getRight();
assertEquals("2", toString(second.getRight()));
assertEquals(HalfBinaryExpr.Operator.LESS, second.getOperator());
}
use of org.drools.mvel.parser.ast.expr.HalfBinaryExpr in project drools by kiegroup.
the class DroolsMvelParserTest method testAndWithImplicitParameter.
@Test
public void testAndWithImplicitParameter() {
String expr = "name == \"Mark\" && == \"Mario\" && == \"Luca\"";
Expression expression = parseExpression(parser, expr).getExpr();
BinaryExpr comboExpr = ((BinaryExpr) expression);
assertEquals(Operator.AND, comboExpr.getOperator());
BinaryExpr first = ((BinaryExpr) ((BinaryExpr) comboExpr.getLeft()).getLeft());
assertEquals("name", toString(first.getLeft()));
assertEquals("\"Mark\"", toString(first.getRight()));
assertEquals(Operator.EQUALS, first.getOperator());
HalfBinaryExpr second = (HalfBinaryExpr) ((BinaryExpr) comboExpr.getLeft()).getRight();
assertEquals("\"Mario\"", toString(second.getRight()));
assertEquals(HalfBinaryExpr.Operator.EQUALS, second.getOperator());
HalfBinaryExpr third = (HalfBinaryExpr) comboExpr.getRight();
assertEquals("\"Luca\"", toString(third.getRight()));
assertEquals(HalfBinaryExpr.Operator.EQUALS, third.getOperator());
}
use of org.drools.mvel.parser.ast.expr.HalfBinaryExpr in project drools by kiegroup.
the class DroolsMvelParserTest method testAndWithImplicitParameterAndParenthesisOnThis.
@Test
public void testAndWithImplicitParameterAndParenthesisOnThis() {
String expr = "this (> 1 && < 2)";
Expression expression = parseExpression(parser, expr).getExpr();
BinaryExpr comboExpr = ((BinaryExpr) expression);
assertEquals(Operator.AND, comboExpr.getOperator());
BinaryExpr first = (BinaryExpr) comboExpr.getLeft();
assertEquals("this", toString(first.getLeft()));
assertEquals("1", toString(first.getRight()));
assertEquals(Operator.GREATER, first.getOperator());
HalfBinaryExpr second = (HalfBinaryExpr) comboExpr.getRight();
assertEquals("2", toString(second.getRight()));
assertEquals(HalfBinaryExpr.Operator.LESS, second.getOperator());
}
use of org.drools.mvel.parser.ast.expr.HalfBinaryExpr in project drools by kiegroup.
the class DroolsMvelParserTest method testAndWithImplicitParameterAndParenthesisMixedRight.
@Test
public void testAndWithImplicitParameterAndParenthesisMixedRight() {
String expr = "value (< 1 || (> 2 && < 3))";
Expression expression = parseExpression(parser, expr).getExpr();
BinaryExpr comboExpr = ((BinaryExpr) expression);
assertEquals(Operator.OR, comboExpr.getOperator());
BinaryExpr first = ((BinaryExpr) comboExpr.getLeft());
assertEquals("value", toString(first.getLeft()));
assertEquals("1", toString(first.getRight()));
assertEquals(Operator.LESS, first.getOperator());
BinaryExpr comboExprRight = ((BinaryExpr) comboExpr.getRight());
assertEquals(Operator.AND, comboExprRight.getOperator());
BinaryExpr third = (BinaryExpr) comboExprRight.getLeft();
assertEquals("value", toString(third.getLeft()));
assertEquals("2", toString(third.getRight()));
assertEquals(Operator.GREATER, third.getOperator());
HalfBinaryExpr forth = (HalfBinaryExpr) comboExprRight.getRight();
assertEquals("3", toString(forth.getRight()));
assertEquals(HalfBinaryExpr.Operator.LESS, forth.getOperator());
}
Aggregations