示例#1
0
文件: PostFix.cs 项目: 65001/AbMath
        public void powerOperator()
        {
            RPN     test = new RPN("(2/2)^1").Compute();
            PostFix math = new PostFix(test);

            Assert.AreEqual(1, math.Compute());
        }
示例#2
0
文件: PostFix.cs 项目: 65001/AbMath
        public void GreaterThan()
        {
            RPN test = new RPN("5 > 2").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(1, math.Compute());

            test.SetEquation("5 > 10").Compute();

            math = new PostFix(test);
            Assert.AreEqual(0, math.Compute());

            test.SetEquation("5 >= 5").Compute();

            math = new PostFix(test);
            Assert.AreEqual(1, math.Compute());

            test.SetEquation("15 >= 5").Compute();

            math = new PostFix(test);
            Assert.AreEqual(1, math.Compute());

            test.SetEquation("5 >= 15").Compute();

            math = new PostFix(test);
            Assert.AreEqual(0, math.Compute());
        }
示例#3
0
文件: PostFix.cs 项目: 65001/AbMath
        public void GCD()
        {
            RPN test = new RPN("gcd(123,277)").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(1, math.Compute());
        }
示例#4
0
文件: PostFix.cs 项目: 65001/AbMath
        public void ComplexIncrement()
        {
            RPN test = new RPN("2++ + 2 + 2").Compute();

            PostFix math = new PostFix(test.Data);

            Assert.AreEqual(7, math.Compute());
        }
示例#5
0
文件: PostFix.cs 项目: 65001/AbMath
        public void SqrtSubtraction()
        {
            RPN test = new RPN("sqrt(-1) - sqrt(-1)").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(double.NaN, math.Compute());
        }
示例#6
0
文件: PostFix.cs 项目: 65001/AbMath
        public void VardiacUltimateStressTest()
        {
            RPN test = new RPN("total( sqrt(16), min(0,1), pi, sin(2pi), max(1,2,3), avg(10,5,7,9) ) - total( sqrt(16), min(0,1), pi, sin(2pi), max(1,2,3), avg(10,5,7,9) )").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(0, math.Compute());
        }
示例#7
0
文件: PostFix.cs 项目: 65001/AbMath
        public void UnarySubtract()
        {
            RPN test = new RPN("-2 + 4").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(2, math.Compute());
        }
示例#8
0
文件: PostFix.cs 项目: 65001/AbMath
        public void Abs()
        {
            RPN test = new RPN("abs(-1)").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(1, math.Compute());
        }
示例#9
0
文件: PostFix.cs 项目: 65001/AbMath
        public void SqrtReduction()
        {
            RPN test = new RPN("sqrt(-1)^2").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(-1, math.Compute());
        }
示例#10
0
文件: PostFix.cs 项目: 65001/AbMath
        public void Increment()
        {
            RPN test = new RPN("7++").Compute();

            PostFix math = new PostFix(test.Data);

            Assert.AreEqual(8, math.Compute());
        }
示例#11
0
文件: PostFix.cs 项目: 65001/AbMath
        public void Arccos()
        {
            RPN test = new RPN("arccos( cos(pi/2) )").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(Math.PI / 2, math.Compute());
        }
示例#12
0
文件: PostFix.cs 项目: 65001/AbMath
        public void VardiacConstantAdd()
        {
            var foo = new RPN("pi(2) + e(2)").Compute();

            PostFix math = new PostFix(foo);

            Assert.AreEqual(11.7197489640976, math.Compute(), 0.00001);
        }
示例#13
0
文件: PostFix.cs 项目: 65001/AbMath
        public void Min()
        {
            RPN test = new RPN("min(0, 1)").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(0, math.Compute());
        }
示例#14
0
文件: PostFix.cs 项目: 65001/AbMath
        public void VardiacCompositeConstants()
        {
            RPN test = new RPN("sin( max(2,3,4) * pi )").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(0, math.Compute());
        }
示例#15
0
文件: PostFix.cs 项目: 65001/AbMath
        public void VardiacComposite()
        {
            RPN test = new RPN("sin(min (0, 1) )").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(0, math.Compute());
        }
示例#16
0
文件: PostFix.cs 项目: 65001/AbMath
        public void VardiacMin()
        {
            RPN test = new RPN("min(1, 2, 3)").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(1, math.Compute());
        }
示例#17
0
文件: PostFix.cs 项目: 65001/AbMath
        public void Mod()
        {
            RPN test = new RPN("5 % 2").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(1, math.Compute());
        }
示例#18
0
文件: PostFix.cs 项目: 65001/AbMath
        public void Arctan()
        {
            RPN test = new RPN("arctan( tan(pi/4) )").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(Math.PI / 4, math.Compute());
        }
示例#19
0
文件: PostFix.cs 项目: 65001/AbMath
        public void LCM()
        {
            RPN test = new RPN("lcm(1000,625)").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(5000, math.Compute());
        }
示例#20
0
文件: PostFix.cs 项目: 65001/AbMath
        public void DivideByZero()
        {
            RPN test = new RPN("1/0").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(double.NaN, math.Compute());
        }
示例#21
0
文件: PostFix.cs 项目: 65001/AbMath
        public void LN()
        {
            RPN test = new RPN("ln(e)").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(1, math.Compute());
        }
示例#22
0
文件: PostFix.cs 项目: 65001/AbMath
        public void ExponentianOperator()
        {
            RPN test = new RPN("1E3").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(1000, math.Compute());
        }
示例#23
0
文件: PostFix.cs 项目: 65001/AbMath
        public void Distance()
        {
            RPN test = new RPN("sqrt(2^2 + 8^2)").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(Math.Sqrt(68), math.Compute());
        }
示例#24
0
文件: PostFix.cs 项目: 65001/AbMath
        public void UnarySubtract2()
        {
            RPN test = new RPN("5 + -2").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(3, math.Compute());
        }
示例#25
0
文件: PostFix.cs 项目: 65001/AbMath
        public void VardiacImplicitMultiplication2()
        {
            RPN test = new RPN("total(1,4,5)3").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(30, math.Compute());
        }
示例#26
0
文件: PostFix.cs 项目: 65001/AbMath
        public void Factorial()
        {
            RPN test = new RPN("5!").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(120, math.Compute());
        }
示例#27
0
文件: PostFix.cs 项目: 65001/AbMath
        public void Substract()
        {
            RPN test = new RPN("5 - 2").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(3, math.Compute());
        }
示例#28
0
文件: PostFix.cs 项目: 65001/AbMath
        public void Round()
        {
            RPN test = new RPN("round(pi,2)").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(3.14, math.Compute());
        }
示例#29
0
文件: PostFix.cs 项目: 65001/AbMath
        public void UnaryDecimal()
        {
            RPN test = new RPN("-.5 + .5").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(0, math.Compute());
        }
示例#30
0
文件: PostFix.cs 项目: 65001/AbMath
        public void CompositeFunctions()
        {
            RPN test = new RPN("max( sqrt( 16 ) , 100)").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(100, math.Compute());
        }