ArrayIndexExpr extends Expr { @Override public Expr getChild(int index) { if (index == 0) { return array; } if (index == 1) { return this.index; } throw new IndexOutOfBoundsException("Index for ArrayIndexExpr must be 0 or 1"); } ArrayIndexExpr(Expr array, Expr index); Expr getArray(); Expr getIndex(); void setIndex(Expr index); @Override void accept(IAstVisitor visitor); @Override ArrayIndexExpr clone(); @Override boolean hasChild(IAstNode candidateChild); @Override Expr getChild(int index); @Override void setChild(int index, Expr expr); @Override int getNumChildren();  }
@Test public void getChild() throws Exception { assertEquals("A", expr.getChild(0).getText()); assertEquals("0", expr.getChild(1).getText()); }
@Test(expected = IndexOutOfBoundsException.class) public void getChildBad() { expr.getChild(2); }