assertThat(children.size(), is(0));
}
@Test
public void shouldRemoveAllChildrenAndReturnCopyOfListOfChildren() {
parent = new AstNode(name("parent"));
AstNode child1 = new AstNode(parent, name("childA"));
AstNode child2 = new AstNode(parent, name("childB"));
AstNode child3 = new AstNode(parent, name("childC"));
// Perform the remove, and verify the list has all the children ...
List<AstNode> children = parent.removeAllChildren();
assertThat(children.get(0), is(sameInstance(child1)));
assertThat(children.get(1), is(sameInstance(child2)));
assertThat(children.get(2), is(sameInstance(child3)));
assertThat(children.size(), is(3));
assertThat(parent.getChildCount(), is(0));
// Add a new child to the parent ...
AstNode child1a = new AstNode(parent, name("child1A"));
assertThat(parent.getFirstChild(), is(sameInstance(child1a)));
// The returned copy should not be modified ...
assertThat(children.get(0), is(sameInstance(child1)));
assertThat(children.get(1), is(sameInstance(child2)));
assertThat(children.get(2), is(sameInstance(child3)));