コード例 #1
0
ファイル: ITreeFixture.cs プロジェクト: winterjr/jaustoolset
        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();
        }
コード例 #2
0
ファイル: ITreeFixture.cs プロジェクト: winterjr/jaustoolset
        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.GetNilNode();

            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();
        }
コード例 #3
0
ファイル: ITreeFixture.cs プロジェクト: nikola-v/jaustoolset
        public void testReplaceOneWithTwoInMiddle()
        {
            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.GetNilNode();
            newChildren.AddChild(new CommonTree(new CommonToken(99, "x")));
            newChildren.AddChild(new CommonTree(new CommonToken(99, "y")));

            t.ReplaceChildren(1, 1, newChildren);
            String expected = "(a b x y d)";
            Assert.AreEqual(expected, t.ToStringTree());
            t.SanityCheckParentAndChildIndexes();
        }
コード例 #4
0
ファイル: ITreeFixture.cs プロジェクト: nikola-v/jaustoolset
        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();
        }