Przeglądaj źródła

Added 36 tests (tchlp*.pp) and some units (uchlp*).

git-svn-id: branches/svenbarth/classhelpers@16730 -
svenbarth 14 lat temu
rodzic
commit
18ed600cbe

+ 14 - 0
.gitattributes

@@ -9278,6 +9278,10 @@ tests/test/tcase7.pp svneol=native#text/pascal
 tests/test/tcase8.pp svneol=native#text/pascal
 tests/test/tcase9.pp svneol=native#text/pascal
 tests/test/tcg1.pp svneol=native#text/plain
+tests/test/tchlp1.pp svneol=native#text/pascal
+tests/test/tchlp2.pp svneol=native#text/pascal
+tests/test/tchlp35.pp svneol=native#text/pascal
+tests/test/tchlp36.pp svneol=native#text/pascal
 tests/test/tcint64.pp svneol=native#text/plain
 tests/test/tclass1.pp svneol=native#text/plain
 tests/test/tclass10.pp svneol=native#text/pascal
@@ -9788,6 +9792,16 @@ tests/test/twrstr6.pp svneol=native#text/plain
 tests/test/twrstr7.pp svneol=native#text/plain
 tests/test/twrstr8.pp svneol=native#text/plain
 tests/test/uabstrcl.pp svneol=native#text/plain
+tests/test/uchlp27a.pp svneol=native#text/pascal
+tests/test/uchlp27b.pp svneol=native#text/pascal
+tests/test/uchlp27c.pp svneol=native#text/pascal
+tests/test/uchlp32a.pp svneol=native#text/pascal
+tests/test/uchlp32b.pp svneol=native#text/pascal
+tests/test/uchlp32c.pp svneol=native#text/pascal
+tests/test/uchlp33a.pp svneol=native#text/pascal
+tests/test/uchlp33b.pp svneol=native#text/pascal
+tests/test/uchlp33c.pp svneol=native#text/pascal
+tests/test/uchlp35.pp svneol=native#text/pascal
 tests/test/uenum2a.pp svneol=native#text/plain
 tests/test/uenum2b.pp svneol=native#text/plain
 tests/test/ugeneric10.pp svneol=native#text/plain

+ 50 - 0
tests/test/tchlp1.pp

@@ -0,0 +1,50 @@
+{%NORUN}
+
+{ checks for support of the class helper syntax in mode objfpc }
+program tchlp1;
+
+{$mode objfpc}
+
+type
+  TObjectHelper = class helper for TObject
+    procedure SomePublicMethod;
+  strict private
+    procedure SomeStrictPrivateMethod;
+  private
+    procedure SomePrivateMethod;
+  strict protected
+    procedure SomeStrictProtectedMethod;
+  protected
+    procedure SomeProtectedMethod;
+  public
+    procedure SomePublicMethod2;
+  end;
+
+procedure TObjectHelper.SomePublicMethod;
+begin
+end;
+
+procedure TObjectHelper.SomeStrictPrivateMethod;
+begin
+end;
+
+procedure TObjectHelper.SomePrivateMethod;
+begin
+end;
+
+procedure TObjectHelper.SomeStrictProtectedMethod;
+begin
+end;
+
+procedure TObjectHelper.SomeProtectedMethod;
+begin
+end;
+
+procedure TObjectHelper.SomePublicMethod2;
+begin
+end;
+
+begin
+
+end.
+

+ 52 - 0
tests/test/tchlp2.pp

@@ -0,0 +1,52 @@
+{%NORUN}
+
+{ checks for support of the class helper syntax in mode delphi }
+program tchlp2;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TObjectHelper = class helper for TObject
+    procedure SomePublicMethod;
+  strict private
+    procedure SomeStrictPrivateMethod;
+  private
+    procedure SomePrivateMethod;
+  strict protected
+    procedure SomeStrictProtectedMethod;
+  protected
+    procedure SomeProtectedMethod;
+  public
+    procedure SomePublicMethod2;
+  end;
+
+procedure TObjectHelper.SomePublicMethod;
+begin
+end;
+
+procedure TObjectHelper.SomeStrictPrivateMethod;
+begin
+end;
+
+procedure TObjectHelper.SomePrivateMethod;
+begin
+end;
+
+procedure TObjectHelper.SomeStrictProtectedMethod;
+begin
+end;
+
+procedure TObjectHelper.SomeProtectedMethod;
+begin
+end;
+
+procedure TObjectHelper.SomePublicMethod2;
+begin
+end;
+
+begin
+
+end.
+

+ 26 - 0
tests/test/tchlp35.pp

@@ -0,0 +1,26 @@
+{ tests virtual methods inside class helpers }
+program tchlp35;
+
+uses
+  uchlp35;
+
+type
+  TObjectHelperB = class helper(TObjectHelperA) for TObject
+    function VirtualTest: Integer; override;
+  end;
+
+function TObjectHelperB.VirtualTest: Integer;
+begin
+  Result := 2;
+end;
+
+var
+  o: TObject;
+  res: Integer;
+begin
+  o := TObject.Create;
+  res := o.Test;
+  if res <> 2 then
+    Halt(1);
+end.
+

+ 29 - 0
tests/test/tchlp36.pp

@@ -0,0 +1,29 @@
+{ %NORUN }
+
+program tchlp36;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TObjectHelper = class helper for TObject
+    procedure Test;
+  end;
+
+  TFoo = class
+
+  end;
+
+  TFooHelper = class helper(TObjectHelper) for TFoo
+  end;
+
+procedure TObjectHelper.Test;
+begin
+end;
+
+var
+  f: TFoo;
+begin
+  f.Test;
+end.

+ 24 - 0
tests/test/uchlp27a.pp

@@ -0,0 +1,24 @@
+unit uchlp27a; 
+
+{$ifdef fpc}
+  {$mode objfpc}{$H+}
+{$endif}
+
+interface
+
+type
+  TFoo = class
+    function Test: Integer;
+  end;
+
+implementation
+
+{ TFoo }
+
+function TFoo.Test: Integer;
+begin
+  Result := 1;
+end;
+
+end.
+

+ 25 - 0
tests/test/uchlp27b.pp

@@ -0,0 +1,25 @@
+unit uchlp27b; 
+
+{$ifdef fpc}
+  {$mode objfpc}{$H+}
+{$endif}
+
+interface
+
+uses
+  uchlp27a;
+
+type
+  TFooHelper = class helper for TFoo
+    function Test: Integer;
+  end;
+
+implementation
+
+function TFooHelper.Test: Integer;
+begin
+  Result := 2;
+end;
+
+end.
+

+ 27 - 0
tests/test/uchlp27c.pp

@@ -0,0 +1,27 @@
+unit uchlp27c; 
+
+{$ifdef fpc}
+  {$mode objfpc}{$H+}
+{$endif}
+
+interface
+
+uses
+  uchlp27a;
+
+type
+  TBar = class(TFoo)
+    function Test: Integer;
+  end;
+
+implementation
+
+{ TBar }
+
+function TBar.Test: Integer;
+begin
+  Result := 3;
+end;
+
+end.
+

+ 16 - 0
tests/test/uchlp32a.pp

@@ -0,0 +1,16 @@
+unit uchlp32a; 
+
+{$ifdef fpc}
+  {$mode objfpc}{$H+}
+{$endif}
+
+interface
+
+type
+  TFoo = class
+  end;
+
+implementation
+
+end.
+

+ 25 - 0
tests/test/uchlp32b.pp

@@ -0,0 +1,25 @@
+unit uchlp32b; 
+
+{$ifdef fpc}
+  {$mode objfpc}{$H+}
+{$endif}
+
+interface
+
+uses
+  uchlp32a;
+
+type
+  TFooHelperA = class helper for TFoo
+    procedure Method1;
+  end;
+
+implementation
+
+procedure TFooHelperA.Method1;
+begin
+
+end;
+
+end.
+

+ 25 - 0
tests/test/uchlp32c.pp

@@ -0,0 +1,25 @@
+unit uchlp32c; 
+
+{$ifdef fpc}
+  {$mode objfpc}{$H+}
+{$endif}
+
+interface
+
+uses
+  uchlp32a;
+
+type
+  TFooHelperB = class helper for TFoo
+    procedure Method2;
+  end;
+
+implementation
+
+procedure TFooHelperB.Method2;
+begin
+
+end;
+
+end.
+

+ 16 - 0
tests/test/uchlp33a.pp

@@ -0,0 +1,16 @@
+unit uchlp33a; 
+
+{$ifdef fpc}
+  {$mode objfpc}{$H+}
+{$endif}
+
+interface
+
+type
+  TFoo = class
+  end;
+
+implementation
+
+end.
+

+ 25 - 0
tests/test/uchlp33b.pp

@@ -0,0 +1,25 @@
+unit uchlp33b; 
+
+{$ifdef fpc}
+  {$mode objfpc}{$H+}
+{$endif}
+
+interface
+
+uses
+  uchlp33a;
+
+type
+  TFooHelper = class helper for TFoo
+    function Test: Integer;
+  end;
+
+implementation
+
+function TFooHelper.Test: Integer;
+begin
+  Result := 1;
+end;
+
+end.
+

+ 25 - 0
tests/test/uchlp33c.pp

@@ -0,0 +1,25 @@
+unit uchlp33c;
+
+{$ifdef fpc}
+  {$mode objfpc}{$H+}
+{$endif}
+
+interface
+
+uses
+  uchlp33a, uchlp33b;
+
+type
+  TFooHelper2 = class helper(TFooHelper) for TFoo
+    function Test: Integer;
+  end;
+
+implementation
+
+function TFooHelper2.Test: Integer;
+begin
+  Result := 2;
+end;
+
+end.
+

+ 28 - 0
tests/test/uchlp35.pp

@@ -0,0 +1,28 @@
+unit uchlp35; 
+
+{$ifdef fpc}
+  {$mode objfpc}{$H+}
+{$endif}
+
+interface
+
+type
+  TObjectHelperA = class helper for TObject
+    function Test: Integer;
+    function VirtualTest: Integer; virtual;
+  end;
+
+implementation
+
+function TObjectHelperA.Test: Integer;
+begin
+  Result := VirtualTest;
+end;
+
+function TObjectHelperA.VirtualTest: Integer;
+begin
+  Result := 1;
+end;
+
+end.
+