diff options
Diffstat (limited to 'chapter19/src/test/java/com/seaofnodes')
| -rw-r--r-- | chapter19/src/test/java/com/seaofnodes/simple/Chapter13Test.java | 13 | ||||
| -rw-r--r-- | chapter19/src/test/java/com/seaofnodes/simple/Chapter19Test.java | 33 |
2 files changed, 46 insertions, 0 deletions
diff --git a/chapter19/src/test/java/com/seaofnodes/simple/Chapter13Test.java b/chapter19/src/test/java/com/seaofnodes/simple/Chapter13Test.java index d05fd7d8..005a3dd4 100644 --- a/chapter19/src/test/java/com/seaofnodes/simple/Chapter13Test.java +++ b/chapter19/src/test/java/com/seaofnodes/simple/Chapter13Test.java @@ -128,6 +128,19 @@ return n.i; } @Test + public void testNullRef4() { + CodeGen code = new CodeGen("-null-5/null-5;"); + try { code.parse().opto().typeCheck(); fail(); } + catch( Exception e ) { assertEquals("Cannot 'Add' null",e.getMessage()); } + } + + @Test public void testNullRef5() { + CodeGen code = new CodeGen("return null+42;"); + try { code.parse().opto().typeCheck(); fail(); } + catch( Exception e ) { assertEquals("Cannot 'Add' null",e.getMessage()); } + } + + @Test public void testEmpty() { CodeGen code = new CodeGen( """ diff --git a/chapter19/src/test/java/com/seaofnodes/simple/Chapter19Test.java b/chapter19/src/test/java/com/seaofnodes/simple/Chapter19Test.java index a4857a01..990c4c32 100644 --- a/chapter19/src/test/java/com/seaofnodes/simple/Chapter19Test.java +++ b/chapter19/src/test/java/com/seaofnodes/simple/Chapter19Test.java @@ -180,6 +180,39 @@ return arg1 * arg; } @Test + public void testBasic18() { + CodeGen code = new CodeGen( + """ + int arg1 = arg + 1; + return arg1 << arg; + """); + code.parse().opto().typeCheck().instSelect("x86_64_v2", "SystemV").GCM().localSched(); + assertEquals("return (shl,(inc,arg),arg);", code._stop.toString()); + } + + @Test + public void testBasic19() { + CodeGen code = new CodeGen( + """ + int arg1 = arg + 1; + return arg1 >> arg; + """); + code.parse().opto().typeCheck().instSelect("x86_64_v2", "SystemV").GCM().localSched(); + assertEquals("return (sar,(inc,arg),arg);", code._stop.toString()); + } + + @Test + public void testBasic20() { + CodeGen code = new CodeGen( + """ + int arg1 = arg + 1; + return arg1 >>> arg; + """); + code.parse().opto().typeCheck().instSelect("x86_64_v2", "SystemV").GCM().localSched(); + assertEquals("return (shr,(inc,arg),arg);", code._stop.toString()); + } + + @Test public void testToFloat() { CodeGen code = new CodeGen(""" int a = arg; |
