示例#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());
  }
示例#2
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());
  }