diff options
Diffstat (limited to 'chapter17/src/test/java/com')
| -rw-r--r-- | chapter17/src/test/java/com/seaofnodes/simple/Chapter13Test.java | 13 | ||||
| -rw-r--r-- | chapter17/src/test/java/com/seaofnodes/simple/Chapter17Test.java | 7 |
2 files changed, 14 insertions, 6 deletions
diff --git a/chapter17/src/test/java/com/seaofnodes/simple/Chapter13Test.java b/chapter17/src/test/java/com/seaofnodes/simple/Chapter13Test.java index 30d9b147..eeb28f1d 100644 --- a/chapter17/src/test/java/com/seaofnodes/simple/Chapter13Test.java +++ b/chapter17/src/test/java/com/seaofnodes/simple/Chapter13Test.java @@ -130,6 +130,19 @@ return n.i; } @Test + public void testNullRef4() { + Parser parser = new Parser("-null-5/null-5;"); + try { parser.parse().iterate(); fail(); } + catch( Exception e ) { assertEquals("Cannot 'Add' null",e.getMessage()); } + } + + @Test public void testNullRef5() { + Parser parser = new Parser("return null+42;"); + try { parser.parse().iterate(); fail(); } + catch( Exception e ) { assertEquals("Cannot 'Add' null",e.getMessage()); } + } + + @Test public void testEmpty() { Parser parser = new Parser( """ diff --git a/chapter17/src/test/java/com/seaofnodes/simple/Chapter17Test.java b/chapter17/src/test/java/com/seaofnodes/simple/Chapter17Test.java index 4a7e959a..1ca9a515 100644 --- a/chapter17/src/test/java/com/seaofnodes/simple/Chapter17Test.java +++ b/chapter17/src/test/java/com/seaofnodes/simple/Chapter17Test.java @@ -11,12 +11,7 @@ public class Chapter17Test { @Test public void testJig() { - Parser parser = new Parser(""" -int i = 0; -i=i=1; -return i; - //return 3.14; -"""); + Parser parser = new Parser("return 1;"); StopNode stop = parser.parse().iterate(); assertEquals("return 1;", stop.toString()); assertEquals(1L, Evaluator.evaluate(stop, 0)); |
