diff options
| author | Cliff Click <cliffc@acm.org> | 2024-11-26 12:17:29 -0800 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2025-01-15 15:07:30 -0800 |
| commit | 69249d4c8d043e6348ecf797a2afa391726ab6d7 (patch) | |
| tree | d28fa2073f43081ea3ac598c56e876ad8a935007 /chapter18/src/test/java/com | |
| parent | 3507afb1602bcf159dede6bde2c70d620d6563da (diff) | |
| download | Simple-69249d4c8d043e6348ecf797a2afa391726ab6d7.tar.gz Simple-69249d4c8d043e6348ecf797a2afa391726ab6d7.zip | |
First cut function ptr type
Diffstat (limited to 'chapter18/src/test/java/com')
| -rw-r--r-- | chapter18/src/test/java/com/seaofnodes/simple/Chapter18Test.java | 36 |
1 files changed, 36 insertions, 0 deletions
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)); + } + + +} |
