Browse Source

+ template test with 2 template parameters

git-svn-id: trunk@5301 -
micha 19 years ago
parent
commit
00d66f9142
2 changed files with 30 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 29 0
      tests/test/tgeneric9.pp

+ 1 - 0
.gitattributes

@@ -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 - 0
tests/test/tgeneric9.pp

@@ -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.