+ template test with 2 template parameters

git-svn-id: trunk@5301 -
This commit is contained in:
micha 2006-11-09 21:25:36 +00:00
parent e619bd3235
commit 00d66f9142
2 changed files with 30 additions and 0 deletions

1
.gitattributes vendored
View File

@ -6455,6 +6455,7 @@ tests/test/tgeneric5.pp svneol=native#text/plain
tests/test/tgeneric6.pp svneol=native#text/plain
tests/test/tgeneric7.pp svneol=native#text/plain
tests/test/tgeneric8.pp svneol=native#text/plain
tests/test/tgeneric9.pp svneol=native#text/plain
tests/test/tgoto.pp svneol=native#text/plain
tests/test/theap.pp svneol=native#text/plain
tests/test/thintdir.pp svneol=native#text/plain

29
tests/test/tgeneric9.pp Normal file
View File

@ -0,0 +1,29 @@
{$mode objfpc}
type
generic TMap<TK, TD> = class(TObject)
Key: TK;
Data: TD;
procedure Add(const AKey: TK; const AData: TD);
end;
procedure TMap.Add(const AKey: TK; const AData: TD);
begin
Key := AKey;
Data := AData;
end;
type
TMyStringList = specialize TMap<string, TObject>;
var
slist: TMyStringList;
begin
slist := TMyStringList.Create;
slist.Add('test', slist);
if slist.Key <> 'test' then
halt(1);
if slist.Data <> slist then
halt(1);
slist.Free;
end.