diff options
| author | fuhsnn <66062782+fuhsnn@users.noreply.github.com> | 2026-09-25 11:05:35 +0800 |
|---|---|---|
| committer | fuhsnn <66062782+fuhsnn@users.noreply.github.com> | 2026-09-25 11:27:48 +0800 |
| commit | 12bde12b2e18c8b82b1510ac4305de66d1205e1a (patch) | |
| tree | 1289023eea7f7afd3f7b8376bd22fcc1a94ebfc8 /chapter17 | |
| parent | 349c23d0527569284a8bec67f27130c4358e056c (diff) | |
| download | Simple-12bde12b2e18c8b82b1510ac4305de66d1205e1a.tar.gz Simple-12bde12b2e18c8b82b1510ac4305de66d1205e1a.zip | |
Add tests
Diffstat (limited to 'chapter17')
| -rw-r--r-- | chapter17/src/test/java/com/seaofnodes/simple/Chapter04Test.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/chapter17/src/test/java/com/seaofnodes/simple/Chapter04Test.java b/chapter17/src/test/java/com/seaofnodes/simple/Chapter04Test.java index 0db3afde..dfd3569f 100644 --- a/chapter17/src/test/java/com/seaofnodes/simple/Chapter04Test.java +++ b/chapter17/src/test/java/com/seaofnodes/simple/Chapter04Test.java @@ -51,6 +51,34 @@ public class Chapter04Test { } @Test + public void testSub0() { + Parser parser = new Parser("return arg-0;"); + StopNode ret = parser.parse(); + assertEquals("return arg;", ret.print()); + } + + @Test + public void test0Sub() { + Parser parser = new Parser("return 0-arg;"); + StopNode ret = parser.parse(); + assertEquals("return (-arg);", ret.print()); + } + + @Test + public void testSubNeg() { + Parser parser = new Parser("return 3--arg;"); + StopNode ret = parser.parse(); + assertEquals("return (arg+3);", ret.print()); + } + + @Test + public void testNegSub() { + Parser parser = new Parser("return -arg-3;"); + StopNode ret = parser.parse(); + assertEquals("return (-(arg+3));", ret.print()); + } + + @Test public void testVarArg() { Parser parser = new Parser("return arg; "); StopNode stop = parser.parse(); |
