From 25cd8e3ee751b5cef9e7b6d89aa6f8cf0cc0a39b Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Mon, 29 Jun 2026 10:08:44 +0100 Subject: [PATCH] test(sepcompile): cover static property in cross-unit .bif round-trip The cross-unit static-members tests (QBE + native) already drive a static var, static method and static const through the warm --unit-cache .bif boundary. Add a static property (a getter-backed 'static property Counter read Next') to the shared test unit so TPropertyDecl.IsStatic surviving the .bif round-trip is guarded too: a non-static import would dispatch the getter with a bogus Self. Expected stdout updated to include the extra Counter read. --- compiler/src/test/pascal/cp.test.e2e.sepcompile.pas | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/compiler/src/test/pascal/cp.test.e2e.sepcompile.pas b/compiler/src/test/pascal/cp.test.e2e.sepcompile.pas index 31e9ec1..ea82bec 100644 --- a/compiler/src/test/pascal/cp.test.e2e.sepcompile.pas +++ b/compiler/src/test/pascal/cp.test.e2e.sepcompile.pas @@ -1612,6 +1612,10 @@ const FCount: Integer; public static function Next: Integer; + { Static property whose getter is a static method: exercises + TPropertyDecl.IsStatic surviving the .bif round-trip (a non-static + import would dispatch with a bogus Self). } + static property Counter: Integer read Next; public static const Tag = 7; end; @@ -1630,6 +1634,7 @@ const begin WriteLn(TReg.Next()); WriteLn(TReg.Next()); + WriteLn(TReg.Counter); WriteLn(TReg.Tag) end. '''; @@ -1668,7 +1673,7 @@ begin AssertEquals('qbe build1 exit (out: ' + Captured + ')', 0, Rc); Rc := RunBinary(ProgBin, Captured); AssertEquals('qbe build1 run exit', 0, Rc); - AssertEquals('qbe build1 stdout', '1' + #10 + '2' + #10 + '7' + #10, Captured); + AssertEquals('qbe build1 stdout', '1' + #10 + '2' + #10 + '3' + #10 + '7' + #10, Captured); { Build 2 (warm cache): RegModU loaded purely from its cached .bif — the static facts must survive the .bif round-trip. } @@ -1679,7 +1684,7 @@ begin AssertEquals('qbe build2 exit (out: ' + Captured + ')', 0, Rc); Rc := RunBinary(ProgBin, Captured); AssertEquals('qbe build2 run exit', 0, Rc); - AssertEquals('qbe build2 stdout', '1' + #10 + '2' + #10 + '7' + #10, Captured) + AssertEquals('qbe build2 stdout', '1' + #10 + '2' + #10 + '3' + #10 + '7' + #10, Captured) end; procedure TSepCompileTests.TestStaticMembers_CrossUnit_Native; @@ -1715,7 +1720,7 @@ begin AssertEquals('native build1 exit (out: ' + Captured + ')', 0, Rc); Rc := RunBinary(ProgBin, Captured); AssertEquals('native build1 run exit', 0, Rc); - AssertEquals('native build1 stdout', '1' + #10 + '2' + #10 + '7' + #10, Captured); + AssertEquals('native build1 stdout', '1' + #10 + '2' + #10 + '3' + #10 + '7' + #10, Captured); Rc := RunBlaise(['--source', ProgPas, '--output', ProgBin, '--backend', 'native', @@ -1724,7 +1729,7 @@ begin AssertEquals('native build2 exit (out: ' + Captured + ')', 0, Rc); Rc := RunBinary(ProgBin, Captured); AssertEquals('native build2 run exit', 0, Rc); - AssertEquals('native build2 stdout', '1' + #10 + '2' + #10 + '7' + #10, Captured) + AssertEquals('native build2 stdout', '1' + #10 + '2' + #10 + '3' + #10 + '7' + #10, Captured) end; initialization