mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-16 13:39:35 +02:00

(since macpas methods may accidentally be called like that as well, as it doesn't have any constructors/destructors) + some tests for MacPas objects from the GNU Pascal testsuite git-svn-id: trunk@5421 -
42 lines
553 B
ObjectPascal
42 lines
553 B
ObjectPascal
{ original: peter5c.pas from the GNU Pascal testsuite }
|
|
|
|
{$mode macpas}
|
|
|
|
program peter5c(output);
|
|
|
|
type
|
|
ObjectA = object
|
|
procedure Doit;
|
|
end;
|
|
ObjectB = object
|
|
obj: ObjectA;
|
|
function GetA: ObjectA;
|
|
end;
|
|
|
|
var
|
|
ok: boolean;
|
|
|
|
procedure ObjectA.Doit;
|
|
begin
|
|
WriteLn( 'OK' );
|
|
ok := true;
|
|
end;
|
|
|
|
function ObjectB.GetA: ObjectA;
|
|
begin
|
|
return obj;
|
|
end;
|
|
|
|
var
|
|
a: ObjectA;
|
|
b: ObjectB;
|
|
begin
|
|
New(a);
|
|
New(b);
|
|
b.obj := a;
|
|
b.GetA.Doit;
|
|
if not ok then
|
|
halt(1);
|
|
end.
|
|
|