Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
        }
Exemplo 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);
     }
 }
Exemplo 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);
        }
Exemplo 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);
     }
 }
Exemplo n.º 11
0
 public void TestEmptyString()
 {
     try
     {
         var obj = MathFunc.Eval(MathFunc.Parsing(TL.Scan(" ")));
     }
     catch (Exception ae)
     {
         Assert.AreEqual("Empty String", ae.Message);
     }
 }
Exemplo 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);
     }
 }
Exemplo 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);
        }
Exemplo n.º 14
0
        public void TestWholeDivision()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("5684/4")));

            Assert.AreEqual("1421", output);
        }
Exemplo 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);
        }
Exemplo n.º 16
0
        public void TestDecimalSin()
        {
            var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("sin(0.5)")));

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

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

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

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

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

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

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

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

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

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

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

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

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

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