diff options
Diffstat (limited to 'chapter15/src/test/java')
| -rw-r--r-- | chapter15/src/test/java/com/seaofnodes/simple/Chapter13Test.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/chapter15/src/test/java/com/seaofnodes/simple/Chapter13Test.java b/chapter15/src/test/java/com/seaofnodes/simple/Chapter13Test.java index e8b71820..416aba31 100644 --- a/chapter15/src/test/java/com/seaofnodes/simple/Chapter13Test.java +++ b/chapter15/src/test/java/com/seaofnodes/simple/Chapter13Test.java @@ -163,4 +163,22 @@ return new S1.s=new S2; StopNode stop = parser.parse().iterate(); assertEquals("return S2;", stop.toString()); } + + @Test + public void testcheckNull() { + Parser parser = new Parser( +""" +struct I {int i;} +struct P {I pi;} +P p1 = new P; +P p2 = new P; +p2.pi = new I; +p2.pi.i = 2; +if (arg) p1 = new P; +return p1.pi.i + 1; +"""); + try { parser.parse(false).iterate(); fail(); } + catch( Exception e ) { assertEquals("Might be null accessing 'i'",e.getMessage()); } + } + } |
