fpc/tests/test/tchlp39.pp
svenbarth b74e0e9b4e Added another bunch of tests. Partly they still need to be verified in Delphi.
git-svn-id: branches/svenbarth/classhelpers@16830 -
2011-01-28 21:09:33 +00:00

52 lines
913 B
ObjectPascal

{ the parent of a class helper has higher priority than the extended class when
searching for symbols }
program tchlp39;
{$ifdef fpc}
{$mode objfpc}
{$endif}
{$apptype console}
type
TFoo = class
function Test(aRecurse: Boolean): Integer;
end;
TFooHelper = class helper for TFoo
function Test(aRecurse: Boolean): Integer;
end;
TFooSubHelper = class helper(TFooHelper) for TFoo
function Test(aRecurse: Boolean): Integer;
end;
function TFoo.Test(aRecurse: Boolean): Integer;
begin
Result := 1;
end;
function TFooHelper.Test(aRecurse: Boolean): Integer;
begin
Result := 2;
end;
function TFooSubHelper.Test(aRecurse: Boolean): Integer;
begin
if aRecurse then
Result := Test(False)
else
Result := 3;
end;
var
f: TFoo;
res: Integer;
begin
f := TFoo.Create;
res := f.Test(True);
Writeln('f.Test: ', res);
if res <> 2 then
Halt(1);
Writeln('ok');
end.