Search in sources :

Example 1 with LogicOperatorExprToken

use of org.develnext.jphp.core.tokenizer.token.expr.operator.LogicOperatorExprToken in project jphp by jphp-compiler.

the class ASMExpressionTest method testPriorities.

@Test
public void testPriorities() {
    Assert.assertEquals("123/+", getASMExpression("1 + 2 / 3").getResult().getWord());
    Assert.assertEquals("123*+", getASMExpression("1 + 2 * 3").getResult().getWord());
    Assert.assertEquals("123%+", getASMExpression("1 + 2 % 3").getResult().getWord());
    Assert.assertEquals("12*3/", getASMExpression("1 * 2 / 3").getResult().getWord());
    Assert.assertEquals("12/3%", getASMExpression("1 / 2 % 3").getResult().getWord());
    Assert.assertEquals("12/3/", getASMExpression("1 / 2 / 3").getResult().getWord());
    Assert.assertEquals("12-3+", getASMExpression("1 - 2 + 3").getResult().getWord());
    ExprStmtToken expr = getASMExpression("1 && 2 + 3").getResult();
    Assert.assertEquals("1&&", expr.getWord());
    Assert.assertTrue(expr.getTokens().get(1) instanceof LogicOperatorExprToken);
    Assert.assertEquals("2+3", ((LogicOperatorExprToken) expr.getTokens().get(1)).getRightValue().getWord());
    Assert.assertEquals("1||", getASMExpression("1 || 2 + 3").getResult().getWord());
    Assert.assertEquals("1||", getASMExpression("1 || 2 && 3").getResult().getWord());
    Assert.assertEquals("1!||", getASMExpression("!1 || 2 && 3").getResult().getWord());
}
Also used : ExprStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.ExprStmtToken) LogicOperatorExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.LogicOperatorExprToken) Test(org.junit.Test)

Aggregations

LogicOperatorExprToken (org.develnext.jphp.core.tokenizer.token.expr.operator.LogicOperatorExprToken)1 ExprStmtToken (org.develnext.jphp.core.tokenizer.token.stmt.ExprStmtToken)1 Test (org.junit.Test)1