diff options
| author | Cliff Click <cliffc@acm.org> | 2024-10-12 14:10:40 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2024-10-21 08:52:01 -0700 |
| commit | 475f66adc7c1c9f1cd479c4492999eae4c060c5b (patch) | |
| tree | 2a5525e0fe356c5500c26decded1f3534c9b7bba /chapter16 | |
| parent | b5e56b9183292c3f731f5f4efe9c6acd54cbae8e (diff) | |
| download | Simple-475f66adc7c1c9f1cd479c4492999eae4c060c5b.tar.gz Simple-475f66adc7c1c9f1cd479c4492999eae4c060c5b.zip | |
Add a first test to code to
Diffstat (limited to 'chapter16')
| -rw-r--r-- | chapter16/src/test/java/com/seaofnodes/simple/Chapter16Test.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/chapter16/src/test/java/com/seaofnodes/simple/Chapter16Test.java b/chapter16/src/test/java/com/seaofnodes/simple/Chapter16Test.java new file mode 100644 index 00000000..d49d7ede --- /dev/null +++ b/chapter16/src/test/java/com/seaofnodes/simple/Chapter16Test.java @@ -0,0 +1,39 @@ +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 java.nio.charset.StandardCharsets; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +public class Chapter16Test { + + @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 testBasicFinal() { + Parser parser = new Parser( +""" +struct Point { int !x, !y; } +Point p = new P { x=3; y=4; } +return p; +"""); + StopNode stop = parser.parse().iterate(); + assertEquals("return P;", stop.toString()); + assertEquals(3.14, Evaluator.evaluate(stop, 0)); + } + +} |
