public void testBecomeRoot6() { // emulates construction of ^(5 6) ITreeAdaptor adaptor = new CommonTreeAdaptor(); CommonTree root_0 = (CommonTree)adaptor.GetNilNode(); CommonTree root_1 = (CommonTree)adaptor.GetNilNode(); 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 testBecomeRoot2() { // 5 becomes new root of ^(101 102 103) CommonTree newRoot = new CommonTree(new CommonToken(5)); CommonTree oldRoot = new CommonTree(new CommonToken(101)); oldRoot.AddChild(new CommonTree(new CommonToken(102))); oldRoot.AddChild(new CommonTree(new CommonToken(103))); ITreeAdaptor adaptor = new CommonTreeAdaptor(); adaptor.BecomeRoot(newRoot, oldRoot); newRoot.SanityCheckParentAndChildIndexes(); }
public void testBecomeRoot5() { // ^(nil 5) becomes new root of ^(101 102 103) CommonTree newRoot = new CommonTree((IToken)null); newRoot.AddChild(new CommonTree(new CommonToken(5))); CommonTree oldRoot = new CommonTree(new CommonToken(101)); oldRoot.AddChild(new CommonTree(new CommonToken(102))); oldRoot.AddChild(new CommonTree(new CommonToken(103))); ITreeAdaptor adaptor = new CommonTreeAdaptor(); adaptor.BecomeRoot(newRoot, oldRoot); newRoot.SanityCheckParentAndChildIndexes(); }