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); }
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); }
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); }
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); }
public void TestParse() { Node result = HighLevel.Parse(null); Assert.IsNull(result); }