diff options
| author | Cliff Click <cliffc@acm.org> | 2024-11-15 14:53:39 -0800 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2024-11-23 09:03:20 -0800 |
| commit | e24a4246190fc8e5785f36427c79100575139e3c (patch) | |
| tree | 3d3945e96faba041ceb5e05f6f8700aff8039334 /chapter17/src/test/java/com | |
| parent | 73d293a89d8f8b5188ee2406ce24a1fef96f062f (diff) | |
| download | Simple-e24a4246190fc8e5785f36427c79100575139e3c.tar.gz Simple-e24a4246190fc8e5785f36427c79100575139e3c.zip | |
Straighten out nested forward ref type errors
Diffstat (limited to 'chapter17/src/test/java/com')
| -rw-r--r-- | chapter17/src/test/java/com/seaofnodes/simple/Chapter17Test.java | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/chapter17/src/test/java/com/seaofnodes/simple/Chapter17Test.java b/chapter17/src/test/java/com/seaofnodes/simple/Chapter17Test.java index 516da849..44538965 100644 --- a/chapter17/src/test/java/com/seaofnodes/simple/Chapter17Test.java +++ b/chapter17/src/test/java/com/seaofnodes/simple/Chapter17Test.java @@ -12,7 +12,12 @@ public class Chapter17Test { @Test public void testJig() { Parser parser = new Parser(""" -return 3.14; +struct A { int i; }; +A! a = new A; +a.i=a; +a.i=2; +return a; + //return 3.14; """); StopNode stop = parser.parse().iterate(); assertEquals("return 3.14;", stop.toString()); @@ -369,7 +374,7 @@ for(;;arg++;) {} // --------------------------------------------------------------- @Test - public void testForward() { + public void testForward0() { Parser parser = new Parser(""" struct A{ B? f1; @@ -382,6 +387,20 @@ return new A; assertEquals("Obj<A>{f1=null,f2=null}", Evaluator.evaluate(stop).toString()); } + @Test + public void testForward1() { + Parser parser = new Parser(""" +struct A{ + B?[]? nil_array_of_b; + B?[] not_array_of_b = new B?[0]; +}; +return new A.not_array_of_b; +"""); + StopNode stop = parser.parse().iterate(); + assertEquals("return (const)[*B?];", stop.toString()); + assertEquals("Obj<[*B?]>{#=0,[]=[]}", Evaluator.evaluate(stop).toString()); + } + // --------------------------------------------------------------- @Test public void testLinkedList2() { |
