Esempio n. 1
0
        public void DefineAndEvaluateSimpleList()
        {
            Parser parser = new Parser("[x y] (list 'list (unquote x) (unquote y)) 1 2");
            object argumentNames = parser.ParseForm();
            object body = parser.ParseForm();

            DefinedMacro func = new DefinedMacro("simple-list", (ICollection)argumentNames, body);

            Assert.AreEqual("simple-list", func.Name);

            object[] arguments = new object[2];
            arguments[0] = parser.ParseForm();
            arguments[1] = parser.ParseForm();

            Machine machine = new Machine();

            object result = func.Apply(machine, machine.Environment, arguments);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(IList));
            Assert.AreEqual(2, ((IList)result).Count);
        }
Esempio n. 2
0
 public void GetConstantExpressionEvaluatingDefineMacro()
 {
     IFunction function = new DefinedMacro("foo", null, null);
     object result = Utilities.ToExpression(function);
     Assert.IsNotNull(result);
     Assert.IsInstanceOfType(result, typeof(ConstantExpression));
 }