public void testBecomeRoot6() { // emulates construction of ^(5 6) ITreeAdaptor adaptor = new CommonTreeAdaptor(); CommonTree root_0 = (CommonTree)adaptor.Nil(); CommonTree root_1 = (CommonTree)adaptor.Nil(); root_1 = (CommonTree)adaptor.BecomeRoot(new CommonTree(new CommonToken(5)), root_1); adaptor.AddChild(root_1, new CommonTree(new CommonToken(6))); adaptor.AddChild(root_0, root_1); root_0.SanityCheckParentAndChildIndexes(); }
public void testReplaceAllWithTwo() { ITreeAdaptor adaptor = new CommonTreeAdaptor(); CommonTree t = new CommonTree(new CommonToken(99, "a")); t.AddChild(new CommonTree(new CommonToken(99, "b"))); t.AddChild(new CommonTree(new CommonToken(99, "c"))); t.AddChild(new CommonTree(new CommonToken(99, "d"))); CommonTree newChildren = (CommonTree)adaptor.Nil(); newChildren.AddChild(new CommonTree(new CommonToken(99, "x"))); newChildren.AddChild(new CommonTree(new CommonToken(99, "y"))); t.ReplaceChildren(0, 2, newChildren); String expected = "(a x y)"; Assert.AreEqual(expected, t.ToStringTree()); t.SanityCheckParentAndChildIndexes(); }