예제 #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);
        }
예제 #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);
        }
예제 #3
0
파일: TestMacro.cs 프로젝트: orfgen/Trip
        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);
        }
예제 #4
0
파일: TestParser.cs 프로젝트: orfgen/Trip
        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);
        }
예제 #5
0
        public void TestParse()
        {
            Node result = HighLevel.Parse(null);

            Assert.IsNull(result);
        }