diff options
| author | Cliff Click <cliffc@acm.org> | 2024-09-30 08:56:50 -0700 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2024-10-06 08:56:22 -0700 |
| commit | 31ba4ecbc5214b3c25917fd97d030bfd39a784a3 (patch) | |
| tree | 75a11c32d9062ade79d531d25c0d8508996fcd5b /chapter15/src/test/java/com/seaofnodes | |
| parent | 6af26a247bf583f0a6a50f44539655367bf800bb (diff) | |
| download | Simple-31ba4ecbc5214b3c25917fd97d030bfd39a784a3.tar.gz Simple-31ba4ecbc5214b3c25917fd97d030bfd39a784a3.zip | |
Fix 2 test cases
Diffstat (limited to 'chapter15/src/test/java/com/seaofnodes')
| -rw-r--r-- | chapter15/src/test/java/com/seaofnodes/simple/Chapter15Test.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/chapter15/src/test/java/com/seaofnodes/simple/Chapter15Test.java b/chapter15/src/test/java/com/seaofnodes/simple/Chapter15Test.java index 15465677..2955361a 100644 --- a/chapter15/src/test/java/com/seaofnodes/simple/Chapter15Test.java +++ b/chapter15/src/test/java/com/seaofnodes/simple/Chapter15Test.java @@ -34,6 +34,19 @@ return is[1]; } @Test + public void testBasic2() { + Parser parser = new Parser( +""" +int[] is = new int[2]; +int[] is2 = new int[2]; +return is[1]; +"""); + StopNode stop = parser.parse(false).iterate(true); + assertEquals("return 0;", stop.toString()); + assertEquals(0L, Evaluator.evaluate(stop, 0)); + } + + @Test public void testRollingSum() { Parser parser = new Parser( """ @@ -67,4 +80,13 @@ return new flt; catch( Exception e ) { assertEquals("Cannot allocate a FltBot",e.getMessage()); } } + @Test + public void testBad1() { + Parser parser = new Parser( +""" +int is = new int[2]; +"""); + try { parser.parse(false).iterate(false); fail(); } + catch( Exception e ) { assertEquals("Type *[]int is not of declared type int",e.getMessage()); } + } } |
