Browse Source

Add tests for resolved generic bug reports.

Also adjusted test for report 20836 (removed unneeded units and the {$R ...} directive completely and added a "%NORUN" modifier).

git-svn-id: trunk@19817 -
svenbarth 13 years ago
parent
commit
5ffba57b51

+ 7 - 0
.gitattributes

@@ -11896,6 +11896,7 @@ tests/webtbs/tw19368.pp svneol=native#text/pascal
 tests/webtbs/tw1938.pp svneol=native#text/plain
 tests/webtbs/tw1938.pp svneol=native#text/plain
 tests/webtbs/tw1948.pp svneol=native#text/plain
 tests/webtbs/tw1948.pp svneol=native#text/plain
 tests/webtbs/tw1950.pp svneol=native#text/plain
 tests/webtbs/tw1950.pp svneol=native#text/plain
+tests/webtbs/tw19500.pp svneol=native#text/pascal
 tests/webtbs/tw19548.pp svneol=native#text/pascal
 tests/webtbs/tw19548.pp svneol=native#text/pascal
 tests/webtbs/tw19555.pp svneol=native#text/pascal
 tests/webtbs/tw19555.pp svneol=native#text/pascal
 tests/webtbs/tw1964.pp svneol=native#text/plain
 tests/webtbs/tw1964.pp svneol=native#text/plain
@@ -11932,6 +11933,7 @@ tests/webtbs/tw2031.pp svneol=native#text/plain
 tests/webtbs/tw2037.pp svneol=native#text/plain
 tests/webtbs/tw2037.pp svneol=native#text/plain
 tests/webtbs/tw20396.pp svneol=native#text/plain
 tests/webtbs/tw20396.pp svneol=native#text/plain
 tests/webtbs/tw2040.pp svneol=native#text/plain
 tests/webtbs/tw2040.pp svneol=native#text/plain
+tests/webtbs/tw20407.pp svneol=native#text/pascal
 tests/webtbs/tw2041.pp svneol=native#text/plain
 tests/webtbs/tw2041.pp svneol=native#text/plain
 tests/webtbs/tw20421.pp svneol=native#text/pascal
 tests/webtbs/tw20421.pp svneol=native#text/pascal
 tests/webtbs/tw2045.pp svneol=native#text/plain
 tests/webtbs/tw2045.pp svneol=native#text/plain
@@ -11940,12 +11942,17 @@ tests/webtbs/tw20527.pp svneol=native#text/plain
 tests/webtbs/tw20557.pp svneol=native#text/pascal
 tests/webtbs/tw20557.pp svneol=native#text/pascal
 tests/webtbs/tw2059.pp svneol=native#text/plain
 tests/webtbs/tw2059.pp svneol=native#text/plain
 tests/webtbs/tw20594.pp svneol=native#text/pascal
 tests/webtbs/tw20594.pp svneol=native#text/pascal
+tests/webtbs/tw20627.pp svneol=native#text/pascal
+tests/webtbs/tw20629.pp svneol=native#text/pascal
 tests/webtbs/tw20638.pp svneol=native#text/pascal
 tests/webtbs/tw20638.pp svneol=native#text/pascal
 tests/webtbs/tw2065.pp svneol=native#text/plain
 tests/webtbs/tw2065.pp svneol=native#text/plain
 tests/webtbs/tw2069.pp svneol=native#text/plain
 tests/webtbs/tw2069.pp svneol=native#text/plain
 tests/webtbs/tw20690.pp svneol=native#text/pascal
 tests/webtbs/tw20690.pp svneol=native#text/pascal
 tests/webtbs/tw2072.pp svneol=native#text/plain
 tests/webtbs/tw2072.pp svneol=native#text/plain
 tests/webtbs/tw20744.pp svneol=native#text/plain
 tests/webtbs/tw20744.pp svneol=native#text/plain
+tests/webtbs/tw20796a.pp svneol=native#text/pascal
+tests/webtbs/tw20796b.pp svneol=native#text/pascal
+tests/webtbs/tw20796c.pp svneol=native#text/pascal
 tests/webtbs/tw20821.pp svneol=native#text/pascal
 tests/webtbs/tw20821.pp svneol=native#text/pascal
 tests/webtbs/tw20836.pp svneol=native#text/pascal
 tests/webtbs/tw20836.pp svneol=native#text/pascal
 tests/webtbs/tw2109.pp svneol=native#text/plain
 tests/webtbs/tw2109.pp svneol=native#text/plain

+ 20 - 0
tests/webtbs/tw19500.pp

@@ -0,0 +1,20 @@
+{ %NORUN }
+
+{$MODE OBJFPC} { -*- text -*- }
+program tw19500;
+
+type
+   generic TFoo <T> = class
+     type
+      TBar = class
+         function Baz(): T;
+      end;
+   end;
+
+function TFoo.TBar.Baz(): T;
+begin
+   Result := nil;
+end;
+
+begin
+end.

+ 14 - 0
tests/webtbs/tw20407.pp

@@ -0,0 +1,14 @@
+{ %NORUN }
+
+program tw20407;
+
+{$mode delphi}
+
+type
+  tbwimagegen<T> = class
+    type
+      TLocalType = tbwimagegen<T>;
+  end;
+
+begin
+end.

+ 48 - 0
tests/webtbs/tw20627.pp

@@ -0,0 +1,48 @@
+{ based on the file attached to bug 20627, but modified for usage in FPC's
+  testsuite }
+
+{$MODE delphi}
+
+type
+  TWrapper<TValue> = class
+  strict private
+    FValue: TValue;
+  public
+    type
+      TWrapperState = class
+      strict private
+        FValue: TValue;
+      public
+        property Value: TValue read FValue write FValue;
+        function GetValueSize: Integer;
+          { The compiler will report that forward declaration
+            TWrapper$LongInt.TWrapperState.GetValueSize is not resolved. }
+      end;
+  public 
+    property Value: TValue read FValue write FValue;
+    function CaptureState: TWrapperState;
+  end;
+
+function TWrapper<TValue>.CaptureState: TWrapperState;
+begin
+  Result := TWrapperState.Create;
+  Result.Value := FValue;
+end;
+
+function TWrapper<TValue>.TWrapperState.GetValueSize: Integer;
+begin
+  Result := SizeOf(FValue);
+end;
+
+
+begin
+  with TWrapper<Integer>.Create do begin
+    Value := 123;
+    with CaptureState do begin
+      if GetValueSize <> SizeOf(Integer) then
+        Halt(1);
+      Free;
+    end;
+    Free;
+  end;
+end.

+ 12 - 0
tests/webtbs/tw20629.pp

@@ -0,0 +1,12 @@
+{ %NORUN }
+
+{$MODE delphi}
+
+type
+  TWrapper<TValue> = class end;
+  TObjectWrapper = TWrapper<TObject>;
+
+begin
+  with TObjectWrapper.Create do Free;     { OK }
+  with TWrapper<TObject>.Create do Free;  { Error }
+end.

+ 39 - 0
tests/webtbs/tw20796a.pp

@@ -0,0 +1,39 @@
+unit tw20796a;
+
+{$MODE DELPHI}
+{$DEFINE CRASHCOMPILER}
+
+interface
+
+type
+  TWrapper<TValue> = class
+  strict private
+    FValue: TValue;
+  public
+    property Value: TValue read FValue write FValue;
+  {$IFDEF CRASHCOMPILER}
+    procedure SomeMethod;
+  {$ENDIF}
+  end;
+
+  TTestClass = class
+  public
+    procedure DoTest;
+  end;
+
+implementation
+
+{$IFDEF CRASHCOMPILER}
+procedure TWrapper<TValue>.SomeMethod;
+begin
+end;
+{$ENDIF}
+
+procedure TTestClass.DoTest;
+var
+  w: TWrapper<Byte>;
+begin
+end;
+
+end.
+

+ 40 - 0
tests/webtbs/tw20796b.pp

@@ -0,0 +1,40 @@
+unit tw20796b;
+
+{$MODE DELPHI}
+{$DEFINE CRASHCOMPILER}
+
+interface
+
+type
+  TWrapper<TValue> = class
+  strict private
+    FValue: TValue;
+  public
+    property Value: TValue read FValue write FValue;
+  {$IFDEF CRASHCOMPILER}
+    procedure SomeMethod;
+  {$ENDIF}
+  end;
+
+  TTestClass = class
+  public
+    procedure DoTest;
+  end;
+
+implementation
+
+{$IFDEF CRASHCOMPILER}
+procedure TWrapper<TValue>.SomeMethod;
+begin
+end;
+{$ENDIF}
+
+procedure TTestClass.DoTest;
+type
+  TByteWrapper = TWrapper<Byte>;
+var
+  w: TByteWrapper;
+begin
+end;
+
+end.

+ 40 - 0
tests/webtbs/tw20796c.pp

@@ -0,0 +1,40 @@
+unit tw20796c;
+
+{$MODE OBJFPC}
+{$DEFINE CRASHCOMPILER}
+
+interface
+
+type
+  generic TWrapper<TValue> = class
+  strict private
+    FValue: TValue;
+  public
+    property Value: TValue read FValue write FValue;
+  {$IFDEF CRASHCOMPILER}
+    procedure SomeMethod;
+  {$ENDIF}
+  end;
+
+  TTestClass = class
+  public
+    procedure DoTest;
+  end;
+
+implementation
+
+{$IFDEF CRASHCOMPILER}
+procedure TWrapper.SomeMethod;
+begin
+end;
+{$ENDIF}
+
+procedure TTestClass.DoTest;
+type
+  TByteWrapper = specialize TWrapper<Byte>;
+var
+  w: TByteWrapper;
+begin
+end;
+
+end.

+ 3 - 8
tests/webtbs/tw20836.pp

@@ -1,15 +1,10 @@
+{ %NORUN }
+
+{ adjusted test by removing some "Lazarusisms" }
 program tw20836;
 program tw20836;
 
 
 {$mode objfpc}{$H+}
 {$mode objfpc}{$H+}
 
 
-uses
-  {$IFDEF UNIX}{$IFDEF UseCThreads}
-  cthreads,
-  {$ENDIF}{$ENDIF}
-  Classes
-  { you can add units after this };
-
-{.$R *.res}
 type
 type
   generic TGObjectChangeCommand<_T>=object
   generic TGObjectChangeCommand<_T>=object
                                         private
                                         private