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.
This commit is contained in:
parent
8d1cdc8f61
commit
25cd8e3ee7
|
|
@ -1612,6 +1612,10 @@ const
|
||||||
FCount: Integer;
|
FCount: Integer;
|
||||||
public
|
public
|
||||||
static function Next: Integer;
|
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
|
public static const
|
||||||
Tag = 7;
|
Tag = 7;
|
||||||
end;
|
end;
|
||||||
|
|
@ -1630,6 +1634,7 @@ const
|
||||||
begin
|
begin
|
||||||
WriteLn(TReg.Next());
|
WriteLn(TReg.Next());
|
||||||
WriteLn(TReg.Next());
|
WriteLn(TReg.Next());
|
||||||
|
WriteLn(TReg.Counter);
|
||||||
WriteLn(TReg.Tag)
|
WriteLn(TReg.Tag)
|
||||||
end.
|
end.
|
||||||
''';
|
''';
|
||||||
|
|
@ -1668,7 +1673,7 @@ begin
|
||||||
AssertEquals('qbe build1 exit (out: ' + Captured + ')', 0, Rc);
|
AssertEquals('qbe build1 exit (out: ' + Captured + ')', 0, Rc);
|
||||||
Rc := RunBinary(ProgBin, Captured);
|
Rc := RunBinary(ProgBin, Captured);
|
||||||
AssertEquals('qbe build1 run exit', 0, Rc);
|
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
|
{ Build 2 (warm cache): RegModU loaded purely from its cached .bif — the
|
||||||
static facts must survive the .bif round-trip. }
|
static facts must survive the .bif round-trip. }
|
||||||
|
|
@ -1679,7 +1684,7 @@ begin
|
||||||
AssertEquals('qbe build2 exit (out: ' + Captured + ')', 0, Rc);
|
AssertEquals('qbe build2 exit (out: ' + Captured + ')', 0, Rc);
|
||||||
Rc := RunBinary(ProgBin, Captured);
|
Rc := RunBinary(ProgBin, Captured);
|
||||||
AssertEquals('qbe build2 run exit', 0, Rc);
|
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;
|
end;
|
||||||
|
|
||||||
procedure TSepCompileTests.TestStaticMembers_CrossUnit_Native;
|
procedure TSepCompileTests.TestStaticMembers_CrossUnit_Native;
|
||||||
|
|
@ -1715,7 +1720,7 @@ begin
|
||||||
AssertEquals('native build1 exit (out: ' + Captured + ')', 0, Rc);
|
AssertEquals('native build1 exit (out: ' + Captured + ')', 0, Rc);
|
||||||
Rc := RunBinary(ProgBin, Captured);
|
Rc := RunBinary(ProgBin, Captured);
|
||||||
AssertEquals('native build1 run exit', 0, Rc);
|
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,
|
Rc := RunBlaise(['--source', ProgPas, '--output', ProgBin,
|
||||||
'--backend', 'native',
|
'--backend', 'native',
|
||||||
|
|
@ -1724,7 +1729,7 @@ begin
|
||||||
AssertEquals('native build2 exit (out: ' + Captured + ')', 0, Rc);
|
AssertEquals('native build2 exit (out: ' + Captured + ')', 0, Rc);
|
||||||
Rc := RunBinary(ProgBin, Captured);
|
Rc := RunBinary(ProgBin, Captured);
|
||||||
AssertEquals('native build2 run exit', 0, Rc);
|
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;
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue