+ testing procvartype in generic class

git-svn-id: trunk@5332 -
This commit is contained in:
micha 2006-11-11 16:26:48 +00:00
parent 4bfe0e6819
commit 0ba8e25c8e
2 changed files with 37 additions and 0 deletions

1
.gitattributes vendored
View File

@ -6448,6 +6448,7 @@ tests/test/tfpu4.pp svneol=native#text/plain
tests/test/tfpu5.pp svneol=native#text/plain
tests/test/tfpuover.pp svneol=native#text/plain
tests/test/tgeneric1.pp svneol=native#text/plain
tests/test/tgeneric10.pp svneol=native#text/plain
tests/test/tgeneric2.pp svneol=native#text/plain
tests/test/tgeneric3.pp svneol=native#text/plain
tests/test/tgeneric4.pp svneol=native#text/plain

36
tests/test/tgeneric10.pp Normal file
View File

@ -0,0 +1,36 @@
{$mode objfpc}
type
generic TList<_T>=class(TObject)
type public
TCompareFunc = function(const Item1, Item2: _T): Integer;
var public
data : _T;
compare : TCompareFunc;
procedure Add(item: _T);
end;
procedure TList.Add(item: _T);
begin
data:=item;
if compare(data, 20) <= 0 then
halt(1);
end;
function CompareInt(Item1, Item2: Integer): Integer;
begin
Result := Item2 - Item1;
end;
type
TMyIntList = specialize TList<integer>;
var
ilist : TMyIntList;
someInt : integer;
begin
someInt:=10;
ilist := TMyIntList.Create;
ilist.compare := ilist.TCompareFunc(@CompareInt);
ilist.add(someInt);
end.