示例#1
0
        public void Alias2()
        {
            var compiler = new RPNExpression("4/12*100+([:A]*[B])");

            Console.WriteLine("Source string: " + compiler.GetSourceString());
            var RPNString = compiler.Prepare();

            Console.WriteLine($"RPNString : {RPNString}");

            var arg = compiler.GetCalcArguments();

            foreach (var p in arg)
            {
                Console.WriteLine("argument:  <" + p + ">");
            }

            List <RPNArguments> arguments = new List <RPNArguments>();

            arguments.Add(new RPNArguments("[:A]", 2));
            arguments.Add(new RPNArguments("[B]", 7));
            var rezult = compiler.Calculate(arguments).ToString();

            Console.WriteLine("Rezult  " + rezult);
            Assert.IsTrue("47.3333333333333" == rezult);
        }
示例#2
0
        public void SimpleString()
        {
            var compiler = new RPNExpression("'aaaaa'");

            Console.WriteLine("Source string: " + compiler.GetSourceString());
            var RPNString = compiler.Prepare();

            Console.WriteLine($"RPNString : {RPNString}");
            var rezult = compiler.Calculate().ToString();

            Console.WriteLine("Rezult  " + rezult);
            Assert.IsTrue(rezult.Equals("aaaaa"));
        }
示例#3
0
        public void JustMinus4()
        {
            var compiler = new RPNExpression("-(-11+12)");

            Console.WriteLine("Source string: " + compiler.GetSourceString());
            var RPNString = compiler.Prepare();

            Console.WriteLine($"RPNString : {RPNString}");

            var rezult = compiler.Calculate().ToString();

            Console.WriteLine("Rezult  " + rezult);
        }
示例#4
0
        public static void TestExpression(string sourceString, string verify = null)
        {
            var compiler = new RPNExpression(sourceString);

            Console.WriteLine("Source string: " + compiler.GetSourceString());
            var RPNString = compiler.Prepare();

            Console.WriteLine($"RPNString : {RPNString}");
            var rezult = compiler.Calculate().ToString();

            Console.WriteLine("Rezult  " + rezult);
            if (verify != null)
            {
                Console.WriteLine("verify  " + verify);
                Assert.IsTrue(rezult.ToString().Equals(verify.ToString()));
            }
        }