From 0ac0c9e10287972ac3af5a4ee43d26f0d5b318fe Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Fri, 30 Oct 2026 16:55:15 -0700 Subject: Canonicalize aggregate memory duals and preserve field finality --- .../java/com/seaofnodes/simple/BoundaryTest.java | 10 +++++++++ .../test/java/com/seaofnodes/simple/TypeTest.java | 26 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) (limited to 'chapter28b/src/test/java') diff --git a/chapter28b/src/test/java/com/seaofnodes/simple/BoundaryTest.java b/chapter28b/src/test/java/com/seaofnodes/simple/BoundaryTest.java index b736ccb3..e196b93f 100644 --- a/chapter28b/src/test/java/com/seaofnodes/simple/BoundaryTest.java +++ b/chapter28b/src/test/java/com/seaofnodes/simple/BoundaryTest.java @@ -9,6 +9,16 @@ import static org.junit.Assert.*; // The new module boundary must preserve the preceding chapters' examples. public class BoundaryTest { @Test public void testLocalConstruction() throws java.io.IOException { + // Nested factories must preserve memory duals during construction, + // for both direct fields and getters on the returned instance. + for( String body : new String[]{"int x=7;", "int _x=7; val get={ -> _x; };" } ) + for( long seed : new long[]{1,13,123} ) { + String src = "struct Outer { struct _Hidden { "+body+ + " }; val make={ -> new _Hidden(); }; }; return new Outer().make()."; + CodeGen factory = new CodeGen(src+(body.startsWith("int x") ? "x;" : "get();"),seed,true) + .driver(CodeGen.Phase.TypeCheck); + assertEquals("7",Eval2.eval(factory,0)); + } String src="struct Counter { int x; int y; int z; new Counter={int n -> while(x