Exemplo n.º 1
0
        public void EvaluateDefinedSymbol()
        {
            Symbol symbol = Symbol.Create("foo");
            Machine machine = new Machine();
            machine.Environment.SetValue(symbol.FullName, "bar");

            IExpression expression = new SymbolExpression(symbol);

            Assert.AreEqual("bar", expression.Evaluate(machine, machine.Environment));
            Assert.AreEqual(symbol, expression.Value);
        }
Exemplo n.º 2
0
        public void EvaluateUnqualifiedSymbolAsDefinedVariableInCurrentNamespace()
        {
            Symbol symbol = Symbol.Create("foo");
            Machine machine = new Machine();
            Variable variable = Variable.Intern(machine, (string) machine.Environment.GetValue(Machine.CurrentNamespaceKey), "foo");

            machine.SetVariableValue(variable, "bar");

            IExpression expression = new SymbolExpression(symbol);

            Assert.AreEqual("bar", expression.Evaluate(machine, machine.Environment));
            Assert.AreEqual(symbol, expression.Value);
        }
Exemplo n.º 3
0
        public void UndefinedSymbolEvaluateToNull()
        {
            Symbol symbol = Symbol.Create("foo");
            Machine machine = new Machine();
            IExpression expression = new SymbolExpression(symbol);

            Assert.IsNull(expression.Evaluate(machine, machine.Environment));
            Assert.AreEqual(symbol, expression.Value);
        }