Exemplo n.º 1
0
        public void powerOperator()
        {
            RPN     test = new RPN("(2/2)^1").Compute();
            PostFix math = new PostFix(test);

            Assert.AreEqual(1, math.Compute());
        }
Exemplo n.º 2
0
        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());
        }
Exemplo n.º 3
0
        public void GCD()
        {
            RPN test = new RPN("gcd(123,277)").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(1, math.Compute());
        }
Exemplo n.º 4
0
        public void ComplexIncrement()
        {
            RPN test = new RPN("2++ + 2 + 2").Compute();

            PostFix math = new PostFix(test.Data);

            Assert.AreEqual(7, math.Compute());
        }
Exemplo n.º 5
0
        public void SqrtSubtraction()
        {
            RPN test = new RPN("sqrt(-1) - sqrt(-1)").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(double.NaN, math.Compute());
        }
Exemplo n.º 6
0
        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());
        }
Exemplo n.º 7
0
        public void UnarySubtract()
        {
            RPN test = new RPN("-2 + 4").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(2, math.Compute());
        }
Exemplo n.º 8
0
        public void Abs()
        {
            RPN test = new RPN("abs(-1)").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(1, math.Compute());
        }
Exemplo n.º 9
0
        public void SqrtReduction()
        {
            RPN test = new RPN("sqrt(-1)^2").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(-1, math.Compute());
        }
Exemplo n.º 10
0
        public void Increment()
        {
            RPN test = new RPN("7++").Compute();

            PostFix math = new PostFix(test.Data);

            Assert.AreEqual(8, math.Compute());
        }
Exemplo n.º 11
0
        public void Arccos()
        {
            RPN test = new RPN("arccos( cos(pi/2) )").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(Math.PI / 2, math.Compute());
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
        public void Min()
        {
            RPN test = new RPN("min(0, 1)").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(0, math.Compute());
        }
Exemplo n.º 14
0
        public void VardiacCompositeConstants()
        {
            RPN test = new RPN("sin( max(2,3,4) * pi )").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(0, math.Compute());
        }
Exemplo n.º 15
0
        public void VardiacComposite()
        {
            RPN test = new RPN("sin(min (0, 1) )").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(0, math.Compute());
        }
Exemplo n.º 16
0
        public void VardiacMin()
        {
            RPN test = new RPN("min(1, 2, 3)").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(1, math.Compute());
        }
Exemplo n.º 17
0
        public void Mod()
        {
            RPN test = new RPN("5 % 2").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(1, math.Compute());
        }
Exemplo n.º 18
0
        public void Arctan()
        {
            RPN test = new RPN("arctan( tan(pi/4) )").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(Math.PI / 4, math.Compute());
        }
Exemplo n.º 19
0
        public void LCM()
        {
            RPN test = new RPN("lcm(1000,625)").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(5000, math.Compute());
        }
Exemplo n.º 20
0
        public void DivideByZero()
        {
            RPN test = new RPN("1/0").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(double.NaN, math.Compute());
        }
Exemplo n.º 21
0
        public void LN()
        {
            RPN test = new RPN("ln(e)").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(1, math.Compute());
        }
Exemplo n.º 22
0
        public void ExponentianOperator()
        {
            RPN test = new RPN("1E3").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(1000, math.Compute());
        }
Exemplo n.º 23
0
        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());
        }
Exemplo n.º 24
0
        public void UnarySubtract2()
        {
            RPN test = new RPN("5 + -2").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(3, math.Compute());
        }
Exemplo n.º 25
0
        public void VardiacImplicitMultiplication2()
        {
            RPN test = new RPN("total(1,4,5)3").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(30, math.Compute());
        }
Exemplo n.º 26
0
        public void Factorial()
        {
            RPN test = new RPN("5!").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(120, math.Compute());
        }
Exemplo n.º 27
0
        public void Substract()
        {
            RPN test = new RPN("5 - 2").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(3, math.Compute());
        }
Exemplo n.º 28
0
        public void Round()
        {
            RPN test = new RPN("round(pi,2)").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(3.14, math.Compute());
        }
Exemplo n.º 29
0
        public void UnaryDecimal()
        {
            RPN test = new RPN("-.5 + .5").Compute();

            PostFix math = new PostFix(test);

            Assert.AreEqual(0, math.Compute());
        }
Exemplo n.º 30
0
        public void CompositeFunctions()
        {
            RPN test = new RPN("max( sqrt( 16 ) , 100)").Compute();

            PostFix math = new PostFix(test);

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