ParenExpr extends Expr { @Override public void setChild(int index, Expr expr) { if (index == 0) { this.expr = expr; return; } throw new IndexOutOfBoundsException("Index for ParenExpr must be 0"); } ParenExpr(Expr expr); Expr getExpr(); @Override void accept(IAstVisitor visitor); @Override ParenExpr clone(); @Override boolean hasChild(IAstNode candidateChild); @Override Expr getChild(int index); @Override void setChild(int index, Expr expr); @Override int getNumChildren();  }
@Test public void setChild() { VariableIdentifierExpr y = new VariableIdentifierExpr("y"); pe.setChild(0, y); assertEquals(y, pe.getChild(0)); }
@Test(expected = IndexOutOfBoundsException.class) public void setChildBad() { VariableIdentifierExpr y = new VariableIdentifierExpr("y"); pe.setChild(1, y); }