mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-19 21:19:31 +02:00
*** empty log message ***
This commit is contained in:
parent
881fe6d416
commit
33d42bd125
47
tests/test/testitf4.pp
Normal file
47
tests/test/testitf4.pp
Normal file
@ -0,0 +1,47 @@
|
||||
{ $version >= 1.1}
|
||||
{$mode objfpc}
|
||||
type
|
||||
ITest = interface(IUnknown)
|
||||
procedure DoSomething;
|
||||
end;
|
||||
|
||||
|
||||
TMyClass = class(TInterfacedObject, ITest)
|
||||
procedure DoSomething;
|
||||
end;
|
||||
|
||||
var
|
||||
i : longint;
|
||||
|
||||
procedure TMyClass.DoSomething;
|
||||
begin
|
||||
inc(i);
|
||||
end;
|
||||
|
||||
|
||||
procedure DoTest(const ATest: ITest);
|
||||
begin
|
||||
ATest.DoSomething;
|
||||
end;
|
||||
|
||||
|
||||
procedure DoTest2(ATest: ITest);
|
||||
begin
|
||||
ATest.DoSomething;
|
||||
end;
|
||||
|
||||
|
||||
var
|
||||
c: TMyClass;
|
||||
begin
|
||||
i:=0;
|
||||
c := TMyClass.Create;
|
||||
DoTest(c);
|
||||
DoTest2(c);
|
||||
c.Free;
|
||||
if i<>2 then
|
||||
begin
|
||||
writeln('Problem with passing interfaces as parameters');
|
||||
halt(1);
|
||||
end;
|
||||
end.
|
Loading…
Reference in New Issue
Block a user