Esempio n. 1
0
        public void TestVariableMultiplication()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("10a")),
                                       new Dictionary <char, string> {
                { 'a', "2" }
            }
                                       );

            Assert.AreEqual("20", output);
        }
Esempio n. 2
0
        public void TestVariablePow()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("pow(2,a)")),
                                       new Dictionary <char, string> {
                { 'a', "2" }
            }
                                       );

            Assert.AreEqual("4", output);
        }
Esempio n. 3
0
        public void TestVariableComplement()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("~a")),
                                       new Dictionary <char, string> {
                { 'a', "5" }
            }
                                       );

            Assert.AreEqual("-6", output);
        }
Esempio n. 4
0
        public void TestMixture1()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("12+(0.5*a)-1")),
                                       new Dictionary <char, string> {
                { 'a', "2" }
            }
                                       );

            Assert.AreEqual("12", output);
        }
Esempio n. 5
0
        public void TestVariableXor()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("10^a")),
                                       new Dictionary <char, string> {
                { 'a', "5" }
            }
                                       );

            Assert.AreEqual("15", output);
        }
Esempio n. 6
0
        public void TestMixture5()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("a*5+(a/3)")),
                                       new Dictionary <char, string>
            {
                { 'a', "6" }
            });

            Assert.AreEqual("32", output);
        }
Esempio n. 7
0
        public void TestMixture6()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("a*2 - (-1)")),
                                       new Dictionary <char, string>
            {
                { 'a', "0.5" }
            });

            Assert.AreEqual("2", output);
        }
Esempio n. 8
0
 public void TestDecimalOnesCompl()
 {
     try
     {
         var obj = MathFunc.Eval(MathFunc.Parsing(TL.Scan("~0.5")));
     }
     catch (Exception ae)
     {
         Assert.AreEqual("Math Error: decimal numbers are incompatible with logic operations", ae.Message);
     }
 }
Esempio n. 9
0
        public void TestMixture4()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("pow(2,3)-sin(45)+5b")),
                                       new Dictionary <char, string>
            {
                { 'b', "2" }
            }
                                       );

            Assert.AreEqual("17.149096475465882", output);
        }
Esempio n. 10
0
 public void TestInvalidSymbol()
 {
     try
     {
         var obj = MathFunc.Eval(MathFunc.Parsing(TL.Scan("#")));
     }
     catch (Exception ae)
     {
         Assert.AreEqual("Unknown symbol while tokenizing", ae.Message);
     }
 }
Esempio n. 11
0
 public void TestEmptyString()
 {
     try
     {
         var obj = MathFunc.Eval(MathFunc.Parsing(TL.Scan(" ")));
     }
     catch (Exception ae)
     {
         Assert.AreEqual("Empty String", ae.Message);
     }
 }
Esempio n. 12
0
 public void TestDecimalXor()
 {
     try
     {
         var obj = MathFunc.Eval(MathFunc.Parsing(TL.Scan("0.5^0.2")));
     }
     catch (Exception ae)
     {
         Assert.AreEqual("Invalid antiunitary operation", ae.Message);
     }
 }
Esempio n. 13
0
        public void TestMixture2()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("a+b-c*(d/e)")),
                                       new Dictionary <char, string>
            {
                { 'a', "2" },
                { 'b', "4" },
                { 'c', "7" },
                { 'd', "4" },
                { 'e', "2" }
            });

            Assert.AreEqual("-8", output);
        }
Esempio n. 14
0
        public void TestWholeDivision()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("5684/4")));

            Assert.AreEqual("1421", output);
        }
Esempio n. 15
0
        public void TestDecimalBrackets()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("0.5*(1.5-0.3)")));

            Assert.AreEqual("0.6", output);
        }
Esempio n. 16
0
        public void TestDecimalSin()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("sin(0.5)")));

            Assert.AreEqual("0.479425538604203", output);
        }
Esempio n. 17
0
        public void TestDecimalCos()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("cos(0.5)")));

            Assert.AreEqual("0.8775825618903728", output);
        }
Esempio n. 18
0
        public void TestDecimalTan()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("tan(0.5)")));

            Assert.AreEqual("0.5463024898437905", output);
        }
Esempio n. 19
0
        public void TestDecimalDivision()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("1.6/0.5")));

            Assert.AreEqual("3.2", output);
        }
Esempio n. 20
0
        public void TestWholeSubstraction()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("1000-999")));

            Assert.AreEqual("1", output);
        }
Esempio n. 21
0
 public void TestWholeNumber()
 {
     Assert.AreEqual("1", MathFunc.Eval(MathFunc.Parsing(TL.Scan("1"))));
 }
Esempio n. 22
0
        public void TestDecimalZero()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("0*0.55")));

            Assert.AreEqual("0", output);
        }
Esempio n. 23
0
        public void TestDecimalNegative()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("-0.5+1")));

            Assert.AreEqual("0.5", output);
        }
Esempio n. 24
0
        public void TestDecimalPow()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("pow(0.5,0.3)")));

            Assert.AreEqual("0.8122523963562356", output);
        }
Esempio n. 25
0
        public void TestWholeAddition()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("25+32")));

            Assert.AreEqual("57", output);
        }
Esempio n. 26
0
        public void TestDeciamlSubstraction()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("0.6-0.4")));

            Assert.AreEqual("0.2", output);
        }
Esempio n. 27
0
        public void TestWholeMult()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("122*14")));

            Assert.AreEqual("1708", output);
        }
Esempio n. 28
0
        public void TestDecimalMult()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("0.4*0.5")));

            Assert.AreEqual("0.2", output);
        }
Esempio n. 29
0
        public void TestWholeBrackets()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("2*(4-3)")));

            Assert.AreEqual("2", output);
        }
Esempio n. 30
0
        public void TestDecimalAddition()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("0.25+0.5")));

            Assert.AreEqual("0.75", output);
        }