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); }
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); }
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); }