示例#1
0
        public void Simplify_OperatorChildrenAreBothNumbers_ReturnsNumberNode()
        {
            SyntaxNode node = GetExpression("2 + 2", new Environment());

            node = OperatorSimplification.Simplify((OperatorNode)node, new Environment());

            Assert.NotNull(node);
            Assert.AreEqual("4", node.ToString());
        }
示例#2
0
        public void Simplify_NestedAlgebraicOperator_ReturnsOperatorNode()
        {
            Environment environment = new Environment();

            environment.AddSymbol("x");
            SyntaxNode node = GetExpression("3 * x + 2 * x", environment);

            node = OperatorSimplification.Simplify((OperatorNode)node, environment);

            Assert.NotNull(node);
            Assert.AreEqual("5 * x", node.ToString());
        }
示例#3
0
        public void Simplify_OperatorChildrenAreBothTheSameIdentifier_ReturnsOperatorNode()
        {
            Environment environment = new Environment();

            environment.AddSymbol("x");
            SyntaxNode node = GetExpression("x + x", environment);

            node = OperatorSimplification.Simplify((OperatorNode)node, environment);

            Assert.NotNull(node);
            Assert.AreEqual("2 * x", node.ToString());
        }
示例#4
0
        public void Simplify_OperatorWithNumberAndFunction_ReturnsOperatorNode()
        {
            Environment environment = new Environment();

            environment.AddSymbol("x");
            environment.AddFunction("f", GetExpression("x", environment));
            SyntaxNode node = GetExpression("2 + f(x)", environment);

            node = OperatorSimplification.Simplify((OperatorNode)node, environment);

            Assert.NotNull(node);
            Assert.AreEqual("2 + f(x)", node.ToString());
        }