From 69249d4c8d043e6348ecf797a2afa391726ab6d7 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Tue, 26 Nov 2024 12:17:29 -0800 Subject: First cut function ptr type --- .../java/com/seaofnodes/simple/Chapter18Test.java | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java (limited to 'chapter18/src/test') diff --git a/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java b/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java new file mode 100644 index 00000000..2c6cca8c --- /dev/null +++ b/chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java @@ -0,0 +1,36 @@ +package com.seaofnodes.simple; + +import com.seaofnodes.simple.evaluator.Evaluator; +import com.seaofnodes.simple.node.StopNode; +import org.junit.Test; +import org.junit.Ignore; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class Chapter18Test { + + @Test + public void testJig() { + Parser parser = new Parser(""" +return 3.14; +"""); + StopNode stop = parser.parse().iterate(); + assertEquals("return 3.14;", stop.toString()); + assertEquals(3.14, Evaluator.evaluate(stop, 0)); + } + + + // --------------------------------------------------------------- + @Test + public void testType0() { + Parser parser = new Parser(""" +{int -> int}? x2 = null; // null function ptr +return x2; +"""); + StopNode stop = parser.parse().iterate(); + assertEquals("return arg;", stop.toString()); + assertEquals(0L, Evaluator.evaluate(stop, 0)); + } + + +} -- cgit v1.2.3