mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-25 03:49:22 +02:00
* extend test for interface helper by tests for "inherited"
git-svn-id: trunk@37061 -
This commit is contained in:
parent
6acba684d4
commit
ec7a17d1e3
@ -34,11 +34,16 @@ type
|
|||||||
function Blubb: LongInt;
|
function Blubb: LongInt;
|
||||||
function Foobar(aArg: LongInt): LongInt; overload;
|
function Foobar(aArg: LongInt): LongInt; overload;
|
||||||
function Test: LongInt;
|
function Test: LongInt;
|
||||||
|
function Calculate: LongInt;
|
||||||
|
function CalculateBase: LongInt;
|
||||||
class function TestStatic: LongInt; static;
|
class function TestStatic: LongInt; static;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TTestIntfSubSubHelper = type helper(TTestIntfHelper) for ITestIntfSubSub
|
TTestIntfSubSubHelper = type helper(TTestIntfHelper) for ITestIntfSubSub
|
||||||
function SomethingElse: LongInt;
|
function SomethingElse: LongInt;
|
||||||
|
function Calculate: LongInt;
|
||||||
|
function CalculateBase: LongInt;
|
||||||
|
function CalculateBase2: LongInt;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TTestSubSub }
|
{ TTestSubSub }
|
||||||
@ -62,6 +67,21 @@ begin
|
|||||||
Result := 7;
|
Result := 7;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TTestIntfSubSubHelper.Calculate: LongInt;
|
||||||
|
begin
|
||||||
|
Result := 100 * SomethingElse + inherited Calculate;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TTestIntfSubSubHelper.CalculateBase: LongInt;
|
||||||
|
begin
|
||||||
|
Result := 100 * inherited SomethingElse + inherited CalculateBase;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TTestIntfSubSubHelper.CalculateBase2: LongInt;
|
||||||
|
begin
|
||||||
|
Result := 100 * inherited SomethingElse + inherited Calculate;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TTest }
|
{ TTest }
|
||||||
|
|
||||||
function TTest.Blubb: LongInt;
|
function TTest.Blubb: LongInt;
|
||||||
@ -91,6 +111,16 @@ begin
|
|||||||
Result := 1;
|
Result := 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TTestIntfHelper.Calculate: LongInt;
|
||||||
|
begin
|
||||||
|
Result := 10 * Blubb + Foobar;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TTestIntfHelper.CalculateBase: LongInt;
|
||||||
|
begin
|
||||||
|
Result := 10 * inherited Blubb + inherited Foobar;
|
||||||
|
end;
|
||||||
|
|
||||||
class function TTestIntfHelper.TestStatic: LongInt;
|
class function TTestIntfHelper.TestStatic: LongInt;
|
||||||
begin
|
begin
|
||||||
Result := 2;
|
Result := 2;
|
||||||
@ -114,20 +144,30 @@ begin
|
|||||||
Halt(5);
|
Halt(5);
|
||||||
if i.Foobar(6) <> 6 then
|
if i.Foobar(6) <> 6 then
|
||||||
Halt(6);
|
Halt(6);
|
||||||
|
if i.Calculate <> 35 then
|
||||||
|
Halt(7);
|
||||||
|
if i.CalculateBase <> 45 then
|
||||||
|
Halt(8);
|
||||||
i := Nil;
|
i := Nil;
|
||||||
|
|
||||||
_is := TTestSub.Create;
|
_is := TTestSub.Create;
|
||||||
if _is.Blubb <> 3 then
|
if _is.Blubb <> 3 then
|
||||||
Halt(7);
|
Halt(9);
|
||||||
if _is.Foobar(8) <> 8 then
|
if _is.Foobar(8) <> 8 then
|
||||||
Halt(8);
|
Halt(10);
|
||||||
_is := Nil;
|
_is := Nil;
|
||||||
|
|
||||||
iss := TTestSubSub.Create;
|
iss := TTestSubSub.Create;
|
||||||
if iss.SomethingElse <> 7 then
|
if iss.SomethingElse <> 7 then
|
||||||
Halt(9);
|
Halt(11);
|
||||||
if iss.Blubb <> 3 then
|
if iss.Blubb <> 3 then
|
||||||
Halt(10);
|
Halt(12);
|
||||||
|
if iss.Calculate <> 735 then
|
||||||
|
Halt(13);
|
||||||
|
if iss.CalculateBase <> 945 then
|
||||||
|
Halt(14);
|
||||||
|
if iss.CalculateBase2 <> 935 then
|
||||||
|
Halt(15);
|
||||||
iss := Nil;
|
iss := Nil;
|
||||||
|
|
||||||
Writeln('ok');
|
Writeln('ok');
|
||||||
|
Loading…
Reference in New Issue
Block a user