From 9bc99b3987f1daea61c329b9327814d9a9148ebe Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Mon, 5 Aug 2024 12:01:38 -0700 Subject: Fix graph draw with field names Allow co-recursive defs --- .../java/com/seaofnodes/simple/Chapter12Test.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'chapter13/src/test/java/com/seaofnodes') diff --git a/chapter13/src/test/java/com/seaofnodes/simple/Chapter12Test.java b/chapter13/src/test/java/com/seaofnodes/simple/Chapter12Test.java index 903fe676..e36c7577 100644 --- a/chapter13/src/test/java/com/seaofnodes/simple/Chapter12Test.java +++ b/chapter13/src/test/java/com/seaofnodes/simple/Chapter12Test.java @@ -102,4 +102,23 @@ return next.i; assertEquals("Stop[ return 0; return 1; return .i; ]", stop.toString()); assertEquals(2L, Evaluator.evaluate(stop, 3)); } + + @Test + public void testCoRecur() { + Parser parser = new Parser( +""" +struct int0 { int i; flt0? f; } +struct flt0 { flt f; int0? i; } +int0 i0 = new int0; +i0.i = 17; +flt0 f0 = new flt0; +f0.f = 3.14; +i0.f = f0; +f0.i = i0; +return f0.i.f.i.i; +"""); + StopNode stop = parser.parse(false).iterate(false); + assertEquals("return 17;", stop.toString()); + } + } -- cgit v1.2.3