mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-10 08:08:36 +02:00
+ template test with 2 template parameters
git-svn-id: trunk@5301 -
This commit is contained in:
parent
e619bd3235
commit
00d66f9142
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -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
29
tests/test/tgeneric9.pp
Normal 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.
|
Loading…
Reference in New Issue
Block a user