示例#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);
        }