summaryrefslogtreecommitdiff
path: root/chapter17/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'chapter17/src/test/java')
-rw-r--r--chapter17/src/test/java/com/seaofnodes/simple/Chapter17Test.java23
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() {