コード例 #1
0
        public void Complex_Expression()
        {
            const int expected = ((3 + 5*6/2) - 8);

            var expression =
                new Substraction(
                    new Addition(
                        new Number(3),
                        new Multiplication(
                            new Number(5),
                            new Division(
                                new Number(6),
                                new Number(2)))),
                    new Number(8));

            AssertExpression(expression, expected);
        }
コード例 #2
0
        public void Test_Complex_Expression()
        {
            const string expected = "( ( 3 + 5 * 2 / 6 ) - 8 )";

            var expression =
                new Substraction(
                    new Addition(
                        new Number(3),
                        new Multiplication(
                            new Number(5),
                            new Division(
                                new Number(2),
                                new Number(6)))),
                    new Number(8));

            AssertExpression(expression, expected);
        }
コード例 #3
0
        public static void Visitor()
        {
            //"( ( 3 + 5 * 2 / 6 ) - 8 )"
            var expression =
                new Substraction(
                    new Addition(
                        new Number(3),
                        new Multiplication(
                            new Number(5),
                            new Division(
                                new Number(2),
                                new Number(6)))),
                    new Number(8));
            var visitor = new ToTextVisitor();
            expression.Accpet(visitor);
            string expressionText = visitor.GetResult();

            Console.WriteLine(expressionText);
        }
コード例 #4
0
 public void VisitSubstraction(Substraction expression)
 {
     VisitBinary(
         (left, right) => left - right);
 }
コード例 #5
0
        public void Simple_Substraction()
        {
            const int expected = (6 - 2);

            var expression =
                new Substraction(
                    new Number(6),
                    new Number(2));

            AssertExpression(expression, expected);
        }
コード例 #6
0
 public void VisitSubstraction(Substraction expression)
 {
     VisitBinary("( {0} - {1} )");
 }
コード例 #7
0
 public void VisitSubstraction(Substraction expression)
 {
     VisitBinary(
         (left, right) => left - right);
 }
コード例 #8
0
 public void VisitSubstraction(Substraction expression)
 {
     VisitBinary("( {0} - {1} )");
 }