Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public void ShouldExpandSymbol()
        {
            Identifier identifier = new Identifier("foo");

            Assert.AreEqual(identifier, MacroUtilities.Expand(identifier, null));
        }
Exemplo n.º 5
0
 public void ShouldExpandConstants()
 {
     Assert.AreEqual(1, MacroUtilities.Expand(1, null));
     Assert.AreEqual("foo", MacroUtilities.Expand("foo", null));
 }
Exemplo n.º 6
0
 public override object Execute(object argument, ValueEnvironment environment)
 {
     return(MacroUtilities.Expand(argument, environment));
 }