diff options
| author | Cliff Click <cliffc@acm.org> | 2024-09-06 09:32:28 -0700 |
|---|---|---|
| committer | Thalia Archibald <thalia@archibald.dev> | 2024-09-07 10:54:48 -0700 |
| commit | 0f56449bc90e77cc9a0e490413585a8823bc1bf2 (patch) | |
| tree | 6857b34a611e59b8591262e65f99932d1a31d64e /chapter14/src/test/java | |
| parent | 511bbfc081de83a600197450a023131655592eaf (diff) | |
| download | Simple-0f56449bc90e77cc9a0e490413585a8823bc1bf2.tar.gz Simple-0f56449bc90e77cc9a0e490413585a8823bc1bf2.zip | |
Fix bugs
AND on floats
Shift-extend idiom smartly makes sharper int types.
Diffstat (limited to 'chapter14/src/test/java')
| -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( """ |
