Пример #1
0
        public void OverrideConstTest()
        {
            IExpression exp = new Define(new Variable("π"), new Number(1));
            ParameterCollection parameters = new ParameterCollection();

            var answer = exp.Calculate(parameters);

            Assert.AreEqual(1.0, parameters["π"]);
        }
Пример #2
0
        public void SimpDefineTest()
        {
            IExpression exp = new Define(new Variable("x"), new Number(1));
            ParameterCollection parameters = new ParameterCollection();

            var answer = exp.Calculate(parameters);

            Assert.AreEqual(1.0, parameters["x"]);
            Assert.AreEqual(double.NaN, answer);
        }
Пример #3
0
        public void DefineExpTest()
        {
            IExpression exp = new Define(new Variable("x"), new Mul(new Number(4), new Add(new Number(8), new Number(1))));
            ParameterCollection parameters = new ParameterCollection();

            var answer = exp.Calculate(parameters);

            Assert.AreEqual(36, parameters["x"]);
            Assert.AreEqual(double.NaN, answer);
        }
Пример #4
0
        public void DefineWithFuncTest()
        {
            IExpression exp = new Define(new Variable("x"), new Sin(new Number(1)));
            ParameterCollection parameters = new ParameterCollection();
            ExpressionParameters expParams = new ExpressionParameters(AngleMeasurement.Radian, parameters);

            var answer = exp.Calculate(expParams);

            Assert.AreEqual(Math.Sin(1), parameters["x"]);
            Assert.AreEqual(double.NaN, answer);
        }