Browse Source

Added a few more tests. All except tgeneric65.pp (object inside generic record) and tgeneric68.pp (object inside generic object) are successfully compiled.

git-svn-id: branches/svenbarth/generics@19723 -
svenbarth 13 years ago
parent
commit
06ebfcd360

+ 16 - 0
.gitattributes

@@ -10124,7 +10124,21 @@ tests/test/tgeneric51.pp svneol=native#text/pascal
 tests/test/tgeneric52.pp svneol=native#text/pascal
 tests/test/tgeneric53.pp svneol=native#text/pascal
 tests/test/tgeneric54.pp svneol=native#text/pascal
+tests/test/tgeneric55.pp svneol=native#text/pascal
+tests/test/tgeneric56.pp svneol=native#text/pascal
+tests/test/tgeneric57.pp svneol=native#text/pascal
+tests/test/tgeneric58.pp svneol=native#text/pascal
+tests/test/tgeneric59.pp svneol=native#text/pascal
 tests/test/tgeneric6.pp svneol=native#text/plain
+tests/test/tgeneric60.pp svneol=native#text/pascal
+tests/test/tgeneric61.pp svneol=native#text/pascal
+tests/test/tgeneric62.pp svneol=native#text/pascal
+tests/test/tgeneric63.pp svneol=native#text/pascal
+tests/test/tgeneric64.pp svneol=native#text/pascal
+tests/test/tgeneric65.pp svneol=native#text/pascal
+tests/test/tgeneric66.pp svneol=native#text/pascal
+tests/test/tgeneric67.pp svneol=native#text/pascal
+tests/test/tgeneric68.pp svneol=native#text/pascal
 tests/test/tgeneric7.pp svneol=native#text/plain
 tests/test/tgeneric8.pp svneol=native#text/plain
 tests/test/tgeneric9.pp svneol=native#text/plain
@@ -10621,6 +10635,8 @@ tests/test/ugeneric10.pp svneol=native#text/plain
 tests/test/ugeneric14.pp svneol=native#text/plain
 tests/test/ugeneric3.pp svneol=native#text/plain
 tests/test/ugeneric4.pp svneol=native#text/plain
+tests/test/ugeneric59a.pp svneol=native#text/pascal
+tests/test/ugeneric59b.pp svneol=native#text/pascal
 tests/test/ugeneric7.pp svneol=native#text/plain
 tests/test/uhintdir.pp svneol=native#text/plain
 tests/test/uhlp3.pp svneol=native#text/pascal

+ 19 - 0
tests/test/tgeneric55.pp

@@ -0,0 +1,19 @@
+{ %FAIL }
+
+{ this tests that the dummy symbol that is introduced for generic "overloads"
+  can not be used when it shouldn't be - Test 1 }
+program tgeneric55;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TTest<T> = class
+
+  end;
+
+var
+  t: TTest;
+begin
+end.

+ 20 - 0
tests/test/tgeneric56.pp

@@ -0,0 +1,20 @@
+{ %FAIL }
+
+{ this tests that the dummy symbol that is introduced for generic "overloads"
+  can not be used when it shouldn't be - Test 2 }
+program tgeneric56;
+
+{$ifdef fpc}
+  {$mode objfpc}
+{$endif}
+
+type
+  generic TTest<T> = class
+
+  end;
+
+var
+  t: TTest;
+begin
+end.
+

+ 21 - 0
tests/test/tgeneric57.pp

@@ -0,0 +1,21 @@
+{ %FAIL }
+
+{ this tests that the dummy symbol that is introduced for generic "overloads"
+  can not be used when it shouldn't be - Test 3 }
+program tgeneric57;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TTest<T> = class
+
+  end;
+
+var
+  t: TObject;
+begin
+  t := TTest.Create;
+end.
+

+ 21 - 0
tests/test/tgeneric58.pp

@@ -0,0 +1,21 @@
+{ %FAIL }
+
+{ this tests that the dummy symbol that is introduced for generic "overloads"
+  can not be used when it shouldn't be - Test 4 }
+program tgeneric58;
+
+{$ifdef fpc}
+  {$mode objfpc}
+{$endif}
+
+type
+  generic TTest<T> = class
+
+  end;
+
+var
+  t: TObject;
+begin
+  t := TTest.Create;
+end.
+

+ 25 - 0
tests/test/tgeneric59.pp

@@ -0,0 +1,25 @@
+{ TTest<T, S> is used from one unit, while TTest<T> is used from another }
+program tgeneric59;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+{$apptype console}
+
+uses
+  ugeneric59a,
+  ugeneric59b;
+
+type
+  TTestInteger = TTest<Integer>;
+  TTestIntegerString = TTest<Integer, String>;
+
+var
+  res: Integer;
+begin
+  res := TTestInteger.Test;
+  Writeln('TTestInteger.Test: ', res);
+  if res <> 2 then
+    Halt(1);
+  Writeln('ok');
+end.

+ 28 - 0
tests/test/tgeneric60.pp

@@ -0,0 +1,28 @@
+{ %NORUN }
+
+{ this tests that nested non-generic structured types can be used inside
+  generics - here: record in class }
+program tgeneric60;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TTest<T> = class
+  type
+    TTestSub = record
+      class function Test(a: T): T; static;
+    end;
+  end;
+
+class function TTest<T>.TTestSub.Test(a: T): T;
+begin
+  Result := a;
+end;
+
+var
+  t: TTest<Integer>.TTestSub;
+begin
+  TTest<Integer>.TTestSub.Test(42);
+end.

+ 28 - 0
tests/test/tgeneric61.pp

@@ -0,0 +1,28 @@
+{ %NORUN }
+
+{ this tests that nested non-generic structured types can be used inside
+  generics - here: class in class }
+program tgeneric61;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TTest<T> = class
+  type
+    TTestSub = class
+      class function Test(a: T): T;
+    end;
+  end;
+
+class function TTest<T>.TTestSub.Test(a: T): T;
+begin
+  Result := a;
+end;
+
+var
+  t: TTest<Integer>.TTestSub;
+begin
+  TTest<Integer>.TTestSub.Test(42);
+end.

+ 28 - 0
tests/test/tgeneric62.pp

@@ -0,0 +1,28 @@
+{ %NORUN }
+
+{ this tests that nested non-generic structured types can be used inside
+  generics - here: object in class }
+program tgeneric62;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TTest<T> = class
+  type
+    TTestSub = object
+      function Test(a: T): T;
+    end;
+  end;
+
+function TTest<T>.TTestSub.Test(a: T): T;
+begin
+  Result := a;
+end;
+
+var
+  t: TTest<Integer>.TTestSub;
+begin
+  t.Test(42);
+end.

+ 28 - 0
tests/test/tgeneric63.pp

@@ -0,0 +1,28 @@
+{ %NORUN }
+
+{ this tests that nested non-generic structured types can be used inside
+  generics - here: record in record }
+program tgeneric63;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TTest<T> = record
+  type
+    TTestSub = record
+      class function Test(a: T): T; static;
+    end;
+  end;
+
+class function TTest<T>.TTestSub.Test(a: T): T;
+begin
+  Result := a;
+end;
+
+var
+  t: TTest<Integer>.TTestSub;
+begin
+  TTest<Integer>.TTestSub.Test(42);
+end.

+ 28 - 0
tests/test/tgeneric64.pp

@@ -0,0 +1,28 @@
+{ %NORUN }
+
+{ this tests that nested non-generic structured types can be used inside
+  generics - here: class in record }
+program tgeneric64;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TTest<T> = record
+  type
+    TTestSub = class
+      class function Test(a: T): T;
+    end;
+  end;
+
+class function TTest<T>.TTestSub.Test(a: T): T;
+begin
+  Result := a;
+end;
+
+var
+  t: TTest<Integer>.TTestSub;
+begin
+  TTest<Integer>.TTestSub.Test(42);
+end.

+ 28 - 0
tests/test/tgeneric65.pp

@@ -0,0 +1,28 @@
+{ %NORUN }
+
+{ this tests that nested non-generic structured types can be used inside
+  generics - here: object in record }
+program tgeneric65;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TTest<T> = record
+  type
+    TTestSub = object
+      function Test(a: T): T;
+    end;
+  end;
+
+function TTest<T>.TTestSub.Test(a: T): T;
+begin
+  Result := a;
+end;
+
+var
+  t: TTest<Integer>.TTestSub;
+begin
+  t.Test(42);
+end.

+ 28 - 0
tests/test/tgeneric66.pp

@@ -0,0 +1,28 @@
+{ %NORUN }
+
+{ this tests that nested non-generic structured types can be used inside
+  generics - here: record in object }
+program tgeneric66;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TTest<T> = object
+  type
+    TTestSub = record
+      class function Test(a: T): T; static;
+    end;
+  end;
+
+class function TTest<T>.TTestSub.Test(a: T): T;
+begin
+  Result := a;
+end;
+
+var
+  t: TTest<Integer>.TTestSub;
+begin
+  TTest<Integer>.TTestSub.Test(42);
+end.

+ 28 - 0
tests/test/tgeneric67.pp

@@ -0,0 +1,28 @@
+{ %NORUN }
+
+{ this tests that nested non-generic structured types can be used inside
+  generics - here: class in object }
+program tgeneric66;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TTest<T> = object
+  type
+    TTestSub = class
+      class function Test(a: T): T;
+    end;
+  end;
+
+class function TTest<T>.TTestSub.Test(a: T): T;
+begin
+  Result := a;
+end;
+
+var
+  t: TTest<Integer>.TTestSub;
+begin
+  TTest<Integer>.TTestSub.Test(42);
+end.

+ 28 - 0
tests/test/tgeneric68.pp

@@ -0,0 +1,28 @@
+{ %NORUN }
+
+{ this tests that nested non-generic structured types can be used inside
+  generics - here: object in object }
+program tgeneric68;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TTest<T> = object
+  type
+    TTestSub = object
+      function Test(a: T): T;
+    end;
+  end;
+
+function TTest<T>.TTestSub.Test(a: T): T;
+begin
+  Result := a;
+end;
+
+var
+  t: TTest<Integer>.TTestSub;
+begin
+  t.Test(42);
+end.

+ 24 - 0
tests/test/ugeneric59a.pp

@@ -0,0 +1,24 @@
+unit ugeneric59a;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+interface
+
+type
+  TTest<T> = class
+    class function Test: Integer;
+  end;
+
+  TTest<T, S> = class
+  end;
+
+implementation
+
+class function TTest<T>.Test: Integer;
+begin
+  Result := 1;
+end;
+
+end.

+ 22 - 0
tests/test/ugeneric59b.pp

@@ -0,0 +1,22 @@
+unit ugeneric59b;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+interface
+
+type
+  TTest<T> = class
+    class function Test: Integer;
+  end;
+
+implementation
+
+class function TTest<T>.Test: Integer;
+begin
+  Result := 2;
+end;
+
+end.
+