Search in sources :

Example 1 with IntegerExprToken

use of org.develnext.jphp.core.tokenizer.token.expr.value.IntegerExprToken in project jphp by jphp-compiler.

the class ASMExpressionTest method testCallExpr.

@Test
public void testCallExpr() {
    ExprStmtToken expression = getASMExpression("func(1 + 2, 3) * 3").getResult();
    Assert.assertEquals(3, expression.getTokens().size());
    Assert.assertTrue(expression.getTokens().get(0) instanceof CallExprToken);
    CallExprToken call = (CallExprToken) expression.getTokens().get(0);
    Assert.assertEquals(2, call.getParameters().size());
    Assert.assertEquals("1+2", call.getParameters().get(0).getWord());
    Assert.assertEquals("3", call.getParameters().get(1).getWord());
    Assert.assertTrue(expression.getTokens().get(1) instanceof IntegerExprToken);
    Assert.assertTrue(expression.getTokens().get(2) instanceof MulExprToken);
}
Also used : CallExprToken(org.develnext.jphp.core.tokenizer.token.expr.value.CallExprToken) ExprStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.ExprStmtToken) MulExprToken(org.develnext.jphp.core.tokenizer.token.expr.operator.MulExprToken) IntegerExprToken(org.develnext.jphp.core.tokenizer.token.expr.value.IntegerExprToken) Test(org.junit.Test)

Example 2 with IntegerExprToken

use of org.develnext.jphp.core.tokenizer.token.expr.value.IntegerExprToken in project jphp by jphp-compiler.

the class ConstTest method testSimple.

@Test
public void testSimple() {
    List<Token> tree = getSyntaxTree("const my_CONST = 1;");
    Assert.assertTrue(tree.size() == 1);
    Assert.assertTrue(tree.get(0) instanceof ConstStmtToken);
    ConstStmtToken constant = (ConstStmtToken) tree.get(0);
    Assert.assertEquals("my_CONST", constant.items.get(0).getFulledName());
    Assert.assertNull(constant.getClazz());
    Assert.assertNotNull(constant.items.get(0).value);
    Assert.assertTrue(constant.items.get(0).value.getTokens().size() == 1);
    Assert.assertTrue(constant.items.get(0).value.getTokens().get(0) instanceof IntegerExprToken);
}
Also used : ConstStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.ConstStmtToken) IntegerExprToken(org.develnext.jphp.core.tokenizer.token.expr.value.IntegerExprToken) IntegerExprToken(org.develnext.jphp.core.tokenizer.token.expr.value.IntegerExprToken) Token(org.develnext.jphp.core.tokenizer.token.Token) ConstStmtToken(org.develnext.jphp.core.tokenizer.token.stmt.ConstStmtToken) Test(org.junit.Test)

Aggregations

IntegerExprToken (org.develnext.jphp.core.tokenizer.token.expr.value.IntegerExprToken)2 Test (org.junit.Test)2 Token (org.develnext.jphp.core.tokenizer.token.Token)1 MulExprToken (org.develnext.jphp.core.tokenizer.token.expr.operator.MulExprToken)1 CallExprToken (org.develnext.jphp.core.tokenizer.token.expr.value.CallExprToken)1 ConstStmtToken (org.develnext.jphp.core.tokenizer.token.stmt.ConstStmtToken)1 ExprStmtToken (org.develnext.jphp.core.tokenizer.token.stmt.ExprStmtToken)1