Example #1
0
        public void TestAddMultPriority()
        {
            var dumpVisitor = new DumpVisitor();

            SimpleParser.Parse("1*(2+3)").Accept(dumpVisitor);
            Assert.AreEqual("Binary(Literal(1)*Paren(Binary(Literal(2)+Literal(3))))", dumpVisitor.ToString());
            Assert.Pass();
        }
Example #2
0
        public void TestRightPriority()
        {
            var dumpVisitor = new DumpVisitor();

            SimpleParser.Parse("1+(3+(5+7))").Accept(dumpVisitor);
            Assert.AreEqual("Binary(Literal(1)+Paren(Binary(Literal(3)+Paren(Binary(Literal(5)+Literal(7))))))", dumpVisitor.ToString());
            Assert.Pass();
        }
Example #3
0
        public void TestHardCombination()
        {
            var dumpVisitor = new DumpVisitor();

            SimpleParser.Parse("1*2+3*4*5").Accept(dumpVisitor);
            Assert.AreEqual("Binary(Binary(Literal(1)*Literal(2))+Binary(Binary(Literal(3)*Literal(4))*Literal(5)))", dumpVisitor.ToString());
            Assert.Pass();
        }
Example #4
0
        public void TestAdd()
        {
            var dumpVisitor = new DumpVisitor();

            SimpleParser.Parse("1+2").Accept(dumpVisitor);
            Assert.AreEqual("Binary(Literal(1)+Literal(2))", dumpVisitor.ToString());

            Assert.Pass();
        }
Example #5
0
        public void TestMinusDivide()
        {
            var dumpVisitor = new DumpVisitor();

            SimpleParser.Parse("5-5/5").Accept(dumpVisitor);
            Assert.AreEqual("Binary(Literal(5)-Binary(Literal(5)/Literal(5)))", dumpVisitor.ToString());

            Assert.Pass();
        }
Example #6
0
        public void TestMinus()
        {
            var dumpVisitor = new DumpVisitor();

            SimpleParser.Parse("9-3").Accept(dumpVisitor);
            Assert.AreEqual("Binary(Literal(9)-Literal(3))", dumpVisitor.ToString());

            Assert.Pass();
        }
Example #7
0
        public void TestNestedBracketsBeforeLiteral()
        {
            var dumpVisitor = new DumpVisitor();

            SimpleParser.Parse("(1+(2+3))*2").Accept(dumpVisitor);
            Assert.AreEqual(
                "Binary(Paren(Binary(Literal(1)+Paren(Binary(Literal(2)+Literal(3)))))*Literal(2))",
                dumpVisitor.ToString());
            Assert.Pass();
        }
Example #8
0
        public void TestHardCombination()
        {
            var dumpVisitor = new DumpVisitor();

            SimpleParser.Parse("1+((2+3)/4+7)*5").Accept(dumpVisitor);
            Console.Write(dumpVisitor.ToString());
            Assert.AreEqual(
                "Binary(Literal(1)+" +
                "Binary(Paren(Binary(Binary(Paren(Binary(Literal(2)+Literal(3)))/Literal(4))+Literal(7)))*Literal(5)))",
                dumpVisitor.ToString());
            Assert.Pass();
        }
Example #9
0
        public void TestNestedBracketsAfterLiteral()
        {
            var dumpVisitor = new DumpVisitor();

            SimpleParser.Parse("2*(1/2+(2+3))").Accept(dumpVisitor);
            Assert.AreEqual(
                "Binary(Literal(2)" +
                "*Paren(Binary(Binary(Literal(1)/Literal(2))+Paren(Binary(Literal(2)+Literal(3))))))",

                dumpVisitor.ToString());
            Assert.Pass();
        }