diff options
| author | Cliff Click <cliffc@acm.org> | 2025-02-07 08:58:36 -0800 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2025-02-07 08:58:36 -0800 |
| commit | 2aa8c5d1d0659bd1c828134f1a1f14d025a2d0f1 (patch) | |
| tree | 0532f3ba5d74de006fcaa906dad9b787ebb06e2e /src/test/java/com/seaofnodes/simple/Chapter04Test.java | |
| parent | 68dc63b9390bbe4ec50cc1b814d4e559e459c057 (diff) | |
| download | Simple-linear-chapter19.tar.gz Simple-linear-chapter19.zip | |
Ch# Chapter 19: Instruction Selection and Portable Compilationlinear-chapter19
Co-authored-by: hadha <helsgithub15@gmail.com>
Co-authored-by: Tamás Hadházy <85063808+Hels15@users.noreply.github.com>
Diffstat (limited to 'src/test/java/com/seaofnodes/simple/Chapter04Test.java')
| -rw-r--r-- | src/test/java/com/seaofnodes/simple/Chapter04Test.java | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/test/java/com/seaofnodes/simple/Chapter04Test.java b/src/test/java/com/seaofnodes/simple/Chapter04Test.java index afed67d1..d09b1748 100644 --- a/src/test/java/com/seaofnodes/simple/Chapter04Test.java +++ b/src/test/java/com/seaofnodes/simple/Chapter04Test.java @@ -34,14 +34,14 @@ public class Chapter04Test { public void testAddAddMul() { CodeGen code = new CodeGen("return arg+0+arg;"); code.parse(); - assertEquals("return (arg*2);", code.print()); + assertEquals("return (arg<<1);", code.print()); } @Test public void testPeephole3() { CodeGen code = new CodeGen("return 1+arg+2+arg+3; "); code.parse(); - assertEquals("return ((arg*2)+6);", code.print()); + assertEquals("return ((arg<<1)+6);", code.print()); } @Test @@ -62,8 +62,7 @@ public class Chapter04Test { // Adding functions means `main` does not constant fold the incoming arg value @Ignore @Test public void testConstantArg() { - CodeGen code = new CodeGen("return arg; ", TypeInteger.constant(2)); - code.parse(); + CodeGen code = new CodeGen("return arg; ", TypeInteger.constant(2), 123L).parse(); assertEquals("return 2;", code.expr().in(1).toString()); } @@ -111,12 +110,8 @@ public class Chapter04Test { @Test public void testBug3() { - try { - new Parser("inta=1; return a;").parse(); - fail(); - } catch( RuntimeException e ) { - assertEquals("Undefined name 'inta'",e.getMessage()); - } + try { new CodeGen("inta=1; return a;").parse(); fail(); } + catch( RuntimeException e ) { assertEquals("Undefined name 'inta'",e.getMessage()); } } @Test @@ -128,8 +123,8 @@ public class Chapter04Test { @Test public void testBug5() { - Parser parser = new Parser("return arg--2;"); - StopNode ret = parser.parse(); - assertEquals("return (arg--2);", ret.print()); + CodeGen code = new CodeGen("return arg--2;"); + code.parse(); + assertEquals("return (arg--2);", code.print()); } } |
