Пример #1
0
        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());
            }
        }
Пример #2
0
        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());
            }
        }
Пример #3
0
        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'");
            }
        }
Пример #4
0
        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());
            }
        }