summaryrefslogtreecommitdiff
path: root/chapter30/src/test/java/com/seaofnodes/simple/PartialReadTest.java
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-11-08 14:10:02 -0800
committerCliff Click <cliffc@acm.org>2026-11-08 14:10:02 -0800
commit06fb5aceeb65a75b1cd643debd667c52fdcafcb9 (patch)
treec99813eaf27d98f840245302c4d6e923c964307e /chapter30/src/test/java/com/seaofnodes/simple/PartialReadTest.java
parent6560a92433a38825fd1d44d9c66ffba9f26990ff (diff)
downloadSimple-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/PartialReadTest.java')
-rw-r--r--chapter30/src/test/java/com/seaofnodes/simple/PartialReadTest.java6
1 files changed, 3 insertions, 3 deletions
diff --git a/chapter30/src/test/java/com/seaofnodes/simple/PartialReadTest.java b/chapter30/src/test/java/com/seaofnodes/simple/PartialReadTest.java
index a6230b69..427096e5 100644
--- a/chapter30/src/test/java/com/seaofnodes/simple/PartialReadTest.java
+++ b/chapter30/src/test/java/com/seaofnodes/simple/PartialReadTest.java
@@ -11,7 +11,7 @@ public class PartialReadTest {
private static String program(String body, String helper) {
return "struct _C { int~ x; int~ y; new _C = { int n -> " + body +
" }; }; val _read_noInline = { _C ^p -> " + helper +
- " }; return new _C(arg).y;";
+ " }; return new _C(((arg<<32)>>32)).y;";
}
private static void rejects(String source, String message) {
try {
@@ -108,7 +108,7 @@ public class PartialReadTest {
_Child child;
new _Parent = { int n -> x=n; child=new _Child(self); };
};
- val p=new _Parent(arg); return p.child.seen+p.child.parent.x;
+ val p=new _Parent(((arg<<32)>>32)); return p.child.seen+p.child.parent.x;
""";
assertEquals("22",Eval2.eval(new CodeGen(src).driver(CodeGen.Phase.TypeCheck),11));
rejects(src.replace("x=n; child=new _Child(self);","child=new _Child(self); x=n;"),"might not be initialized");
@@ -127,7 +127,7 @@ public class PartialReadTest {
new _C = { int n -> data=new int[1]; data[0]=n; y=_read_noInline(self); };
};
val _read_noInline={ _C ^p -> return p.data[0]; };
- return new _C(arg).y;
+ return new _C(((arg<<32)>>32)).y;
""";
assertEquals("23",Eval2.eval(new CodeGen(src).driver(CodeGen.Phase.TypeCheck),23));
// A set reference slot is not proof that its referent is initialized.