Пример #1
0
        public void CalculateLessTrueTest()
        {
            var parameters = new ParameterCollection() { new Parameter("x", 0) };
            var lessThen = new LessThan(new Variable("x"), new Number(10));

            Assert.AreEqual(true, lessThen.Calculate(parameters));
        }
Пример #2
0
        public void CalculateLessFalseTest()
        {
            var parameters = new ParameterCollection() { new Parameter("x", 10) };
            var lessThen = new LessThan(new Variable("x"), new Number(10));

            Assert.Equal(false, lessThen.Execute(parameters));
        }
Пример #3
0
        public void CalculateOrTrueTest2()
        {
            var parameters = new ParameterCollection() { new Parameter("x", 0) };
            var lessThen = new LessThan(new Variable("x"), new Number(-10));
            var greaterThen = new GreaterThan(new Variable("x"), new Number(-10));
            var or = new Or(lessThen, greaterThen);

            Assert.AreEqual(true, or.Calculate(parameters));
        }
Пример #4
0
        public void CalculateAndTrueTest()
        {
            var parameters = new ParameterCollection() { new Parameter("x", 0) };
            var lessThen = new LessThan(new Variable("x"), new Number(10));
            var greaterThen = new GreaterThan(new Variable("x"), new Number(-10));
            var and = new And(lessThen, greaterThen);

            Assert.AreEqual(true, and.Calculate(parameters));
        }
Пример #5
0
        public void CalculateWhileTest()
        {
            var parameters = new ExpressionParameters();
            parameters.Variables.Add(new Parameter("x", 0));

            var body = new Define(new Variable("x"), new Add(new Variable("x"), new Number(2)));
            var cond = new LessThan(new Variable("x"), new Number(10));

            var @while = new While(body, cond);
            @while.Execute(parameters);

            Assert.Equal(10.0, parameters.Variables["x"]);
        }
Пример #6
0
        public void CalculateForTest()
        {
            var parameters = new ExpressionParameters();

            var init = new Define(new Variable("i"), new Number(0));
            var cond = new LessThan(new Variable("i"), new Number(10));
            var iter = new Define(new Variable("i"), new Add(new Variable("i"), new Number(1)));

            var @for = new For(new Variable("i"), init, cond, iter);
            @for.Execute(parameters);

            Assert.Equal(10.0, parameters.Variables["i"]);
        }