diff options
| author | Cliff Click <cliffc@acm.org> | 2026-11-08 14:10:02 -0800 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-11-08 14:10:02 -0800 |
| commit | 06fb5aceeb65a75b1cd643debd667c52fdcafcb9 (patch) | |
| tree | c99813eaf27d98f840245302c4d6e923c964307e /chapter30/src/test/java/com/seaofnodes/simple/Chapter22Test.java | |
| parent | 6560a92433a38825fd1d44d9c66ffba9f26990ff (diff) | |
| download | Simple-ch30.tar.gz Simple-ch30.zip | |
Better error messagesch30
Better error messages.
Buffs to the std lib; getch() to fetch a single character; streaming I/O handles retries, and large sizes, with better error reporting.
Formatted strings.
Default int moved to i32.
TicTacToe, the game.
Diffstat (limited to 'chapter30/src/test/java/com/seaofnodes/simple/Chapter22Test.java')
| -rw-r--r-- | chapter30/src/test/java/com/seaofnodes/simple/Chapter22Test.java | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/chapter30/src/test/java/com/seaofnodes/simple/Chapter22Test.java b/chapter30/src/test/java/com/seaofnodes/simple/Chapter22Test.java index e9a668a7..9bebee23 100644 --- a/chapter30/src/test/java/com/seaofnodes/simple/Chapter22Test.java +++ b/chapter30/src/test/java/com/seaofnodes/simple/Chapter22Test.java @@ -18,7 +18,7 @@ import static org.junit.Assert.*; public class Chapter22Test { @Test public void testNarrowCReturnsEmulated() { - String[] types = {"i8","u8","i16","u16","i32","u32","int"}; + String[] types = {"i8","u8","i16","u16","i32","u32","i64","int"}; long[] values = {0xa5a5a5a500000000L,0xa5a5a5a50000007fL,0xa5a5a5a500000080L, 0xa5a5a5a500007fffL,0xa5a5a5a500008000L,0xa5a5a5a57fffffffL, 0xa5a5a5a580000000L,0xa5a5a5a5ffffffffL}; @@ -35,7 +35,7 @@ public class Chapter22Test { long expected = switch(i) { case 0 -> (byte)value; case 1 -> value&255; case 2 -> (short)value; case 3 -> value&65535; - case 4 -> (int)value; case 5 -> value&0xffffffffL; + case 4, 7 -> (int)value; case 5 -> value&0xffffffffL; default -> value; }; byte[] image = new byte[1<<16]; @@ -70,7 +70,7 @@ public class Chapter22Test { {i8} c_i8="C"; {u8} c_u8="C"; {i16} c_i16="C"; {u16} c_u16="C"; {i32} c_i32="C"; {u32} c_u32="C"; - {int} c_i64="C"; + {i64} c_i64="C"; val test_i8={->return c_i8();}; val test_u8={->return c_u8();}; val test_i16={->return c_i16();}; @@ -344,7 +344,7 @@ val _sum = { i32[~] is -> // final array return _sum(is); """; CodeGen code = new CodeGen(src).driver(CodeGen.Phase.TypeCheck); - assertEquals("return Phi(Loop,0,(Phi_sum+.[]));", code.print()); + assertEquals("return Phi(Loop,0,(((Phi_sum+.[])<<32)>>32));", code.print()); assertEquals("14", Eval2.eval(code, 0)); } @@ -354,7 +354,8 @@ return _sum(is); String src = """ // Echo stdin to stdout. -return sys.io.p( sys.io.stdin() ); +val input=sys.io.stdin(); +return input ? sys.io.p(input) : -1; """; TestC.runSF(src,"echo", "",0); |
