public void ExtraOperatorError() { var s = "('Var1' 'Var2')"; try { var eval = new NoSymEval(); eval.Evaluate(s); Assert.Fail("Expression should produce symbol error"); } catch (Exception e) { Assert.IsTrue(e is InvalidOperationException, "Unexpected " + e.ToString()); } }
public void CurrentValueTest() { var s = "(1.2+'V2')"; try { var eval = new NoSymEval(); eval.Evaluate(s); Assert.AreEqual(eval.currentValueList.Count, 1); Assert.AreEqual(eval.currentValueList[0], 1.2); } catch (Exception e) { Assert.IsTrue(e is InvalidOperationException, "Unexpected " + e.ToString()); } }
public void ExtraBrackets() { var s = "(((202)+11+2"; try { var eval = new NoSymEval(); eval.Evaluate(s); Assert.Fail("Extra bracket not detected"); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); Assert.IsTrue(e is InvalidOperationException, "Unexpected " + e.ToString()); Assert.IsTrue(e.Message.Contains("2 missing"), "Error message should contain '2 missing'"); } }
public void SpaceInNumber() { var s = "202+ 1 1 + 2"; try { var eval = new NoSymEval(); eval.Evaluate(s); Assert.AreEqual(eval.currentValueList.Count, 1); Assert.AreEqual(eval.currentValueList[0], 1.2); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); Assert.IsTrue(e is InvalidOperationException, "Unexpected " + e.ToString()); } }