public void EqualNullNotNull()
        {
            var lexpr = new ConstantExpression(null);
            var rexpr = new ConstantExpression(42);
            var expr  = new BinaryOperatorExpression(BinaryOperator.Equal, lexpr, rexpr);

            Assert.AreEqual(false, expr.Evaluate(null));
        }
        public void DivideIntegers()
        {
            var lexpr = new ConstantExpression(84);
            var rexpr = new ConstantExpression(2);
            var expr  = new BinaryOperatorExpression(BinaryOperator.Divide, lexpr, rexpr);

            Assert.AreEqual(42.0, expr.Evaluate(null));
        }
        public void EqualInteger()
        {
            var lexpr = new ConstantExpression(42);
            var rexpr = new ConstantExpression(42);
            var expr  = new BinaryOperatorExpression(BinaryOperator.Equal, lexpr, rexpr);

            Assert.AreEqual(true, expr.Evaluate(null));
        }
        public void SubtractIntegers()
        {
            var lexpr = new ConstantExpression(44);
            var rexpr = new ConstantExpression(2);
            var expr  = new BinaryOperatorExpression(BinaryOperator.Subtract, lexpr, rexpr);

            Assert.AreEqual(42, expr.Evaluate(null));
        }
        public void MultiplyIntegers()
        {
            var lexpr = new ConstantExpression(21);
            var rexpr = new ConstantExpression(2);
            var expr  = new BinaryOperatorExpression(BinaryOperator.Multiply, lexpr, rexpr);

            Assert.AreEqual(42, expr.Evaluate(null));
        }
        public void GreaterInteger()
        {
            var lexpr = new ConstantExpression(42);
            var rexpr = new ConstantExpression(42);
            var expr  = new BinaryOperatorExpression(BinaryOperator.Greater, lexpr, rexpr);

            Assert.AreEqual(false, expr.Evaluate(null));
        }
Пример #7
0
        public void EvaluateMultiplyExpression()
        {
            BinaryExpression expression = new BinaryOperatorExpression(new ConstantExpression(2), new ConstantExpression(3), BinaryOperator.Multiply);

            Assert.IsNotNull(expression);
            Assert.IsNotNull(expression.Left);
            Assert.IsNotNull(expression.Right);

            Assert.AreEqual(6, expression.Evaluate(new BindingEnvironment()));
        }
Пример #8
0
        public void EvaluateSubtractExpression()
        {
            BinaryExpression expression = new BinaryOperatorExpression(new ConstantExpression(1), new ConstantExpression(2), BinaryOperator.Subtract);

            Assert.IsNotNull(expression);
            Assert.IsNotNull(expression.Left);
            Assert.IsNotNull(expression.Right);

            Assert.AreEqual(-1, expression.Evaluate(new BindingEnvironment()));
        }
Пример #9
0
        public void EvaluateDivideExpression()
        {
            BinaryExpression expression = new BinaryOperatorExpression(new ConstantExpression(6), new ConstantExpression(3), BinaryOperator.Divide);

            Assert.IsNotNull(expression);
            Assert.IsNotNull(expression.Left);
            Assert.IsNotNull(expression.Right);

            Assert.AreEqual(2, expression.Evaluate(new BindingEnvironment()));
        }
        public void EvaluateMultiplyExpressionWithLeftString()
        {
            BinaryExpression expression = new BinaryOperatorExpression(new ConstantExpression("spam"), new ConstantExpression(3), BinaryOperator.Multiply);

            Assert.IsNotNull(expression);
            Assert.IsNotNull(expression.Left);
            Assert.IsNotNull(expression.Right);

            Assert.AreEqual("spamspamspam", expression.Evaluate(new BindingEnvironment()));
        }
        public void EvaluateDivideToFloatExpression()
        {
            BinaryExpression expression = new BinaryOperatorExpression(new ConstantExpression(4), new ConstantExpression(5), BinaryOperator.Divide);

            Assert.IsNotNull(expression);
            Assert.IsNotNull(expression.Left);
            Assert.IsNotNull(expression.Right);

            Assert.AreEqual(0.8, expression.Evaluate(new BindingEnvironment()));
        }
        public void EvaluateAddExpression()
        {
            BinaryExpression expression = new BinaryOperatorExpression(new ConstantExpression(1), new ConstantExpression(2), BinaryOperator.Add);

            Assert.IsNotNull(expression);
            Assert.IsNotNull(expression.Left);
            Assert.IsNotNull(expression.Right);

            Assert.AreEqual(3, expression.Evaluate(new BindingEnvironment()));
        }