public void ShouldExpandUnquotedSymbol() { Parser parser = new Parser("(unquote x)"); object list = parser.Compile(); ValueEnvironment environment = new ValueEnvironment(); environment.SetValue("x", "y"); object result = MacroUtilities.Expand(list, environment); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(string)); Assert.AreEqual("y", result); }
public void ShouldExpandSimpleList() { Parser parser = new Parser("(1 2 3)"); object array = parser.Compile(); object result = MacroUtilities.Expand(array, null); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(List)); List resultList = (List)result; Assert.AreEqual(1, resultList.First); Assert.AreEqual(2, resultList.Next.First); Assert.AreEqual(3, resultList.Next.Next.First); Assert.IsNull(resultList.Next.Next.Next); }
public void ShouldExpandImplicitUnquotedSymbolInList() { Parser parser = new Parser("(1 ~x 3)"); object list = parser.Compile(); ValueEnvironment environment = new ValueEnvironment(); environment.SetValue("x", 2); object result = MacroUtilities.Expand(list, environment); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(List)); List resultList = (List)result; Assert.AreEqual(1, resultList.First); Assert.AreEqual(2, resultList.Next.First); Assert.AreEqual(3, resultList.Next.Next.First); Assert.IsNull(resultList.Next.Next.Next); }
public void ShouldExpandSymbol() { Identifier identifier = new Identifier("foo"); Assert.AreEqual(identifier, MacroUtilities.Expand(identifier, null)); }
public void ShouldExpandConstants() { Assert.AreEqual(1, MacroUtilities.Expand(1, null)); Assert.AreEqual("foo", MacroUtilities.Expand("foo", null)); }
public override object Execute(object argument, ValueEnvironment environment) { return(MacroUtilities.Expand(argument, environment)); }