Пример #1
0
        public void TestVariables()
        {
            Evaluator e = new Evaluator();
            e.SetVariable("daughter1", "Vivian");
            Assert.AreEqual("Vivian", e.GetVariable("daughter1").As<string>());

            e.Evaluate("let daughter2 = \"Lillian\"");
            Assert.AreEqual("Lillian", e.GetVariable("daughter2").As<string>());

            e.Evaluate("let daughter1 = daughter2");
            Assert.AreEqual("Lillian", e.GetVariable("daughter1").As<string>());

            e.Evaluate("let boingBoing = 1");
            Assert.AreEqual(1, e.Evaluate("boingBoing").As<int>());
            e.Evaluate("unlet boingBoing"); // god forbid!
            Assert.IsFalse(e.HasVariable("boingBoing"));
        }