예제 #1
0
  public void testPostfixExpression1() throws ANTLRException {
    setupParser("idx++");
    defineVariable("idx", false);

    PostfixExpression result = (PostfixExpression) _parser.expression();

    assertNotNull(result);
    assertTrue(result.isIncrement());

    VariableAccess varAccess = (VariableAccess) result.getInnerExpression();

    assertNotNull(varAccess);
    assertEquals("idx", varAccess.getVariableName());
    assertEquals(result, varAccess.getContainer());
  }
예제 #2
0
  public void testPostfixExpression4() throws ANTLRException {
    setupParser("(var)--");
    defineVariable("var", false);

    PostfixExpression result = (PostfixExpression) _parser.expression();

    assertNotNull(result);
    assertTrue(!result.isIncrement());

    ParenthesizedExpression parenExpr = (ParenthesizedExpression) result.getInnerExpression();

    assertNotNull(parenExpr);
    assertEquals(result, parenExpr.getContainer());

    VariableAccess varAccess = (VariableAccess) parenExpr.getInnerExpression();

    assertNotNull(varAccess);
    assertEquals("var", varAccess.getVariableName());
    assertEquals(parenExpr, varAccess.getContainer());
  }