summaryrefslogtreecommitdiff
path: root/chapter11/src/test/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'chapter11/src/test/java/com')
-rw-r--r--chapter11/src/test/java/com/seaofnodes/simple/Chapter10Test.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/chapter11/src/test/java/com/seaofnodes/simple/Chapter10Test.java b/chapter11/src/test/java/com/seaofnodes/simple/Chapter10Test.java
index 3e97e8e7..8dc489f0 100644
--- a/chapter11/src/test/java/com/seaofnodes/simple/Chapter10Test.java
+++ b/chapter11/src/test/java/com/seaofnodes/simple/Chapter10Test.java
@@ -48,6 +48,7 @@ public class Chapter10Test {
public void testNullGuardErrors() {
for( String body : new String[] {
"return p.x;",
+ "if (p == null) return p.x; return -1;",
"if (!!point) return p.x; return -1;",
"if (!!p) { int x = p.x; } return p.x;"
} ) {
@@ -55,7 +56,10 @@ public class Chapter10Test {
new Parser(NULLABLE_POINT_SOURCE+body).parse().iterate();
fail(body);
} catch( RuntimeException e ) {
- assertEquals(body,"Might be null accessing 'x'",e.getMessage());
+ // Known null is rejected during parsing in these chapters.
+ String expected = body.startsWith("if (p == null)")
+ ? "Accessing unknown field 'x' from 'null'" : "Might be null accessing 'x'";
+ assertEquals(body,expected,e.getMessage());
}
}
}