diff options
Diffstat (limited to 'chapter14/src/test/java/com')
| -rw-r--r-- | chapter14/src/test/java/com/seaofnodes/simple/Chapter07Test.java | 1 | ||||
| -rw-r--r-- | chapter14/src/test/java/com/seaofnodes/simple/Chapter14Test.java | 25 |
2 files changed, 25 insertions, 1 deletions
diff --git a/chapter14/src/test/java/com/seaofnodes/simple/Chapter07Test.java b/chapter14/src/test/java/com/seaofnodes/simple/Chapter07Test.java index f9251be7..faa81347 100644 --- a/chapter14/src/test/java/com/seaofnodes/simple/Chapter07Test.java +++ b/chapter14/src/test/java/com/seaofnodes/simple/Chapter07Test.java @@ -1,7 +1,6 @@ package com.seaofnodes.simple; import com.seaofnodes.simple.node.*; -import com.seaofnodes.simple.type.TypeInteger; import org.junit.Test; import static org.junit.Assert.*; diff --git a/chapter14/src/test/java/com/seaofnodes/simple/Chapter14Test.java b/chapter14/src/test/java/com/seaofnodes/simple/Chapter14Test.java index 8b3c3c9a..962b8e4d 100644 --- a/chapter14/src/test/java/com/seaofnodes/simple/Chapter14Test.java +++ b/chapter14/src/test/java/com/seaofnodes/simple/Chapter14Test.java @@ -116,6 +116,19 @@ return b; // Sign extend } @Test + public void testI8() { + Parser parser = new Parser( +""" +i8 b = arg; +b = b + 1;// Truncate +return b; +"""); + StopNode stop = parser.parse(false).iterate(false); + assertEquals("return (((((arg<<56)>>56)+1)<<56)>>56);", stop.toString()); + assertEquals(1L, Evaluator.evaluate(stop, 0)); + } + + @Test public void testMask() { Parser parser = new Parser( """ @@ -129,6 +142,18 @@ return c; // } @Test + public void testMaskFloat() { + Parser parser = new Parser( +""" +flt f = arg; +arg = f & 0; +return arg; +"""); + try { parser.parse(true).iterate(true); fail(); } + catch( Exception e ) { assertEquals("Cannot '&' FltBot",e.getMessage()); } + } + + @Test public void testTypes() { Parser parser = new Parser( """ |
