public void ShouldSetValue() { ValueEnvironment environment = new ValueEnvironment(); environment.SetValue("foo", "bar"); Assert.AreEqual("bar", environment.GetValue("foo")); }
public void ShouldGetValueFromParent() { ValueEnvironment parent = new ValueEnvironment(); ValueEnvironment environment = new ValueEnvironment(parent); parent.SetValue("foo", "bar"); Assert.AreEqual("bar", environment.GetValue("foo")); }
public void ShouldSetAndGetLocalValue() { ValueEnvironment parent = new ValueEnvironment(); ValueEnvironment environment = new ValueEnvironment(parent); environment.SetValue("foo", "bar"); Assert.AreEqual("bar", environment.GetValue("foo")); Assert.IsNull(parent.GetValue("foo")); }
public static Variable ToVariable(Machine machine, ValueEnvironment environment, Symbol symbol) { string ns = symbol.Namespace; if (String.IsNullOrEmpty(ns)) ns = (string)environment.GetValue(Machine.CurrentNamespaceKey); string name = symbol.Name; Variable variable = machine.GetVariable(ns, name); if (variable == null) variable = Variable.Intern(machine, ns, name); return variable; }
public void ShouldGetNullIfNoValue() { ValueEnvironment environment = new ValueEnvironment(); Assert.IsNull(environment.GetValue("foo")); }