public void TestVariableMultiplication() { var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("10a")), new Dictionary <char, string> { { 'a', "2" } } ); Assert.AreEqual("20", output); }
public void TestVariablePow() { var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("pow(2,a)")), new Dictionary <char, string> { { 'a', "2" } } ); Assert.AreEqual("4", output); }
public void TestVariableComplement() { var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("~a")), new Dictionary <char, string> { { 'a', "5" } } ); Assert.AreEqual("-6", output); }
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); }
public void TestVariableXor() { var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("10^a")), new Dictionary <char, string> { { 'a', "5" } } ); Assert.AreEqual("15", output); }
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); }
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); }
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); } }
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); }
public void TestInvalidSymbol() { try { var obj = MathFunc.Eval(MathFunc.Parsing(TL.Scan("#"))); } catch (Exception ae) { Assert.AreEqual("Unknown symbol while tokenizing", ae.Message); } }
public void TestEmptyString() { try { var obj = MathFunc.Eval(MathFunc.Parsing(TL.Scan(" "))); } catch (Exception ae) { Assert.AreEqual("Empty String", ae.Message); } }
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); } }
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); }
public void TestWholeDivision() { var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("5684/4"))); Assert.AreEqual("1421", output); }
public void TestDecimalBrackets() { var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("0.5*(1.5-0.3)"))); Assert.AreEqual("0.6", output); }
public void TestDecimalSin() { var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("sin(0.5)"))); Assert.AreEqual("0.479425538604203", output); }
public void TestDecimalCos() { var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("cos(0.5)"))); Assert.AreEqual("0.8775825618903728", output); }
public void TestDecimalTan() { var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("tan(0.5)"))); Assert.AreEqual("0.5463024898437905", output); }
public void TestDecimalDivision() { var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("1.6/0.5"))); Assert.AreEqual("3.2", output); }
public void TestWholeSubstraction() { var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("1000-999"))); Assert.AreEqual("1", output); }
public void TestWholeNumber() { Assert.AreEqual("1", MathFunc.Eval(MathFunc.Parsing(TL.Scan("1")))); }
public void TestDecimalZero() { var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("0*0.55"))); Assert.AreEqual("0", output); }
public void TestDecimalNegative() { var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("-0.5+1"))); Assert.AreEqual("0.5", output); }
public void TestDecimalPow() { var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("pow(0.5,0.3)"))); Assert.AreEqual("0.8122523963562356", output); }
public void TestWholeAddition() { var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("25+32"))); Assert.AreEqual("57", output); }
public void TestDeciamlSubstraction() { var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("0.6-0.4"))); Assert.AreEqual("0.2", output); }
public void TestWholeMult() { var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("122*14"))); Assert.AreEqual("1708", output); }
public void TestDecimalMult() { var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("0.4*0.5"))); Assert.AreEqual("0.2", output); }
public void TestWholeBrackets() { var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("2*(4-3)"))); Assert.AreEqual("2", output); }
public void TestDecimalAddition() { var output = MathFunc.Eval(MathFunc.Parsing(TL.Scan("0.25+0.5"))); Assert.AreEqual("0.75", output); }