Exemplo n.º 1
0
        public void TestLambdaEvaluation()
        {
            string expr      = "(lambda (x) (print x))";
            Node   parseTree = HighLevel.Parse(expr);

            Node nodeResult = Evaluator.Evaluate(parseTree, env);

            Assert.IsNotNull(nodeResult);
            Assert.AreEqual(StdNodeTypes.Function, nodeResult.NodeType);
        }
Exemplo n.º 2
0
        public void TestLambdaApplicationEvaluation()
        {
            string expr      = "(eval (list (lambda (x) (+ 1 x)) 3))";
            Node   parseTree = HighLevel.Parse(expr);

            Node nodeResult = Evaluator.Evaluate(parseTree, env);

            Assert.IsNotNull(nodeResult);
            Assert.AreEqual(StdNodeTypes.Identifier, nodeResult.NodeType);

            string result = NodeOps.Serialize(nodeResult);

            Assert.AreEqual("4", result);
        }
Exemplo n.º 3
0
        public void TestSimpleParse()
        {
            string line = "(seq (defmacro inc (x) (+ x 1)) (inc 2))";

            Node node = HighLevel.Parse(line);

            Assert.IsNotNull(node);

            Env env = new Env(null);

            node = MacroExpander.ExpandMacros(node, env);
            string serialization = NodeOps.Serialize(node);

            Assert.AreEqual("(seq (+ 2 1))", serialization);
        }
Exemplo n.º 4
0
        public void TestSimpleParse()
        {
            string line = "(+ 1 2)";

            Node node = HighLevel.Parse(line);

            Assert.IsNull(node.Content);

            Node child0 = node.Head;

            Assert.AreEqual("+", child0.Content);

            Node child1 = node.Tail.Head;

            Assert.AreEqual("1", child1.Content);

            Node child2 = node.Tail.Tail.Head;

            Assert.AreEqual("2", child2.Content);
        }
Exemplo n.º 5
0
        public void TestParse()
        {
            Node result = HighLevel.Parse(null);

            Assert.IsNull(result);
        }