diff options
Diffstat (limited to 'chapter18/src/test/java')
| -rw-r--r-- | chapter18/src/test/java/com/seaofnodes/simple/Chapter04Test.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/chapter18/src/test/java/com/seaofnodes/simple/Chapter04Test.java b/chapter18/src/test/java/com/seaofnodes/simple/Chapter04Test.java index afed67d1..d2260e1f 100644 --- a/chapter18/src/test/java/com/seaofnodes/simple/Chapter04Test.java +++ b/chapter18/src/test/java/com/seaofnodes/simple/Chapter04Test.java @@ -52,6 +52,34 @@ public class Chapter04Test { } @Test + public void testSub0() { + CodeGen code = new CodeGen("return arg-0;"); + code.parse(); + assertEquals("return arg;", code.print()); + } + + @Test + public void test0Sub() { + CodeGen code = new CodeGen("return 0-arg;"); + code.parse(); + assertEquals("return (-arg);", code.print()); + } + + @Test + public void testSubNeg() { + CodeGen code = new CodeGen("return 3--arg;"); + code.parse(); + assertEquals("return (arg+3);", code.print()); + } + + @Test + public void testNegSub() { + CodeGen code = new CodeGen("return -arg-3;"); + code.parse(); + assertEquals("return (-(arg+3));", code.print()); + } + + @Test public void testVarArg() { CodeGen code = new CodeGen("return arg; "); code.parse(); |
