Exemple #1
0
        public void LLConfEmptyDiffLabelsNotEqualTest()
        {
            var ll1 = new LlConfiguration <CharSymbol>(new CharSymbol('A'));
            var ll2 = new LlConfiguration <CharSymbol>(new CharSymbol('B'));

            Assert.AreNotEqual(ll1, ll2);
        }
Exemple #2
0
        public void LLConfEmptyCountTest()
        {
            CharSymbol chSym = new CharSymbol('A');
            var        ll    = new LlConfiguration <CharSymbol>(chSym);

            Assert.AreEqual(ll.Count(), 0);
        }
Exemple #3
0
        public void LLConfEmptyPushPeekTest()
        {
            CharSymbol chSym = new CharSymbol('A');
            var        ll    = new LlConfiguration <CharSymbol>(chSym);

            Assert.AreEqual(ll.Push(states["A1"]).Peek(), states["A1"]);
        }
Exemple #4
0
        public void LLConfEmptyPushTest()
        {
            CharSymbol chSym  = new CharSymbol('A');
            var        imList = ImmutableList.Create(states["A1"]);
            var        ll     = new LlConfiguration <CharSymbol>(chSym);

            Assert.AreEqual(ll.Push(states["A1"]).stack, imList);
        }
Exemple #5
0
        public void LLConfPeekTest()
        {
            CharSymbol chSym  = new CharSymbol('A');
            var        imList = ImmutableList.Create(states["A3"]);
            var        ll     = new LlConfiguration <CharSymbol>(chSym, imList);

            Assert.AreEqual(states["A3"], ll.Peek());
        }
Exemple #6
0
        public void LLConfPopPeekTest()
        {
            CharSymbol chSym  = new CharSymbol('A');
            var        imList = ImmutableList.Create(states["A1"], states["A2"]);
            var        begLL  = new LlConfiguration <CharSymbol>(chSym, imList);

            Assert.AreEqual(begLL.Pop().Peek(), states["A1"]);
        }
Exemple #7
0
        public void LLConfSymbolConstructorStackTest()
        {
            CharSymbol chSym = new CharSymbol('A');
            var        stack = new Stack <DfaState <CharSymbol> >();
            var        ll    = new LlConfiguration <CharSymbol>(chSym);

            Assert.AreEqual(stack, ll.copyOfStack());
        }
Exemple #8
0
        public void LLConfThreePopToEmptyTest()
        {
            CharSymbol chSym  = new CharSymbol('A');
            var        imList = ImmutableList.Create(states["A1"], states["B2"], states["A3"]);
            var        ll1    = new LlConfiguration <CharSymbol>(chSym);
            var        ll2    = new LlConfiguration <CharSymbol>(chSym, imList);

            Assert.AreEqual(ll1, ll2.Pop().Pop().Pop());
        }
Exemple #9
0
        public void LLConfSymbolConstructorTest()
        {
            CharSymbol chSym = new CharSymbol('A');
            var        ll    = new LlConfiguration <CharSymbol>(chSym);

            Console.WriteLine("LL -> " + ll);
            Assert.AreEqual(chSym, ll.label);
            Assert.IsEmpty(ll.stack);
        }
Exemple #10
0
        public void LLConfPopToEmptyTest()
        {
            CharSymbol chSym  = new CharSymbol('A');
            var        imList = ImmutableList.Create(states["A1"]);
            var        begLL  = new LlConfiguration <CharSymbol>(chSym, imList);
            var        resLL  = new LlConfiguration <CharSymbol>(chSym);

            Assert.AreEqual(begLL.Pop(), resLL);
        }
Exemple #11
0
        public void LLConfThreePushEqualTest()
        {
            CharSymbol chSym      = new CharSymbol('A');
            var        targetList = ImmutableList.Create(states["A1"], states["B2"], states["A3"]);
            var        ll1        = new LlConfiguration <CharSymbol>(chSym);
            var        ll2        = new LlConfiguration <CharSymbol>(chSym, targetList);

            Assert.AreEqual(ll1.Push(states["A1"]).Push(states["B2"]).Push(states["A3"]), ll2);
        }
Exemple #12
0
        public void LLConfEmptyPushEqualTest()
        {
            CharSymbol chSym  = new CharSymbol('A');
            var        imList = ImmutableList.Create(states["A3"]);
            var        ll1    = new LlConfiguration <CharSymbol>(chSym);
            var        ll2    = new LlConfiguration <CharSymbol>(chSym, imList);

            Assert.AreEqual(ll1.Push(states["A3"]), ll2);
        }
Exemple #13
0
        public void LLConfOnePopEqualTest()
        {
            CharSymbol chSym   = new CharSymbol('A');
            var        imList1 = ImmutableList.Create(states["A1"], states["A2"]);
            var        imList2 = ImmutableList.Create(states["A1"], states["A2"], states["A3"]);
            var        ll1     = new LlConfiguration <CharSymbol>(chSym, imList1);
            var        ll2     = new LlConfiguration <CharSymbol>(chSym, imList2);

            Assert.AreEqual(ll1, ll2.Pop());
        }
Exemple #14
0
        public void LLConfSameListDiffLabelNotEqualTest()
        {
            CharSymbol chSym1 = new CharSymbol('A');
            CharSymbol chSym2 = new CharSymbol('B');
            var        imList = ImmutableList.Create(states["A1"], states["A2"], states["A3"]);

            var ll1 = new LlConfiguration <CharSymbol>(chSym1, imList);
            var ll2 = new LlConfiguration <CharSymbol>(chSym2, imList);

            Assert.AreNotEqual(ll1, ll2);
        }
Exemple #15
0
        public void LLConfListConstructorTest()
        {
            CharSymbol chSym  = new CharSymbol('A');
            var        imList = ImmutableList.Create(states["A1"], states["A2"], states["A3"]);

            var ll = new LlConfiguration <CharSymbol>(chSym, imList);

            Console.WriteLine("LL -> " + ll);
            Assert.AreEqual(chSym, ll.label);
            Assert.AreEqual(imList, ll.stack);
        }
Exemple #16
0
        public void LLConfPopCountTest()
        {
            CharSymbol chSym = new CharSymbol('A');
            var        stack = new Stack <DfaState <CharSymbol> >();

            stack.Push(states["A1"]);
            stack.Push(states["A2"]);
            var ll = new LlConfiguration <CharSymbol>(chSym, stack);

            Assert.AreEqual(ll.Pop().Count(), 1);
        }
Exemple #17
0
        public void LLConfDiffCountNotEqualTest()
        {
            CharSymbol chSym   = new CharSymbol('A');
            var        aaaList = ImmutableList.Create(states["A1"], states["A2"], states["A3"]);
            var        aaList  = ImmutableList.Create(states["A1"], states["A2"]);

            var ll1 = new LlConfiguration <CharSymbol>(chSym, aaaList);
            var ll2 = new LlConfiguration <CharSymbol>(chSym, aaList);

            Assert.AreNotEqual(ll1, ll2);
        }
Exemple #18
0
        public void LLConfThreeCountTest()
        {
            CharSymbol chSym = new CharSymbol('A');
            var        stack = new Stack <DfaState <CharSymbol> >();

            stack.Push(new DfaState <CharSymbol>("A1"));
            stack.Push(new DfaState <CharSymbol>("A2"));
            stack.Push(new DfaState <CharSymbol>("A3"));
            var ll = new LlConfiguration <CharSymbol>(chSym, stack);

            Assert.AreEqual(ll.Count(), 3);
        }
Exemple #19
0
        public void LLConfSubsumesEqualLabelTest()
        {
            CharSymbol chSymA = new CharSymbol('A');
            var        llA    = new LlConfiguration <CharSymbol>(chSymA);

            CharSymbol chSymB = new CharSymbol('A');
            var        llB    = new LlConfiguration <CharSymbol>(chSymB);

            bool result = llA.Subsumes(llB);

            Assert.AreEqual(true, result);
        }
Exemple #20
0
        public void LLConfListConstructorStackTest()
        {
            CharSymbol chSym = new CharSymbol('A');
            var        stack = new Stack <DfaState <CharSymbol> >();

            stack.Push(states["A1"]);
            stack.Push(states["A2"]);
            stack.Push(states["A3"]);
            var imList = ImmutableList.Create(states["A1"], states["A2"], states["A3"]);
            var ll     = new LlConfiguration <CharSymbol>(chSym, imList);

            Assert.AreEqual(stack, ll.copyOfStack());
        }
Exemple #21
0
        public void LLConfSubsumesFalseTest()
        {
            CharSymbol chSym = new CharSymbol('A');
            var        llA   = new LlConfiguration <CharSymbol>(chSym);
            var        llB   = new LlConfiguration <CharSymbol>(chSym);

            llA = llA.Push(states["B2"]).Push(states["A3"]);
            llB = llB.Push(states ["A1"]).Push(states ["A2"]).Push(states ["A3"]);

            bool result = llA.Subsumes(llB);

            Assert.AreEqual(false, result);
        }