Exemple #1
0
        public void OverrideConstTest()
        {
            var exp        = new Define(new Variable("π"), new Number(1));
            var parameters = new ExpressionParameters();

            exp.Execute(parameters);

            Assert.Equal(1.0, parameters.Variables["π"]);
        }
Exemple #2
0
        public void DefineExpTest()
        {
            var exp        = new Define(Variable.X, new Mul(new Number(4), new Add(new Number(8), new Number(1))));
            var parameters = new ExpressionParameters();

            var answer = exp.Execute(parameters);

            Assert.Equal(36.0, parameters.Variables["x"]);
            Assert.Equal("The value '4 * (8 + 1)' was assigned to the variable 'x'.", answer);
        }
Exemple #3
0
        public void SimpDefineTest()
        {
            var exp        = new Define(Variable.X, new Number(1));
            var parameters = new ExpressionParameters();

            var answer = exp.Execute(parameters);

            Assert.Equal(1.0, parameters.Variables["x"]);
            Assert.Equal("The value '1' was assigned to the variable 'x'.", answer);
        }
Exemple #4
0
        public void DefineWithFuncTest()
        {
            var exp        = new Define(Variable.X, new Sin(new Number(1)));
            var parameters = new ParameterCollection();
            var expParams  = new ExpressionParameters(AngleMeasurement.Radian, parameters);

            var answer = exp.Execute(expParams);

            Assert.Equal(Math.Sin(1), parameters["x"]);
            Assert.Equal("The value 'sin(1)' was assigned to the variable 'x'.", answer);
        }
Exemple #5
0
        public void DefineFuncWithParamsTest()
        {
            var uf         = new UserFunction("s", 1);
            var func       = new Sin(Variable.X);
            var exp        = new Define(uf, func);
            var parameters = new ExpressionParameters();

            var result = exp.Execute(parameters);

            Assert.Equal(func, parameters.Functions[uf]);
            Assert.Equal("The expression 'sin(x)' was assigned to the function 's(x1)'.", result);
        }
Exemple #6
0
        public void DefineFuncTest()
        {
            var uf         = new UserFunction("s", new IExpression[0], 0);
            var func       = new Sin(new Number(1));
            var exp        = new Define(uf, func);
            var parameters = new ExpressionParameters();

            var result = exp.Execute(parameters);

            Assert.Equal(func, parameters.Functions[uf]);
            Assert.Equal("The expression 'sin(1)' was assigned to the function 's()'.", result);
        }