Esempio n. 1
0
  public void testPostfixExpression2() throws ANTLRException {
    setupParser("this.var--");

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

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

    FieldAccess fieldAccess = (FieldAccess) result.getInnerExpression();

    assertNotNull(fieldAccess);
    assertEquals("var", fieldAccess.getFieldName());
    assertEquals(result, fieldAccess.getContainer());
  }
Esempio n. 2
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());
  }
Esempio n. 3
0
  public void testPostfixExpression3() throws ANTLRException {
    setupParser("arr[3]++");

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

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

    ArrayAccess arrayAccess = (ArrayAccess) result.getInnerExpression();

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

    FieldAccess fieldAccess = (FieldAccess) arrayAccess.getBaseExpression();

    assertNotNull(fieldAccess);
    assertEquals("arr", fieldAccess.getFieldName());
    assertEquals(arrayAccess, fieldAccess.getContainer());
  }
Esempio n. 4
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());
  }