Răsfoiți Sursa

Completely restructured the test for the helper feature. The tests were split into three categories:
* general tests for the helper feature (thlp*)
* tests for class helpers (tchlp*)
* tests for record helpers (trhlp*)

With my current yet-to-be-commited implementation nearly all tests pass, but some fail because of missing FPC features:
* thlp30.pp currently fails because of generic constraints, but should fail despite the constraints
* thlp29.pp fails, because generic methods are not yet supported
* trhlp8.pp, trhlp9.pp, trhlp10.pp fail, because one can't use default properties using the abbreviated syntax
* trhlp17.pp, trhlp18.pp, trhlp19.pp fail, because nested types are not supported for records

git-svn-id: branches/svenbarth/classhelpers@17237 -

svenbarth 14 ani în urmă
părinte
comite
553d357d64
100 a modificat fișierele cu 1723 adăugiri și 1557 ștergeri
  1. 95 51
      .gitattributes
  2. 15 36
      tests/test/tchlp1.pp
  3. 24 9
      tests/test/tchlp10.pp
  4. 8 11
      tests/test/tchlp11.pp
  5. 12 22
      tests/test/tchlp12.pp
  6. 12 30
      tests/test/tchlp13.pp
  7. 10 16
      tests/test/tchlp14.pp
  8. 12 21
      tests/test/tchlp15.pp
  9. 14 6
      tests/test/tchlp16.pp
  10. 14 5
      tests/test/tchlp17.pp
  11. 8 13
      tests/test/tchlp18.pp
  12. 8 10
      tests/test/tchlp19.pp
  13. 10 34
      tests/test/tchlp2.pp
  14. 8 9
      tests/test/tchlp20.pp
  15. 9 9
      tests/test/tchlp21.pp
  16. 8 24
      tests/test/tchlp22.pp
  17. 7 24
      tests/test/tchlp23.pp
  18. 30 7
      tests/test/tchlp24.pp
  19. 10 4
      tests/test/tchlp25.pp
  20. 5 8
      tests/test/tchlp26.pp
  21. 18 14
      tests/test/tchlp27.pp
  22. 23 18
      tests/test/tchlp28.pp
  23. 32 18
      tests/test/tchlp29.pp
  24. 15 4
      tests/test/tchlp3.pp
  25. 22 14
      tests/test/tchlp30.pp
  26. 23 11
      tests/test/tchlp31.pp
  27. 23 7
      tests/test/tchlp32.pp
  28. 26 12
      tests/test/tchlp33.pp
  29. 17 7
      tests/test/tchlp34.pp
  30. 27 11
      tests/test/tchlp35.pp
  31. 29 12
      tests/test/tchlp36.pp
  32. 13 27
      tests/test/tchlp37.pp
  33. 18 17
      tests/test/tchlp38.pp
  34. 23 23
      tests/test/tchlp39.pp
  35. 15 5
      tests/test/tchlp4.pp
  36. 20 18
      tests/test/tchlp40.pp
  37. 37 11
      tests/test/tchlp41.pp
  38. 25 48
      tests/test/tchlp42.pp
  39. 15 31
      tests/test/tchlp43.pp
  40. 13 13
      tests/test/tchlp44.pp
  41. 25 9
      tests/test/tchlp45.pp
  42. 37 9
      tests/test/tchlp46.pp
  43. 42 9
      tests/test/tchlp47.pp
  44. 42 9
      tests/test/tchlp48.pp
  45. 37 9
      tests/test/tchlp49.pp
  46. 19 8
      tests/test/tchlp5.pp
  47. 27 10
      tests/test/tchlp50.pp
  48. 34 10
      tests/test/tchlp51.pp
  49. 57 8
      tests/test/tchlp52.pp
  50. 70 13
      tests/test/tchlp53.pp
  51. 100 10
      tests/test/tchlp54.pp
  52. 0 26
      tests/test/tchlp55.pp
  53. 0 34
      tests/test/tchlp56.pp
  54. 0 30
      tests/test/tchlp57.pp
  55. 0 31
      tests/test/tchlp58.pp
  56. 18 11
      tests/test/tchlp6.pp
  57. 0 51
      tests/test/tchlp62.pp
  58. 0 51
      tests/test/tchlp63.pp
  59. 0 46
      tests/test/tchlp64.pp
  60. 0 47
      tests/test/tchlp67.pp
  61. 0 48
      tests/test/tchlp68.pp
  62. 28 11
      tests/test/tchlp7.pp
  63. 0 18
      tests/test/tchlp78.pp
  64. 0 23
      tests/test/tchlp79.pp
  65. 27 7
      tests/test/tchlp8.pp
  66. 0 26
      tests/test/tchlp82.pp
  67. 0 26
      tests/test/tchlp83.pp
  68. 0 26
      tests/test/tchlp84.pp
  69. 0 26
      tests/test/tchlp85.pp
  70. 0 30
      tests/test/tchlp86.pp
  71. 0 33
      tests/test/tchlp87.pp
  72. 0 42
      tests/test/tchlp88.pp
  73. 0 47
      tests/test/tchlp89.pp
  74. 9 19
      tests/test/tchlp9.pp
  75. 0 51
      tests/test/tchlp90.pp
  76. 18 0
      tests/test/thlp1.pp
  77. 20 0
      tests/test/thlp10.pp
  78. 21 0
      tests/test/thlp11.pp
  79. 21 0
      tests/test/thlp12.pp
  80. 24 0
      tests/test/thlp13.pp
  81. 25 0
      tests/test/thlp14.pp
  82. 18 0
      tests/test/thlp15.pp
  83. 17 0
      tests/test/thlp16.pp
  84. 23 0
      tests/test/thlp17.pp
  85. 21 0
      tests/test/thlp18.pp
  86. 20 0
      tests/test/thlp19.pp
  87. 28 0
      tests/test/thlp2.pp
  88. 19 0
      tests/test/thlp20.pp
  89. 19 0
      tests/test/thlp21.pp
  90. 19 0
      tests/test/thlp22.pp
  91. 24 0
      tests/test/thlp23.pp
  92. 1 2
      tests/test/thlp24.pp
  93. 1 2
      tests/test/thlp25.pp
  94. 4 4
      tests/test/thlp26.pp
  95. 1 2
      tests/test/thlp27.pp
  96. 1 2
      tests/test/thlp28.pp
  97. 5 7
      tests/test/thlp29.pp
  98. 28 0
      tests/test/thlp3.pp
  99. 2 4
      tests/test/thlp30.pp
  100. 18 0
      tests/test/thlp31.pp

+ 95 - 51
.gitattributes

@@ -9567,45 +9567,10 @@ tests/test/tchlp51.pp svneol=native#text/pascal
 tests/test/tchlp52.pp svneol=native#text/pascal
 tests/test/tchlp53.pp svneol=native#text/pascal
 tests/test/tchlp54.pp svneol=native#text/pascal
-tests/test/tchlp55.pp svneol=native#text/pascal
-tests/test/tchlp56.pp svneol=native#text/pascal
-tests/test/tchlp57.pp svneol=native#text/pascal
-tests/test/tchlp58.pp svneol=native#text/pascal
-tests/test/tchlp59.pp svneol=native#text/pascal
 tests/test/tchlp6.pp svneol=native#text/pascal
-tests/test/tchlp61.pp svneol=native#text/pascal
-tests/test/tchlp62.pp svneol=native#text/pascal
-tests/test/tchlp63.pp svneol=native#text/pascal
-tests/test/tchlp64.pp svneol=native#text/pascal
-tests/test/tchlp65.pp svneol=native#text/pascal
-tests/test/tchlp66.pp svneol=native#text/pascal
-tests/test/tchlp67.pp svneol=native#text/pascal
-tests/test/tchlp68.pp svneol=native#text/pascal
-tests/test/tchlp69.pp svneol=native#text/pascal
 tests/test/tchlp7.pp svneol=native#text/pascal
-tests/test/tchlp70.pp svneol=native#text/pascal
-tests/test/tchlp71.pp svneol=native#text/pascal
-tests/test/tchlp72.pp svneol=native#text/pascal
-tests/test/tchlp73.pp svneol=native#text/pascal
-tests/test/tchlp74.pp svneol=native#text/pascal
-tests/test/tchlp75.pp svneol=native#text/pascal
-tests/test/tchlp76.pp svneol=native#text/pascal
-tests/test/tchlp77.pp svneol=native#text/pascal
-tests/test/tchlp78.pp svneol=native#text/pascal
-tests/test/tchlp79.pp svneol=native#text/pascal
 tests/test/tchlp8.pp svneol=native#text/pascal
-tests/test/tchlp80.pp svneol=native#text/pascal
-tests/test/tchlp81.pp svneol=native#text/pascal
-tests/test/tchlp82.pp svneol=native#text/pascal
-tests/test/tchlp83.pp svneol=native#text/pascal
-tests/test/tchlp84.pp svneol=native#text/pascal
-tests/test/tchlp85.pp svneol=native#text/pascal
-tests/test/tchlp86.pp svneol=native#text/pascal
-tests/test/tchlp87.pp svneol=native#text/pascal
-tests/test/tchlp88.pp svneol=native#text/pascal
-tests/test/tchlp89.pp svneol=native#text/pascal
 tests/test/tchlp9.pp svneol=native#text/pascal
-tests/test/tchlp90.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
@@ -9765,6 +9730,50 @@ tests/test/theap.pp svneol=native#text/plain
 tests/test/theapthread.pp svneol=native#text/plain
 tests/test/thintdir.pp svneol=native#text/plain
 tests/test/thintdir1.pp svneol=native#text/pascal
+tests/test/thlp1.pp svneol=native#text/pascal
+tests/test/thlp10.pp svneol=native#text/pascal
+tests/test/thlp11.pp svneol=native#text/pascal
+tests/test/thlp12.pp svneol=native#text/pascal
+tests/test/thlp13.pp svneol=native#text/pascal
+tests/test/thlp14.pp svneol=native#text/pascal
+tests/test/thlp15.pp svneol=native#text/pascal
+tests/test/thlp16.pp svneol=native#text/pascal
+tests/test/thlp17.pp svneol=native#text/pascal
+tests/test/thlp18.pp svneol=native#text/pascal
+tests/test/thlp19.pp svneol=native#text/pascal
+tests/test/thlp2.pp svneol=native#text/pascal
+tests/test/thlp20.pp svneol=native#text/pascal
+tests/test/thlp21.pp svneol=native#text/pascal
+tests/test/thlp22.pp svneol=native#text/pascal
+tests/test/thlp23.pp svneol=native#text/pascal
+tests/test/thlp24.pp svneol=native#text/pascal
+tests/test/thlp25.pp svneol=native#text/pascal
+tests/test/thlp26.pp svneol=native#text/pascal
+tests/test/thlp27.pp svneol=native#text/pascal
+tests/test/thlp28.pp svneol=native#text/pascal
+tests/test/thlp29.pp svneol=native#text/pascal
+tests/test/thlp3.pp svneol=native#text/pascal
+tests/test/thlp30.pp svneol=native#text/pascal
+tests/test/thlp31.pp svneol=native#text/pascal
+tests/test/thlp32.pp svneol=native#text/pascal
+tests/test/thlp33.pp svneol=native#text/pascal
+tests/test/thlp34.pp svneol=native#text/pascal
+tests/test/thlp35.pp svneol=native#text/pascal
+tests/test/thlp36.pp svneol=native#text/pascal
+tests/test/thlp37.pp svneol=native#text/pascal
+tests/test/thlp38.pp svneol=native#text/pascal
+tests/test/thlp39.pp svneol=native#text/pascal
+tests/test/thlp4.pp svneol=native#text/pascal
+tests/test/thlp40.pp svneol=native#text/pascal
+tests/test/thlp41.pp svneol=native#text/pascal
+tests/test/thlp42.pp svneol=native#text/pascal
+tests/test/thlp43.pp svneol=native#text/pascal
+tests/test/thlp44.pp svneol=native#text/pascal
+tests/test/thlp5.pp svneol=native#text/pascal
+tests/test/thlp6.pp svneol=native#text/pascal
+tests/test/thlp7.pp svneol=native#text/pascal
+tests/test/thlp8.pp svneol=native#text/pascal
+tests/test/thlp9.pp svneol=native#text/pascal
 tests/test/timplements1.pp svneol=native#text/plain
 tests/test/timplements2.pp svneol=native#text/plain
 tests/test/timplements3.pp svneol=native#text/plain
@@ -10031,6 +10040,47 @@ tests/test/trecreg2.pp svneol=native#text/plain
 tests/test/trecreg3.pp svneol=native#text/plain
 tests/test/trecreg4.pp svneol=native#text/plain
 tests/test/tresstr.pp svneol=native#text/plain
+tests/test/trhlp1.pp svneol=native#text/pascal
+tests/test/trhlp10.pp svneol=native#text/pascal
+tests/test/trhlp11.pp svneol=native#text/pascal
+tests/test/trhlp12.pp svneol=native#text/pascal
+tests/test/trhlp13.pp svneol=native#text/pascal
+tests/test/trhlp14.pp svneol=native#text/pascal
+tests/test/trhlp15.pp svneol=native#text/pascal
+tests/test/trhlp16.pp svneol=native#text/pascal
+tests/test/trhlp17.pp svneol=native#text/pascal
+tests/test/trhlp18.pp svneol=native#text/pascal
+tests/test/trhlp19.pp svneol=native#text/pascal
+tests/test/trhlp2.pp svneol=native#text/pascal
+tests/test/trhlp20.pp svneol=native#text/pascal
+tests/test/trhlp21.pp svneol=native#text/pascal
+tests/test/trhlp22.pp svneol=native#text/pascal
+tests/test/trhlp23.pp svneol=native#text/pascal
+tests/test/trhlp24.pp svneol=native#text/pascal
+tests/test/trhlp25.pp svneol=native#text/pascal
+tests/test/trhlp26.pp svneol=native#text/pascal
+tests/test/trhlp27.pp svneol=native#text/pascal
+tests/test/trhlp28.pp svneol=native#text/pascal
+tests/test/trhlp29.pp svneol=native#text/pascal
+tests/test/trhlp3.pp svneol=native#text/pascal
+tests/test/trhlp30.pp svneol=native#text/pascal
+tests/test/trhlp31.pp svneol=native#text/pascal
+tests/test/trhlp32.pp svneol=native#text/pascal
+tests/test/trhlp33.pp svneol=native#text/pascal
+tests/test/trhlp34.pp svneol=native#text/pascal
+tests/test/trhlp35.pp svneol=native#text/pascal
+tests/test/trhlp36.pp svneol=native#text/pascal
+tests/test/trhlp37.pp svneol=native#text/pascal
+tests/test/trhlp38.pp svneol=native#text/pascal
+tests/test/trhlp39.pp svneol=native#text/pascal
+tests/test/trhlp4.pp svneol=native#text/pascal
+tests/test/trhlp40.pp svneol=native#text/pascal
+tests/test/trhlp41.pp svneol=native#text/pascal
+tests/test/trhlp5.pp svneol=native#text/pascal
+tests/test/trhlp6.pp svneol=native#text/pascal
+tests/test/trhlp7.pp svneol=native#text/pascal
+tests/test/trhlp8.pp svneol=native#text/pascal
+tests/test/trhlp9.pp svneol=native#text/pascal
 tests/test/trox1.pp svneol=native#text/plain
 tests/test/trox2.pp svneol=native#text/plain
 tests/test/trstr1.pp svneol=native#text/plain
@@ -10138,22 +10188,8 @@ 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/uchlp45.pp svneol=native#text/pascal
-tests/test/uchlp50.pp svneol=native#text/pascal
-tests/test/uchlp51a.pp svneol=native#text/pascal
-tests/test/uchlp51b.pp svneol=native#text/pascal
-tests/test/uchlp51c.pp svneol=native#text/pascal
-tests/test/uchlp82.pp svneol=native#text/pascal
+tests/test/uchlp12.pp svneol=native#text/pascal
+tests/test/uchlp18.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
@@ -10162,6 +10198,12 @@ tests/test/ugeneric3.pp svneol=native#text/plain
 tests/test/ugeneric4.pp svneol=native#text/plain
 tests/test/ugeneric7.pp svneol=native#text/plain
 tests/test/uhintdir.pp svneol=native#text/plain
+tests/test/uhlp3.pp svneol=native#text/pascal
+tests/test/uhlp31.pp svneol=native#text/pascal
+tests/test/uhlp39.pp svneol=native#text/pascal
+tests/test/uhlp41a.pp svneol=native#text/pascal
+tests/test/uhlp41b.pp svneol=native#text/pascal
+tests/test/uhlp43.pp svneol=native#text/pascal
 tests/test/uimpluni1.pp svneol=native#text/plain
 tests/test/uimpluni2.pp svneol=native#text/plain
 tests/test/uinline4a.pp svneol=native#text/plain
@@ -10325,6 +10367,8 @@ tests/test/uprec6.pp svneol=native#text/plain
 tests/test/uprec7.pp svneol=native#text/plain
 tests/test/uprocext1.pp svneol=native#text/plain
 tests/test/uprocext2.pp svneol=native#text/plain
+tests/test/urhlp14.pp svneol=native#text/pascal
+tests/test/urhlp17.pp svneol=native#text/pascal
 tests/test/utasout.pp svneol=native#text/plain
 tests/test/uunit1.pp svneol=native#text/plain
 tests/test/uunit2a.pp svneol=native#text/plain

+ 15 - 36
tests/test/tchlp1.pp

@@ -1,50 +1,29 @@
-{%NORUN}
+{ %NORUN }
 
-{ checks for support of the class helper syntax in mode objfpc }
+{ this tests that helpers can introduce instance methods for classes - mode
+  Delphi }
 program tchlp1;
 
-{$mode objfpc}
+{$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;
+  TTest = class
 
-procedure TObjectHelper.SomePublicMethod;
-begin
-end;
-
-procedure TObjectHelper.SomeStrictPrivateMethod;
-begin
-end;
-
-procedure TObjectHelper.SomePrivateMethod;
-begin
-end;
+  end;
 
-procedure TObjectHelper.SomeStrictProtectedMethod;
-begin
-end;
+  TTestHelper = class helper for TTest
+    procedure Test;
+  end;
 
-procedure TObjectHelper.SomeProtectedMethod;
+procedure TTestHelper.Test;
 begin
-end;
 
-procedure TObjectHelper.SomePublicMethod2;
-begin
 end;
 
+var
+  t: TTest;
 begin
-
+  t.Test;
 end.
-

+ 24 - 9
tests/test/tchlp10.pp

@@ -1,25 +1,40 @@
 { %NORUN }
 
-{ first simple scope test for class helpers }
+{ method modifiers of the extended class are completly irrelevant }
 program tchlp10;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
 type
-  TObjectHelper = class helper for TObject
-    procedure SomeMethod;
+  TTest = class
+    procedure Test; virtual;
   end;
 
-procedure TObjectHelper.SomeMethod;
+  TTestHelper = class helper for TTest
+    procedure Test; virtual;
+  end;
+
+  TTestHelperSub = class helper(TTestHelper) for TTest
+    procedure Test; override;
+  end;
+
+procedure TTest.Test;
 begin
 
 end;
 
-var
-  o: TObject;
+procedure TTestHelper.Test;
 begin
-  o.SomeMethod;
-end.
 
+end;
+
+procedure TTestHelperSub.Test;
+begin
+
+end;
+
+begin
+
+end.

+ 8 - 11
tests/test/tchlp11.pp

@@ -1,23 +1,20 @@
-{ %NORUN }
+{ %FAIL }
 
-{ second simple scope test for class helpers }
+{ it's forbidden for a class helper to extend a record }
 program tchlp11;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
 type
-  TObjectHelper = class helper for TObject
-    class procedure SomeMethod;
-  end;
+  TTest = record
 
-class procedure TObjectHelper.SomeMethod;
-begin
+  end;
 
-end;
+  TTestHelper = class helper for TTest
+  end;
 
 begin
-  TObject.SomeMethod;
-end.
 
+end.

+ 12 - 22
tests/test/tchlp12.pp

@@ -1,35 +1,25 @@
-{ class helpers hide methods of the extended class }
+{ %FAIL }
+
+{ class helpers can access (strict) protected, public and published members -
+  here: strict private }
 program tchlp12;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
-type
-  TFoo = class
-    function Test: Integer;
-  end;
+uses
+  uchlp12;
 
-  TFooHelper = class helper for TFoo
-    function Test: Integer;
+type
+  TTestHelper = class helper for TTest
+    function AccessTest: Integer;
   end;
 
-function TFoo.Test: Integer;
+function TTestHelper.AccessTest: Integer;
 begin
-  Result := 1;
+  Result := Test1;
 end;
 
-function TFooHelper.Test: Integer;
 begin
-  Result := 2;
-end;
-
-var
-  f: TFoo;
-begin
-  f := TFoo.Create;
-  if f.Test <> 2 then
-    Halt(1);
-  Writeln('ok');
 end.
-

+ 12 - 30
tests/test/tchlp13.pp

@@ -1,44 +1,26 @@
-{ class helpers don't hide methods of the subclasses of the extended class }
+{ %FAIL }
+
+{ class helpers can access (strict) protected, public and published members -
+  here: private }
 program tchlp13;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
-type
-  TFoo = class
-    function Test: Integer;
-  end;
-
-  TFooHelper = class helper for TFoo
-    function Test: Integer;
-  end;
+uses
+  uchlp12;
 
-  TFooSub = class(TFoo)
-    function Test: Integer;
+type
+  TTestHelper = class helper for TTest
+    function AccessTest: Integer;
   end;
 
-function TFoo.Test: Integer;
-begin
-  Result := 1;
-end;
-
-function TFooHelper.Test: Integer;
-begin
-  Result := 2;
-end;
-
-function TFooSub.Test: Integer;
+function TTestHelper.AccessTest: Integer;
 begin
-  Result := 3;
+  Result := Test2;
 end;
 
-var
-  f: TFooSub;
 begin
-  f := TFooSub.Create;
-  if f.Test <> 3 then
-    Halt(1);
-  Writeln('ok');
 end.
 

+ 10 - 16
tests/test/tchlp14.pp

@@ -1,32 +1,26 @@
-{ %FAIL }
+{ %NORUN }
 
-{ class helpers must not override virtual methods of the extended class }
+{ class helpers can access (strict) protected, public and published members -
+  here: strict protected }
 program tchlp14;
 
 {$ifdef fpc}
   {$mode delphi}
 {$endif}
 
-type
-  TFoo = class
-    function Test: Integer; virtual;
-  end;
+uses
+  uchlp12;
 
-  TFooHelper = class helper for TFoo
-    function Test: Integer; override;
+type
+  TTestHelper = class helper for TTest
+    function AccessTest: Integer;
   end;
 
-function TFoo.Test: Integer;
+function TTestHelper.AccessTest: Integer;
 begin
-  Result := 1;
+  Result := Test3;
 end;
 
-function TFooHelper.Test: Integer;
 begin
-  Result := 2;
-end;
-
-begin
-
 end.
 

+ 12 - 21
tests/test/tchlp15.pp

@@ -1,35 +1,26 @@
-{ class helpers may hide virtual methods of the extended class }
+{ %NORUN }
+
+{ class helpers can access (strict) protected, public and published members -
+  here: protected }
 program tchlp15;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
-type
-  TFoo = class
-    function Test: Integer; virtual;
-  end;
+uses
+  uchlp12;
 
-  TFooHelper = class helper for TFoo
-    function Test: Integer;
+type
+  TTestHelper = class helper for TTest
+    function AccessTest: Integer;
   end;
 
-function TFoo.Test: Integer;
-begin
-  Result := 1;
-end;
-
-function TFooHelper.Test: Integer;
+function TTestHelper.AccessTest: Integer;
 begin
-  Result := 2;
+  Result := Test4;
 end;
 
-var
-  f: TFoo;
 begin
-  f := TFoo.Create;
-  if f.Test <> 2 then
-    Halt(1);
-  Writeln('ok');
 end.
 

+ 14 - 6
tests/test/tchlp16.pp

@@ -1,18 +1,26 @@
-{ %FAIL }
+{ %NORUN }
 
-{ class helpers may not be referenced in any way - test 1 }
+{ class helpers can access (strict) protected, public and published members -
+  here: public }
 program tchlp16;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
+uses
+  uchlp12;
+
 type
-  TObjectHelper = class helper for TObject
+  TTestHelper = class helper for TTest
+    function AccessTest: Integer;
   end;
 
-var
-  o: TObjectHelper;
+function TTestHelper.AccessTest: Integer;
+begin
+  Result := Test5;
+end;
+
 begin
 end.
 

+ 14 - 5
tests/test/tchlp17.pp

@@ -1,17 +1,26 @@
-{ %FAIL }
+{ %NORUN }
 
-{ class helpers may not be referenced in any way - test 2 }
+{ class helpers can access (strict) protected, public and published members -
+  here: published }
 program tchlp17;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
+uses
+  uchlp12;
+
 type
-  TObjectHelper = class helper for TObject
+  TTestHelper = class helper for TTest
+    function AccessTest: Integer;
   end;
 
+function TTestHelper.AccessTest: Integer;
+begin
+  Result := Test6;
+end;
+
 begin
-  with TObjectHelper.Create do ;
 end.
 

+ 8 - 13
tests/test/tchlp18.pp

@@ -1,23 +1,18 @@
 { %FAIL }
 
-{ class helpers may not be referenced in any way - test 3 }
+{ usage of nested helpers adheres to visibility rules as well - here:
+  strict private }
 program tchlp18;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
-type
-  TObjectHelper = class helper for TObject
-    class procedure Test;
-  end;
+uses
+  uchlp18;
 
-class procedure TObjectHelper.Test;
+var
+  t: TTest1;
 begin
-
-end;
-
-begin
-  TObjectHelper.Test;
+  t.Test;
 end.
-

+ 8 - 10
tests/test/tchlp19.pp

@@ -1,21 +1,19 @@
 { %FAIL }
 
-{ class helpers may not be referenced in any way - test 4 }
+{ usage of nested helpers adheres to visibility rules as well - here:
+  private }
 program tchlp19;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
-type
-  TObjectHelper = class helper for TObject
-  end;
-
-procedure SomeProc(aHelper: TObjectHelper);
-begin
-
-end;
+uses
+  uchlp18;
 
+var
+  t: TTest2;
 begin
+  t.Test;
 end.
 

+ 10 - 34
tests/test/tchlp2.pp

@@ -1,6 +1,7 @@
-{%NORUN}
+{ %NORUN }
 
-{ checks for support of the class helper syntax in mode delphi }
+{ this tests that helpers can introduce class methods for classes - mode
+  Delphi }
 program tchlp2;
 
 {$ifdef fpc}
@@ -8,45 +9,20 @@ program tchlp2;
 {$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;
+  TTest = class
 
-procedure TObjectHelper.SomeStrictPrivateMethod;
-begin
-end;
-
-procedure TObjectHelper.SomePrivateMethod;
-begin
-end;
+  end;
 
-procedure TObjectHelper.SomeStrictProtectedMethod;
-begin
-end;
+  TTestHelper = class helper for TTest
+    class procedure Test;
+  end;
 
-procedure TObjectHelper.SomeProtectedMethod;
+class procedure TTestHelper.Test;
 begin
-end;
 
-procedure TObjectHelper.SomePublicMethod2;
-begin
 end;
 
 begin
-
+  TTest.Test;
 end.
 

+ 8 - 9
tests/test/tchlp20.pp

@@ -1,20 +1,19 @@
 { %FAIL }
 
-{ class helpers may not be referenced in any way - test 5 }
+{ usage of nested helpers adheres to visibility rules as well - here:
+  strict protected }
 program tchlp20;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
-type
-  TObjectHelper = class helper for TObject
-  end;
-
-  TSomeRec = record
-    helper: TObjectHelper;
-  end;
+uses
+  uchlp18;
 
+var
+  t: TTest3;
 begin
+  t.Test;
 end.
 

+ 9 - 9
tests/test/tchlp21.pp

@@ -1,19 +1,19 @@
 { %FAIL }
 
-{ class helpers may not be referenced in any way - test 6 }
-program tchlp21;
+{ usage of nested helpers adheres to visibility rules as well - here:
+  protected }
+program tchlp18;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
-type
-  TObjectHelper = class helper for TObject
-  end;
-
-  TObjectHelperHelper = class helper for TObjectHelper
-  end;
+uses
+  uchlp18;
 
+var
+  t: TTest4;
 begin
+  t.Test;
 end.
 

+ 8 - 24
tests/test/tchlp22.pp

@@ -1,35 +1,19 @@
-{ %FAIL }
+{ %NORUN }
 
-{ overloading needs to be enabled explicitly }
+{ usage of nested helpers adheres to visibility rules as well - here:
+  public }
 program tchlp22;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
-type
-  TFoo = class
-    procedure Test(const aTest: String);
-  end;
-
-  TFooHelper = class helper for TFoo
-    procedure Test;
-  end;
-
-procedure TFoo.Test(const aTest: String);
-begin
-
-end;
-
-procedure TFooHelper.Test;
-begin
-
-end;
+uses
+  uchlp18;
 
 var
-  f: TFoo;
+  t: TTest5;
 begin
-  f := TFoo.Create;
-  f.Test('Foo');
+  t.Test;
 end.
 

+ 7 - 24
tests/test/tchlp23.pp

@@ -1,36 +1,19 @@
 { %NORUN }
 
-{ overloading needs to be enabled explicitly }
+{ usage of nested helpers adheres to visibility rules as well - here:
+  published }
 program tchlp23;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
-type
-  TFoo = class
-    procedure Test(const aTest: String);
-  end;
-
-  TFooHelper = class helper for TFoo
-    procedure Test; overload;
-  end;
-
-procedure TFoo.Test(const aTest: String);
-begin
-
-end;
-
-procedure TFooHelper.Test;
-begin
-
-end;
+uses
+  uchlp18;
 
 var
-  f: TFoo;
+  t: TTest6;
 begin
-  f := TFoo.Create;
-  f.Test;
-  f.Test('Foo');
+  t.Test;
 end.
 

+ 30 - 7
tests/test/tchlp24.pp

@@ -1,19 +1,42 @@
-{ %FAIL }
-
-{ class helpers may not be referenced in any way - test 7 }
+{ published methods of class helpers are not accessible through the extended
+  class' RTTI }
 program tchlp24;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
+{$apptype console}
 
 type
-  TObjectHelper = class helper for TObject
+{$M+}
+  TTest = class
   end;
+{$M-}
 
-  TObjectHelperSub = class(TObjectHelper)
+{$M+}
+  TTestHelper = class helper for TTest
+  published
+    function Test: Integer;
   end;
+{$M-}
 
+function TTestHelper.Test: Integer;
 begin
-end.
+  Result := 1;
+end;
 
+var
+  f: TTest;
+  res: Pointer;
+begin
+  f := TTest.Create;
+  res := f.MethodAddress('Test');
+{$ifdef fpc}
+  Writeln('Address of TTest.Test: ', PtrInt(res));
+{$else}
+  Writeln('Address of TTest.Test: ', NativeInt(res));
+{$endif}
+  if res <> Nil then
+    Halt(1);
+  Writeln('ok');
+end.

+ 10 - 4
tests/test/tchlp25.pp

@@ -1,17 +1,23 @@
-{ %FAIL }
+{ %NORUN }
 
-{ class helpers may not contain any fields }
+{ class helpers can extend a subclass of the parent's extended class }
 program tchlp25;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
 type
   TObjectHelper = class helper for TObject
-    Test: Integer;
+  end;
+
+  TTest = class
+  end;
+
+  TTestHelper = class helper(TObjectHelper) for TTest
   end;
 
 begin
+
 end.
 

+ 5 - 8
tests/test/tchlp26.pp

@@ -1,23 +1,20 @@
-{ %NORUN }
+{ %FAIL }
 
-{ class helpers can extend a subclass of the parent's extended class }
+{ a class helper can only inherit from another class helper }
 program tchlp26;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
 type
-  TObjectHelperA = class helper for TObject
-  end;
+  TTest = class
 
-  TFoo = class
   end;
 
-  TObjectHelperB = class helper(TObjectHelperA) for TFoo
+  TObjectHelper = class helper(TTest) for TObject
   end;
 
 begin
-
 end.
 

+ 18 - 14
tests/test/tchlp27.pp

@@ -1,22 +1,26 @@
-{ extensive scoping test - test 1 }
+{ %FAIL }
+
+{ a class helper must extend a subclass of the parent class helper }
 program tchlp27;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
-uses
-  uchlp27a, uchlp27b;
+type
+  TTest1 = class
+
+  end;
+
+  TTest1Helper = class helper for TTest1
+  end;
+
+  TTest2 = class
+
+  end;
+
+  TTest2Helper = class helper(TTest1Helper) for TTest2
+  end;
 
-var
-  f: TFoo;
-  res: Integer;
 begin
-  f := TFoo.Create;
-  res := f.Test;
-  Writeln('f.Test: ', res);
-  if res <> 2 then
-    Halt(1);
-  Writeln('ok');
 end.
-

+ 23 - 18
tests/test/tchlp28.pp

@@ -1,30 +1,35 @@
-{ extensive scoping test - test 2 }
+{ class helpers hide methods of the extended class }
 program tchlp28;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
-uses
-  uchlp27a, uchlp27b, uchlp27c;
+type
+  TTest = class
+    function Test: Integer;
+  end;
 
-var
-  f: TFoo;
-  b: TBar;
-  res: Integer;
+  TTestHelper = class helper for TTest
+    function Test: Integer;
+  end;
+
+function TTest.Test: Integer;
 begin
-  f := TBar.Create;
-  res := f.Test;
-  Writeln('f.Test: ', res);
-  if res <> 2 then
-    Halt(1);
+  Result := 1;
+end;
 
-  b := TBar.Create;
-  res := b.Test;
-  Writeln('b.Test: ', res);
-  if res <> 3 then
-    Halt(2);
+function TTestHelper.Test: Integer;
+begin
+  Result := 2;
+end;
 
+var
+  t: TTest;
+begin
+  t := TTest.Create;
+  if t.Test <> 2 then
+    Halt(1);
   Writeln('ok');
 end.
 

+ 32 - 18
tests/test/tchlp29.pp

@@ -1,30 +1,44 @@
-{ extensive scoping test - test 3 }
+{ class helpers don't hide methods of the subclasses of the extended class }
 program tchlp29;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
-uses
-  uchlp27a, uchlp27c, uchlp27b;
+type
+  TTest = class
+    function Test: Integer;
+  end;
 
-var
-  f: TFoo;
-  b: TBar;
-  res: Integer;
+  TTestHelper = class helper for TTest
+    function Test: Integer;
+  end;
+
+  TTestSub = class(TTest)
+    function Test: Integer;
+  end;
+
+function TTest.Test: Integer;
 begin
-  f := TBar.Create;
-  res := f.Test;
-  Writeln('f.Test: ', res);
-  if res <> 2 then
-    Halt(1);
+  Result := 1;
+end;
+
+function TTestHelper.Test: Integer;
+begin
+  Result := 2;
+end;
 
-  b := TBar.Create;
-  res := b.Test;
-  Writeln('b.Test: ', res);
-  if res <> 3 then
-    Halt(2);
+function TTestSub.Test: Integer;
+begin
+  Result := 3;
+end;
 
+var
+  t: TTestSub;
+begin
+  t := TTestSub.Create;
+  if t.Test <> 3 then
+    Halt(1);
   Writeln('ok');
 end.
 

+ 15 - 4
tests/test/tchlp3.pp

@@ -1,6 +1,7 @@
-{%FAIL}
+{ %NORUN }
 
-{ forward declarations are not allowed }
+{ this tests that helpers can introduce instance methods for classes - mode
+  ObjFPC }
 program tchlp3;
 
 {$ifdef fpc}
@@ -8,12 +9,22 @@ program tchlp3;
 {$endif}
 
 type
-  TObjectHelper = class helper for TObject;
+  TTest = class
 
-  TObjectHelper = class helper for TObject
   end;
 
+  TTestHelper = class helper for TTest
+    procedure Test;
+  end;
+
+procedure TTestHelper.Test;
 begin
 
+end;
+
+var
+  t: TTest;
+begin
+  t.Test;
 end.
 

+ 22 - 14
tests/test/tchlp30.pp

@@ -1,23 +1,31 @@
-{ extensive scoping test - test 4 }
+{ %FAIL }
+
+{ helpers must not override virtual methods of the extended class }
 program tchlp30;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
-uses
-  uchlp27b, uchlp27a;
+type
+  TTest = class
+    function Test: Integer; virtual;
+  end;
+
+  TTestHelper = class helper for TTest
+    function Test: Integer; override;
+  end;
 
-var
-  f: TFoo;
-  res: Integer;
+function TTest.Test: Integer;
 begin
-  f := TFoo.Create;
-  res := f.Test;
-  Writeln('f.Test: ', res);
-  if res <> 2 then
-    Halt(1);
 
-  Writeln('ok');
-end.
+end;
+
+function TTestHelper.Test: Integer;
+begin
 
+end;
+
+begin
+
+end.

+ 23 - 11
tests/test/tchlp31.pp

@@ -1,23 +1,35 @@
-{ extensive scoping test - test 5 }
+{ helpers may hide virtual methods of the extended class }
 program tchlp31;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
-uses
-  uchlp27b, uchlp27c;
+type
+  TTest = class
+    function Test: Integer; virtual;
+  end;
+
+  TTestHelper = class helper for TTest
+    function Test: Integer;
+  end;
+
+function TTest.Test: Integer;
+begin
+  Result := 1;
+end;
+
+function TTestHelper.Test: Integer;
+begin
+  Result := 2;
+end;
 
 var
-  b: TBar;
-  res: Integer;
+  t: TTest;
 begin
-  b := TBar.Create;
-  res := b.Test;
-  Writeln('b.Test: ', res);
-  if res <> 3 then
+  t := TTest.Create;
+  if t.Test <> 2 then
     Halt(1);
-
   Writeln('ok');
 end.
 

+ 23 - 7
tests/test/tchlp32.pp

@@ -1,19 +1,35 @@
 { %FAIL }
 
-{ only the last available class helper for a class must be used - test 1 }
+{ overloading needs to be enabled explicitly }
 program tchlp32;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
-uses
-  uchlp32a, uchlp32b, uchlp32c;
+type
+  TTest = class
+    procedure Test(const aTest: String);
+  end;
+
+  TTestHelper = class helper for TTest
+    procedure Test;
+  end;
+
+procedure TTest.Test(const aTest: String);
+begin
+
+end;
+
+procedure TTestHelper.Test;
+begin
+
+end;
 
 var
-  f: TFoo;
+  t: TTest;
 begin
-  f := TFoo.Create;
-  f.Method1;
+  t := TTest.Create;
+  t.Test('Foo');
 end.
 

+ 26 - 12
tests/test/tchlp33.pp

@@ -1,22 +1,36 @@
-{ only the last available class helper for a class must be used - test 2 }
+{ %NORUN }
+
+{ overloading needs to be enabled explicitly }
 program tchlp33;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
-uses
-  uchlp33a, uchlp33c, uchlp33b;
+type
+  TTest = class
+    procedure Test(const aTest: String);
+  end;
+
+  TTestHelper = class helper for TTest
+    procedure Test; overload;
+  end;
+
+procedure TTest.Test(const aTest: String);
+begin
+
+end;
+
+procedure TTestHelper.Test;
+begin
+
+end;
 
 var
-  f: TFoo;
-  res: Integer;
+  t: TTest;
 begin
-  f := TFoo.Create;
-  res := f.Test;
-  Writeln('f.Test: ', res);
-  if res <> 1 then
-    Halt(1);
-  Writeln('ok');
+  t := TTest.Create;
+  t.Test;
+  t.Test('Foo');
 end.
 

+ 17 - 7
tests/test/tchlp34.pp

@@ -1,20 +1,30 @@
-{ %FAIL }
+{ %NORUN }
 
-{ a class helper can only inherit from another class helper }
+{ a helper can already be accessed when implementing a class' methods }
 program tchlp34;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
 type
-  TFoo = class
-
+  TTest = class
+    procedure Test;
   end;
 
-  TObjectHelper = class helper(TFoo) for TObject
+  TTestHelper = class helper for TTest
+    procedure DoSomething;
   end;
 
+procedure TTest.Test;
+begin
+  DoSomething;
+end;
+
+procedure TTestHelper.DoSomething;
 begin
-end.
 
+end;
+
+begin
+end.

+ 27 - 11
tests/test/tchlp35.pp

@@ -1,4 +1,4 @@
-{ tests virtual methods inside class helpers }
+{ helper methods also influence calls to a parent's method in a derived class }
 program tchlp35;
 
 {$ifdef fpc}
@@ -6,26 +6,42 @@ program tchlp35;
 {$endif}
 {$apptype console}
 
-uses
-  uchlp35;
-
 type
-  TObjectHelperB = class helper(TObjectHelperA) for TObject
-    function VirtualTest: Integer; override;
+  TTest = class
+    function Test: Integer;
+  end;
+
+  TTestSub = class(TTest)
+    function AccessTest: Integer;
   end;
 
-function TObjectHelperB.VirtualTest: Integer;
+  TTestHelper = class helper for TTest
+    function Test: Integer;
+  end;
+
+function TTest.Test: Integer;
+begin
+  Result := 1;
+end;
+
+function TTestSub.AccessTest: Integer;
+begin
+  Result := Test;
+end;
+
+function TTestHelper.Test: Integer;
 begin
   Result := 2;
 end;
 
 var
-  o: TObject;
+  t: TTestSub;
   res: Integer;
 begin
-  o := TObject.Create;
-  res := o.Test;
+  t := TTestSub.Create;
+  res := t.AccessTest;
+  Writeln('f.AccessTest: ', res);
   if res <> 2 then
     Halt(1);
+  Writeln('ok');
 end.
-

+ 29 - 12
tests/test/tchlp36.pp

@@ -1,31 +1,48 @@
-{ %FAIL }
-
-{ a class helper must extend a subclass of the parent class helper }
+{ helper methods also influence calls to a parent's method in a derived class }
 program tchlp36;
 
 {$ifdef fpc}
   {$mode delphi}
 {$endif}
+{$apptype console}
 
 type
-  TBar = class
-
+  TTest = class
+    function Test: Integer;
   end;
 
-  TBarHelper = class helper for TBar
-    procedure Test;
+  TTestSub = class(TTest)
+    function AccessTest: Integer;
   end;
 
-  TFoo = class
-
+  TTestHelper = class helper for TTest
+    function Test: Integer;
   end;
 
-  TFooHelper = class helper(TBarHelper) for TFoo
-  end;
+function TTest.Test: Integer;
+begin
+  Result := 1;
+end;
 
-procedure TBarHelper.Test;
+function TTestSub.AccessTest: Integer;
 begin
+  Result := inherited Test;
 end;
 
+function TTestHelper.Test: Integer;
 begin
+  Result := 2;
+end;
+
+var
+  t: TTestSub;
+  res: Integer;
+begin
+  t := TTestSub.Create;
+  res := t.AccessTest;
+  Writeln('f.AccessTest: ', res);
+  if res <> 2 then
+    Halt(1);
+  Writeln('ok');
 end.
+

+ 13 - 27
tests/test/tchlp37.pp

@@ -1,47 +1,33 @@
-{ a parent class helper's methods are available in a child class helper }
+{ %NORUN }
+
+{ helpers of a parent are available in a subclass as well }
 program tchlp37;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 {$apptype console}
 
 type
-  TFoo = class
-    function Test: Integer;
-  end;
+  TTest = class
 
-  TFooHelper = class helper for TFoo
-    function Test: Integer;
   end;
 
-  TFooBarHelper = class helper(TFooHelper) for TFoo
-    function AccessTest: Integer;
+  TTestSub = class(TTest)
+
   end;
 
-function TFoo.Test: Integer;
-begin
-  Result := 1;
-end;
+  TTestHelper = class helper for TTest
+    procedure Test;
+  end;
 
-function TFooHelper.Test: Integer;
+procedure TTestHelper.Test;
 begin
-  Result := 2;
-end;
 
-function TFooBarHelper.AccessTest: Integer;
-begin
-  Result := Test;
 end;
 
 var
-  f: TFoo;
-  res: Integer;
+  t: TTestSub;
 begin
-  f := TFoo.Create;
-  res := f.AccessTest;
-  Writeln(res);
-  if res <> 2 then
-    Halt(1);
-  Writeln('ok');
+  t.Test;
 end.

+ 18 - 17
tests/test/tchlp38.pp

@@ -1,41 +1,42 @@
-{ methods of the extended class can be called using "inherited" }
+{ a helper of a parent class hides the parent's methods }
 program tchlp38;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 {$apptype console}
 
 type
-  TFoo = class
-    function Test(aRecurse: Boolean): Integer;
+  TTest = class
+    function Test: Integer;
   end;
 
-  TFooHelper = class helper for TFoo
-    function Test(aRecurse: Boolean): Integer;
+  TTestSub = class(TTest)
+
+  end;
+
+  TTestHelper = class helper for TTest
+    function Test: Integer;
   end;
 
-function TFoo.Test(aRecurse: Boolean): Integer;
+function TTest.Test: Integer;
 begin
   Result := 1;
 end;
 
-function TFooHelper.Test(aRecurse: Boolean): Integer;
+function TTestHelper.Test: Integer;
 begin
-  if aRecurse then
-    Result := inherited Test(False)
-  else
-    Result := 2;
+  Result := 2;
 end;
 
 var
-  f: TFoo;
+  t: TTestSub;
   res: Integer;
 begin
-  f := TFoo.Create;
-  res := f.Test(True);
-  Writeln('f.Test: ', res);
-  if res <> 1 then
+  t := TTestSub.Create;
+  res := t.Test;
+  Writeln('b.TestFoo: ', res);
+  if res <> 2 then
     Halt(1);
   Writeln('ok');
 end.

+ 23 - 23
tests/test/tchlp39.pp

@@ -1,51 +1,51 @@
-{ the extended class has higher priority than the parent class when
-  searching for symbols }
-program tchlp39;
+{ a helper of a parent class hides methods in the child class if its also a
+  parent of the helper for the child class }
+program tchlp90;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 {$apptype console}
 
 type
-  TFoo = class
-    function Test(aRecurse: Boolean): Integer;
+  TTest = class
+    function Test: Integer;
   end;
 
-  TFooHelper = class helper for TFoo
-    function Test(aRecurse: Boolean): Integer;
+  TTestSub = class(TTest)
+     function Test: Integer;
   end;
 
-  TFooSubHelper = class helper(TFooHelper) for TFoo
-    function Test(aRecurse: Boolean): Integer;
+  TTestHelper = class helper for TTest
+    function Test: Integer;
   end;
 
-function TFoo.Test(aRecurse: Boolean): Integer;
+  TTestSubHelper = class helper(TTestHelper) for TTestSub
+  end;
+
+function TTest.Test: Integer;
 begin
   Result := 1;
 end;
 
-function TFooHelper.Test(aRecurse: Boolean): Integer;
+function TTestSub.Test: Integer;
 begin
-  Result := 2;
+  Result := 4;
 end;
 
-function TFooSubHelper.Test(aRecurse: Boolean): Integer;
+function TTestHelper.Test: Integer;
 begin
-  if aRecurse then
-    Result := inherited Test(False)
-  else
-    Result := 3;
+  Result := 2;
 end;
 
 var
-  f: TFoo;
+  t: TTestSub;
   res: Integer;
 begin
-  f := TFoo.Create;
-  res := f.Test(True);
-  Writeln('f.Test: ', res);
-  if res <> 1 then
+  t := TTestSub.Create;
+  res := t.Test;
+  Writeln('b.TestFoo: ', res);
+  if res <> 2 then
     Halt(1);
   Writeln('ok');
 end.

+ 15 - 5
tests/test/tchlp4.pp

@@ -1,18 +1,28 @@
-{%FAIL}
+{ %NORUN }
 
-{ destructors are not allowed }
+{ this tests that helpers can introduce class methods for classes - mode
+  ObjFPC }
 program tchlp4;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
 type
-  TObjectHelper = class helper for TObject
-    destructor Destroy; override;
+  TTest = class
+
+  end;
+
+  TTestHelper = class helper for TTest
+    class procedure Test;
   end;
 
+class procedure TTestHelper.Test;
 begin
 
+end;
+
+begin
+  TTest.Test;
 end.
 

+ 20 - 18
tests/test/tchlp40.pp

@@ -1,4 +1,4 @@
-{ published is allowed in mode Delphi, but unusable }
+{ methods of the extended class can be called using "inherited" }
 program tchlp40;
 
 {$ifdef fpc}
@@ -7,33 +7,35 @@ program tchlp40;
 {$apptype console}
 
 type
-  {$M+}
-  TFoo = class
+  TTest = class
+    function Test(aRecurse: Boolean): Integer;
   end;
-  {$M-}
 
-  TFooHelper = class helper for TFoo
-  published
-    function Test: Integer;
+  TTestHelper = class helper for TTest
+    function Test(aRecurse: Boolean): Integer;
   end;
 
-function TFooHelper.Test: Integer;
+function TTest.Test(aRecurse: Boolean): Integer;
 begin
   Result := 1;
 end;
 
+function TTestHelper.Test(aRecurse: Boolean): Integer;
+begin
+  if aRecurse then
+    Result := inherited Test(False)
+  else
+    Result := 2;
+end;
+
 var
-  f: TFoo;
-  res: Pointer;
+  t: TTest;
+  res: Integer;
 begin
-  f := TFoo.Create;
-  res := f.MethodAddress('Test');
-{$ifdef fpc}
-  Writeln('Address of TFoo.Test: ', res);
-{$else}
-  Writeln('Address of TFoo.Test: ', Integer(res));
-{$endif}
-  if res <> Nil then
+  t := TTest.Create;
+  res := t.Test(True);
+  Writeln('t.Test: ', res);
+  if res <> 1 then
     Halt(1);
   Writeln('ok');
 end.

+ 37 - 11
tests/test/tchlp41.pp

@@ -1,25 +1,51 @@
-{ %FAIL }
-
-{ puplished members are not allowed in mode objfpc }
+{ the extended class has higher priority than the parent class when
+  searching for symbols }
 program tchlp41;
 
-{$mode objfpc}
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+{$apptype console}
 
 type
-  {$M+}
-  TFoo = class
+  TTest = class
+    function Test(aRecurse: Boolean): Integer;
+  end;
+
+  TTestHelper = class helper for TTest
+    function Test(aRecurse: Boolean): Integer;
   end;
-  {$M-}
 
-  TFooHelper = class helper for TFoo
-  published
-    function Test: Integer;
+  TTestHelperSub = class helper(TTestHelper) for TTest
+    function Test(aRecurse: Boolean): Integer;
   end;
 
-function TFooHelper.Test: Integer;
+function TTest.Test(aRecurse: Boolean): Integer;
 begin
   Result := 1;
 end;
 
+function TTestHelper.Test(aRecurse: Boolean): Integer;
+begin
+  Result := 2;
+end;
+
+function TTestHelperSub.Test(aRecurse: Boolean): Integer;
+begin
+  if aRecurse then
+    Result := inherited Test(False)
+  else
+    Result := 3;
+end;
+
+var
+  t: TTest;
+  res: Integer;
 begin
+  t := TTest.Create;
+  res := t.Test(True);
+  Writeln('t.Test: ', res);
+  if res <> 1 then
+    Halt(1);
+  Writeln('ok');
 end.

+ 25 - 48
tests/test/tchlp42.pp

@@ -1,74 +1,51 @@
-{ a class helper may introduce a enumerator }
+{ the extended type is searched first for a inherited method even if it's
+  defined as "override" }
 program tchlp42;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 {$apptype console}
 
 type
-  TContainer = class
-    Contents: array[0..5] of Integer;
-    constructor Create;
+  TTest = class
+    function Test(aRecurse: Boolean): Integer; virtual;
   end;
 
-  TContainerEnum = class
-  private
-    fIndex: Integer;
-    fContainer: TContainer;
-  public
-    constructor Create(aContainer: TContainer);
-    function GetCurrent: Integer;
-    function MoveNext: Boolean;
-    property Current: Integer read GetCurrent;
+  TObjectHelper = class helper for TObject
+    function Test(aRecurse: Boolean): Integer; virtual;
   end;
 
-  TContainerHelper = class helper for TContainer
-    function GetEnumerator: TContainerEnum;
+  TTestHelper = class helper(TObjectHelper) for TTest
+    function Test(aRecurse: Boolean): Integer; override;
   end;
 
-{ TContainer }
-
-constructor TContainer.Create;
-var
-  i: Integer;
-begin
-  for i := Low(Contents) to High(Contents) do
-    Contents[i] := High(Contents) - i;
-end;
-
-{ TContainerHelper }
-
-function TContainerHelper.GetEnumerator: TContainerEnum;
-begin
-  Result := TContainerEnum.Create(Self);
-end;
-
-{ TContainerEnum }
-
-constructor TContainerEnum.Create(aContainer: TContainer);
+function TTest.Test(aRecurse: Boolean): Integer;
 begin
-  fContainer := aContainer;
-  fIndex := Low(fContainer.Contents) - 1;
+  Result := 1;
 end;
 
-function TContainerEnum.GetCurrent: Integer;
+function TObjectHelper.Test(aRecurse: Boolean): Integer;
 begin
-  Result := fContainer.Contents[fIndex];
+  Result := 2;
 end;
 
-function TContainerEnum.MoveNext: Boolean;
+function TTestHelper.Test(aRecurse: Boolean): Integer;
 begin
-  Inc(fIndex);
-  Result := fIndex <= High(fContainer.Contents);
+  if aRecurse then
+    Result := inherited Test(False)
+  else
+    Result := 3;
 end;
 
 var
-  cont: TContainer;
-  i: Integer;
+  t: TTest;
+  res: Integer;
 begin
-  cont := TContainer.Create;
-  for i in cont do
-    Writeln(i);
+  t := TTest.Create;
+  res := t.Test(True);
+  Writeln('t.Test: ', res);
+  if res <> 1 then
+    Halt(1);
   Writeln('ok');
 end.

+ 15 - 31
tests/test/tchlp43.pp

@@ -1,51 +1,35 @@
-{ the extended type is searched first for a inherited method even if it's
-  defined as "override" }
+{ %NORUN }
+
+{ for helpers Self always refers to the extended class }
 program tchlp43;
 
 {$ifdef fpc}
-  {$mode delphi}
+  {$mode objfpc}
 {$endif}
-{$apptype console}
 
 type
-  TFoo = class
-    function Test(aRecurse: Boolean): Integer; virtual;
-  end;
-
-  TObjectHelper = class helper for TObject
-    function Test(aRecurse: Boolean): Integer; virtual;
+  TTest = class
+    procedure DoTest(aTest: TTest);
   end;
 
-  TFooHelper = class helper(TObjectHelper) for TFoo
-    function Test(aRecurse: Boolean): Integer; override;
+  TTestHelper = class helper for TTest
+    procedure Test;
   end;
 
-function TFoo.Test(aRecurse: Boolean): Integer;
+procedure TTest.DoTest(aTest: TTest);
 begin
-  Result := 1;
-end;
 
-function TObjectHelper.Test(aRecurse: Boolean): Integer;
-begin
-  Result := 2;
 end;
 
-function TFooHelper.Test(aRecurse: Boolean): Integer;
+procedure TTestHelper.Test;
 begin
-  if aRecurse then
-    Result := inherited Test(False)
-  else
-    Result := 3;
+  DoTest(Self);
 end;
 
 var
-  f: TFoo;
-  res: Integer;
+  t: TTest;
 begin
-  f := TFoo.Create;
-  res := f.Test(True);
-  Writeln('f.Test: ', res);
-  if res <> 1 then
-    Halt(1);
-  Writeln('ok');
+  t := TTest.Create;
+  t.Test;
 end.
+

+ 13 - 13
tests/test/tchlp44.pp

@@ -1,49 +1,49 @@
-{ in a parent class helper Self always is of the type of the extended class }
+{ in a class helper Self always is of the type of the extended class }
 program tchlp44;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 {$apptype console}
 
 type
-  TFoo = class
+  TTest = class
     function Test: Integer;
   end;
 
-  TBar = class(TFoo)
+  TTestSub = class(TTest)
     function Test: Integer;
   end;
 
-  TFooHelper = class helper for TFoo
+  TTestHelper = class helper for TTest
     function AccessTest: Integer;
   end;
 
-  TBarHelper = class helper(TFooHelper) for TBar
+  TTestSubHelper = class helper(TTestHelper) for TTestSub
   end;
 
-function TFoo.Test: Integer;
+function TTest.Test: Integer;
 begin
   Result := 1;
 end;
 
-function TBar.Test: Integer;
+function TTestSub.Test: Integer;
 begin
   Result := 2;
 end;
 
-function TFooHelper.AccessTest: Integer;
+function TTestHelper.AccessTest: Integer;
 begin
   Result := Test;
 end;
 
 var
-  b: TBar;
+  t: TTestSub;
   res: Integer;
 begin
-  b := TBar.Create;
-  res := b.AccessTest;
-  Writeln('b.AccessTest: ', res);
+  t := TTestSub.Create;
+  res := t.AccessTest;
+  Writeln('t.AccessTest: ', res);
   if res <> 1 then
     Halt(1);
   Writeln('ok');

+ 25 - 9
tests/test/tchlp45.pp

@@ -1,19 +1,35 @@
-{ %FAIL }
+{ %NORUN }
 
-{ access to methods must adhere to visibility rules (here: strict private) }
+{ tests whether the methods of a parent helper are usable in a derived helper }
 program tchlp45;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 {$apptype console}
 
-uses
-  uchlp45;
+type
+  TTest = class
+
+  end;
+
+  TTestHelper = class helper for TTest
+    procedure Test;
+  end;
+
+  TTestHelperSub = class helper(TTestHelper) for TTest
+    procedure AccessTest;
+  end;
+
+procedure TTestHelper.Test;
+begin
+
+end;
+
+procedure TTestHelperSub.AccessTest;
+begin
+  Test;
+end;
 
-var
-  f: TFoo;
 begin
-  f := TFoo.Create;
-  f.Test1;
 end.

+ 37 - 9
tests/test/tchlp46.pp

@@ -1,18 +1,46 @@
-{ %FAIL }
-
-{ access to methods must adhere to visibility rules (here: private)}
+{ test that helpers can access the methods of the parent helper using
+  "inherited" }
 program tchlp46;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
+{$apptype console}
+
+type
+  TTest = class
+
+  end;
+
+  TTestHelper = class helper for TTest
+    function Test(aRecurse: Boolean): Integer;
+  end;
 
-uses
-  uchlp45;
+  TTestHelperSub = class helper(TTestHelper) for TTest
+    function Test(aRecurse: Boolean): Integer;
+  end;
+
+function TTestHelper.Test(aRecurse: Boolean): Integer;
+begin
+  Result := 1;
+end;
+
+function TTestHelperSub.Test(aRecurse: Boolean): Integer;
+begin
+  if aRecurse then
+    Result := inherited Test(False)
+  else
+    Result := 2;
+end;
 
 var
-  f: TFoo;
+  t: TTest;
+  res: Integer;
 begin
-  f := TFoo.Create;
-  f.Test2;
+  t := TTest.Create;
+  res := t.Test(True);
+  Writeln('t.Test: ', res);
+  if res <> 1 then
+    Halt(1);
+  Writeln('ok');
 end.

+ 42 - 9
tests/test/tchlp47.pp

@@ -1,18 +1,51 @@
-{ %FAIL }
-
-{ access to methods must adhere to visibility rules (here: strict protected)}
+{ a method defined in a parent helper has higher priority than a method defined
+  in the parent of the extended class - test 1}
 program tchlp47;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
+{$apptype console}
+
+type
+  TTest = class
+    function Test: Integer;
+  end;
+
+  TTestSub = class(TTest)
+  end;
+
+  TTestSubHelper = class helper for TTestSub
+    function Test: Integer;
+  end;
+
+  TTestSubHelperSub = class helper(TTestSubHelper) for TTestSub
+    function AccessTest: Integer;
+  end;
 
-uses
-  uchlp45;
+function TTest.Test: Integer;
+begin
+  Result := 1;
+end;
+
+function TTestSubHelper.Test: Integer;
+begin
+  Result := 2;
+end;
+
+function TTestSubHelperSub.AccessTest: Integer;
+begin
+  Result := Test;
+end;
 
 var
-  f: TFoo;
+  t: TTestSub;
+  res: Integer;
 begin
-  f := TFoo.Create;
-  f.Test3;
+  t := TTestSub.Create;
+  res := t.AccessTest;
+  Writeln('t.AccessTest: ', res);
+  if res <> 2 then
+    Halt(1);
+  Writeln('ok');
 end.

+ 42 - 9
tests/test/tchlp48.pp

@@ -1,18 +1,51 @@
-{ %FAIL }
-
-{ access to methods must adhere to visibility rules (here: protected)}
+{ a method defined in a parent helper has higher priority than a method defined
+  in the parent of the extended class - test 2 }
 program tchlp48;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
+{$apptype console}
+
+type
+  TTest = class
+    function Test: Integer;
+  end;
+
+  TTestSub = class(TTest)
+  end;
+
+  TTestSubHelper = class helper for TTestSub
+    function Test: Integer;
+  end;
+
+  TTestSubHelperSub = class helper(TTestSubHelper) for TTestSub
+    function AccessTest: Integer;
+  end;
 
-uses
-  uchlp45;
+function TTest.Test: Integer;
+begin
+  Result := 1;
+end;
+
+function TTestSubHelper.Test: Integer;
+begin
+  Result := 2;
+end;
+
+function TTestSubHelperSub.AccessTest: Integer;
+begin
+  Result := inherited Test;
+end;
 
 var
-  f: TFoo;
+  t: TTestSub;
+  res: Integer;
 begin
-  f := TFoo.Create;
-  f.Test4;
+  t := TTestSub.Create;
+  res := t.AccessTest;
+  Writeln('t.AccessTest: ', res);
+  if res <> 2 then
+    Halt(1);
+  Writeln('ok');
 end.

+ 37 - 9
tests/test/tchlp49.pp

@@ -1,18 +1,46 @@
-{ %NORUN }
-
-{ access to methods must adhere to visibility rules (here: public)}
+{ a class helper can access methods defined in the parent of the extended
+  class }
 program tchlp49;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
+{$apptype console}
+
+type
+  TTest = class
+    function Test(aRecurse: Boolean): Integer;
+  end;
+
+  TTestSub = class(TTest)
+  end;
+
+  TTestSubHelper = class helper for TTestSub
+    function Test(aRecurse: Boolean): Integer;
+  end;
 
-uses
-  uchlp45;
+function TTest.Test(aRecurse: Boolean): Integer;
+begin
+  Result := 1;
+end;
+
+function TTestSubHelper.Test(aRecurse: Boolean): Integer;
+begin
+  if aRecurse then
+    Result := inherited Test(False)
+  else
+    Result := 2;
+end;
 
 var
-  f: TFoo;
+  t: TTestSub;
+  res: Integer;
 begin
-  f := TFoo.Create;
-  f.Test5;
+  t := TTestSub.Create;
+  res := t.Test(True);
+  Writeln('t.Test: ', res);
+  if res <> 1 then
+    Halt(1);
+  Writeln('ok');
 end.
+

+ 19 - 8
tests/test/tchlp5.pp

@@ -1,18 +1,29 @@
-{%FAIL}
-
-{ class destructors are not allowed }
+{ the size of a class helper is equivalent to that of a pointer }
 program tchlp5;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
+{$apptype console}
 
 type
-  TObjectHelper = class helper for TObject
-    class destructor Destroy; override;
+  TTest = class
+    s: String;
+    i32: Integer;
+    b: Boolean;
+    i64: Int64;
   end;
 
-begin
+  TTestHelper = class helper for TTest
+  end;
 
+var
+  res: Integer;
+begin
+  res := SizeOf(TTestHelper);
+  Writeln('SizeOf(TTest): ', SizeOf(TTest));
+  Writeln('SizeOf(TTestHelper): ', res);
+  if res <> SizeOf(Pointer) then
+    Halt(1);
+  Writeln('ok');
 end.
-

+ 27 - 10
tests/test/tchlp50.pp

@@ -1,24 +1,41 @@
-{ test whether the correct class helper is used, if two are defined for the
-  same class in a unit }
+{ without "inherited" the methods of the helper are called first }
 program tchlp50;
 
 {$ifdef fpc}
-  {$mode objfpc}{$H+}
+  {$mode delphi}
 {$endif}
 {$apptype console}
 
-uses
-  uchlp50;
+type
+  TTest = class
+    function Test(aRecurse: Boolean): Integer;
+  end;
+
+  TTestHelper = class helper for TTest
+    function Test(aRecurse: Boolean): Integer;
+  end;
+
+function TTest.Test(aRecurse: Boolean): Integer;
+begin
+  Result := 1;
+end;
+
+function TTestHelper.Test(aRecurse: Boolean): Integer;
+begin
+  if aRecurse then
+    Result := Test(False)
+  else
+    Result := 2;
+end;
 
 var
-  f: TFoo;
+  t: TTest;
   res: Integer;
 begin
-  f := TFoo.Create;
-  res := f.Test;
-  Writeln('f.Test: ', res);
+  t := TTest.Create;
+  res := t.Test(True);
+  Writeln('t.Test: ', res);
   if res <> 2 then
     Halt(1);
   Writeln('ok');
 end.
-

+ 34 - 10
tests/test/tchlp51.pp

@@ -1,23 +1,47 @@
-{ this tests whether a class helper introduced in the uses clause of an
-  implementation section overrides the one introduced in the interface section }
+{ methods defined in a helper have higher priority than those defined in the
+  extended type }
 program tchlp51;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 {$apptype console}
 
-uses
-  uchlp51a, uchlp51c;
+type
+  TTest = class
+    function Test: Integer;
+  end;
+
+  TTestHelper = class helper for TTest
+  private
+    function Test: Integer;
+  public
+    function AccessTest: Integer;
+  end;
+
+function TTest.Test: Integer;
+begin
+  Result := 1;
+end;
+
+function TTestHelper.Test: Integer;
+begin
+  Result := 2;
+end;
+
+function TTestHelper.AccessTest: Integer;
+begin
+  Result := Test;
+end;
 
 var
-  f: TFoo;
+  t: TTest;
   res: Integer;
 begin
-  f := TFoo.Create;
-  res := f.AccessTest;
-  Writeln('f.AccessTest: ', res);
-  if res <> 1 then
+  t := TTest.Create;
+  res := t.AccessTest;
+  Writeln('t.AccessTest: ', res);
+  if res <> 2 then
     Halt(1);
   Writeln('ok');
 end.

+ 57 - 8
tests/test/tchlp52.pp

@@ -1,24 +1,73 @@
-{ %FAIL }
+{ %NORUN }
 
-{ class helpers may not be referenced in any way - test 7 }
+{ a helper may introduce an enumerator }
 program tchlp52;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
 type
-  TObjectHelper = class helper for TObject
-    procedure Test;
+  TContainer = class
+    Contents: array[0..5] of Integer;
+    constructor Create;
   end;
 
-procedure TObjectHelper.Test;
+  TContainerEnum = class
+  private
+    fIndex: Integer;
+    fContainer: TContainer;
+  public
+    constructor Create(aContainer: TContainer);
+    function GetCurrent: Integer;
+    function MoveNext: Boolean;
+    property Current: Integer read GetCurrent;
+  end;
+
+  TContainerHelper = class helper for TContainer
+    function GetEnumerator: TContainerEnum;
+  end;
+
+{ TContainer }
+
+constructor TContainer.Create;
+var
+  i: Integer;
 begin
+  for i := Low(Contents) to High(Contents) do
+    Contents[i] := i;
+end;
+
+{ TContainerHelper }
 
+function TContainerHelper.GetEnumerator: TContainerEnum;
+begin
+  Result := TContainerEnum.Create(Self);
+end;
+
+{ TContainerEnum }
+
+constructor TContainerEnum.Create(aContainer: TContainer);
+begin
+  fContainer := aContainer;
+  fIndex := Low(fContainer.Contents) - 1;
+end;
+
+function TContainerEnum.GetCurrent: Integer;
+begin
+  Result := fContainer.Contents[fIndex];
+end;
+
+function TContainerEnum.MoveNext: Boolean;
+begin
+  Inc(fIndex);
+  Result := fIndex <= High(fContainer.Contents);
 end;
 
 var
-  o: TObject;
+  cont: TContainer;
+  i: Integer;
 begin
-  TObjectHelper(o).Test;
+  cont := TContainer.Create;
+  for i in cont do ;
 end.

+ 70 - 13
tests/test/tchlp53.pp

@@ -1,40 +1,97 @@
-{ %NORUN }
-
-{ method modifiers of the extended class are completly irrelevant }
+{ a helper hides an existing enumerator }
 program tchlp53;
 
 {$ifdef fpc}
   {$mode delphi}
 {$endif}
+{$apptype console}
 
 type
-  TFoo = class
-    procedure Test; virtual;
+  TContainerEnum = class;
+
+  TContainer = class
+    Contents: array[0..5] of Integer;
+    function GetEnumerator: TContainerEnum;
+    constructor Create;
   end;
 
-  TFooHelper = class helper for TFoo
-    procedure Test; virtual;
+  TContainerEnum = class
+  private
+    fIndex: Integer;
+    fContainer: TContainer;
+    fForward: Boolean;
+  public
+    constructor Create(aContainer: TContainer; aForward: Boolean);
+    function GetCurrent: Integer;
+    function MoveNext: Boolean;
+    property Current: Integer read GetCurrent;
   end;
 
-  TFooSubHelper = class helper(TFooHelper) for TFoo
-    procedure Test; override;
+  TContainerHelper = class helper for TContainer
+    function GetEnumerator: TContainerEnum;
   end;
 
-procedure TFoo.Test;
-begin
+{ TContainer }
 
+constructor TContainer.Create;
+var
+  i: Integer;
+begin
+  for i := Low(Contents) to High(Contents) do
+    Contents[i] := i;
 end;
 
-procedure TFooHelper.Test;
+function TContainer.GetEnumerator: TContainerEnum;
 begin
+  Result := TContainerEnum.Create(Self, True);
+end;
+
+{ TContainerHelper }
 
+function TContainerHelper.GetEnumerator: TContainerEnum;
+begin
+  Result := TContainerEnum.Create(Self, False);
 end;
 
-procedure TFooSubHelper.Test;
+{ TContainerEnum }
+
+constructor TContainerEnum.Create(aContainer: TContainer; aForward: Boolean);
 begin
+  fContainer := aContainer;
+  fForward := aForward;
+  if fForward then
+    fIndex := Low(fContainer.Contents) - 1
+  else
+    fIndex := High(fContainer.Contents) + 1;
+end;
 
+function TContainerEnum.GetCurrent: Integer;
+begin
+  Result := fContainer.Contents[fIndex];
 end;
 
+function TContainerEnum.MoveNext: Boolean;
 begin
+  if fForward then begin
+    Inc(fIndex);
+    Result := fIndex <= High(fContainer.Contents);
+  end else begin
+    Dec(fIndex);
+    Result := fIndex >= Low(fContainer.Contents);
+  end;
+end;
 
+var
+  cont: TContainer;
+  i, c: Integer;
+begin
+  cont := TContainer.Create;
+  c := 5;
+  for i in cont do begin
+    if c <> i then
+      Halt(1);
+    Writeln(i);
+    Dec(c);
+  end;
+  Writeln('ok');
 end.

+ 100 - 10
tests/test/tchlp54.pp

@@ -1,33 +1,123 @@
-{ tests whether the methods of a parent helper are usable in a derived helper }
+{ this example tests combinations of class and helpers hierarchies }
 program tchlp54;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 {$apptype console}
 
 type
-  TFoo = class
+  TTest1 = class
+  end;
+
+  TTest2 = class(TTest1)
+    class function Test3: Integer;
+  end;
+
+  TTest3 = class(TTest2)
+    class function Test1: Integer;
+    class function Test2: Integer;
+  end;
 
+  TTest4 = class(TTest3)
   end;
 
-  TFooHelper = class helper for TFoo
-    procedure Test;
+  TTest1Helper = class helper for TTest1
+    class function Test1: Integer;
+    class function Test3: Integer;
+    class function Test4: Integer;
   end;
 
-  TFooBarHelper = class helper(TFooHelper) for TFoo
-    procedure AccessTest;
+  TTest3Helper = class helper for TTest3
+    class function Test2: Integer;
+    class function Test4: Integer;
   end;
 
-procedure TFooHelper.Test;
+  TTest4Helper = class helper(TTest1Helper) for TTest4
+    class function DoTest1: Integer;
+    class function DoTest2: Integer;
+    class function DoTest3: Integer;
+    class function DoTest4: Integer;
+  end;
+
+class function TTest2.Test3: Integer;
+begin
+  Result := 1;
+end;
+
+class function TTest3.Test1: Integer;
+begin
+  Result := 1;
+end;
+
+class function TTest3.Test2: Integer;
+begin
+  Result := 1;
+end;
+
+class function TTest1Helper.Test1: Integer;
+begin
+  Result := 2;
+end;
+
+class function TTest1Helper.Test3: Integer;
+begin
+  Result := 2;
+end;
+
+class function TTest1Helper.Test4: Integer;
+begin
+  Result := 1;
+end;
+
+class function TTest3Helper.Test2: Integer;
+begin
+  Result := 2;
+end;
+
+class function TTest3Helper.Test4: Integer;
 begin
+  Result := 2;
+end;
+
+class function TTest4Helper.DoTest1: Integer;
+begin
+  Result := Test1;
+end;
 
+class function TTest4Helper.DoTest2: Integer;
+begin
+  Result := Test2;
+end;
+
+class function TTest4Helper.DoTest3: Integer;
+begin
+  Result := Test3;
 end;
 
-procedure TFooBarHelper.AccessTest;
+class function TTest4Helper.DoTest4: Integer;
 begin
-  Test;
+  Result := Test4;
 end;
 
+var
+  res: Integer;
 begin
+  res := TTest4.DoTest1;
+  Writeln('TTest4.DoTest1: ', res);
+  if res <> 2 then
+    Halt(1);
+  res := TTest4.DoTest2;
+  Writeln('TTest4.DoTest2: ', res);
+  if res <> 2 then
+    Halt(2);
+  res := TTest4.DoTest3;
+  Writeln('TTest4.DoTest3: ', res);
+  if res <> 2 then
+    Halt(3);
+  res := TTest4.DoTest4;
+  Writeln('TTest4.DoTest4: ', res);
+  if res <> 1 then
+    Halt(4);
+  Writeln('ok');
 end.

+ 0 - 26
tests/test/tchlp55.pp

@@ -1,26 +0,0 @@
-program tchlp55;
-
-{$ifdef fpc}
-  {$mode objfpc}
-{$endif}
-
-type
-  TTest = class
-  strict private
-    type
-      TFooHelper = class helper for TObject
-        procedure Test;
-      end;
-  end;
-
-procedure TTest.TFooHelper.Test;
-begin
-
-end;
-
-var
-  o: TObject;
-begin
-  o := TObject.Create;
-  o.Test;
-end.

+ 0 - 34
tests/test/tchlp56.pp

@@ -1,34 +0,0 @@
-{ %NORUN }
-
-{ for helpers Self always refers to the extended class }
-program tchlp56;
-
-{$ifdef fpc}
-  {$mode objfpc}
-{$endif}
-
-type
-  TFoo = class
-    procedure DoFoo(aFoo: TFoo);
-  end;
-
-  TFooHelper = class helper for TFoo
-    procedure Test;
-  end;
-
-procedure TFoo.DoFoo(aFoo: TFoo);
-begin
-
-end;
-
-procedure TFooHelper.Test;
-begin
-  DoFoo(Self);
-end;
-
-var
-  f: TFoo;
-begin
-  f := TFoo.Create;
-  f.Test;
-end.

+ 0 - 30
tests/test/tchlp57.pp

@@ -1,30 +0,0 @@
-{ %NORUN }
-
-{ a class helper can already be accessed when implementing a class' methods }
-program tchlp57;
-
-{$ifdef fpc}
-  {$mode objfpc}
-{$endif}
-
-type
-  TFoo = class
-    procedure Test;
-  end;
-
-  TFooHelper = class helper for TFoo
-    procedure Bar;
-  end;
-
-procedure TFoo.Test;
-begin
-  Bar;
-end;
-
-procedure TFooHelper.Bar;
-begin
-
-end;
-
-begin
-end.

+ 0 - 31
tests/test/tchlp58.pp

@@ -1,31 +0,0 @@
-{ %NORUN }
-
-{ tests whether class helpers can introduce properties }
-program tchlp58;
-
-{$ifdef fpc}
-  {$mode delphi}
-{$endif}
-{$apptype console}
-
-type
-  TFoo = class
-    Test: Integer;
-  end;
-
-  TFooHelper = class helper for TFoo
-    function GetAccessTest: Integer;
-    property AccessTest: Integer read GetAccessTest;
-  end;
-
-function TFooHelper.GetAccessTest: Integer;
-begin
-  Result := Test;
-end;
-
-var
-  f: TFoo;
-begin
-  f := TFoo.Create;
-  f.AccessTest;
-end.

+ 18 - 11
tests/test/tchlp6.pp

@@ -1,27 +1,34 @@
-{%NORUN}
-
-{ message methods are allowed in mode Delphi }
+{ helpers may introduce new default properties }
 program tchlp6;
 
 {$ifdef fpc}
   {$mode delphi}
 {$endif}
+{$apptype console}
 
 type
-  TMessage = record
-    ID: LongWord;
+  TTest = class
+
   end;
 
-  TObjectHelper = class helper for TObject
-    procedure SomeMessage(var aMessage: TMessage); message 42;
+  TTestHelper = class helper for TTest
+    function GetTest(aIndex: Integer): Integer;
+    property Test[Index: Integer]: Integer read GetTest; default;
   end;
 
-procedure TObjectHelper.SomeMessage(var aMessage: TMessage);
+function TTestHelper.GetTest(aIndex: Integer): Integer;
 begin
-
+  Result := aIndex;
 end;
 
+var
+  t: TTest;
+  res: Integer;
 begin
-
+  t := TTest.Create;
+  res := t[3];
+  Writeln('value: ', res);
+  if res <> 3 then
+    Halt(1);
+  Writeln('ok');
 end.
-

+ 0 - 51
tests/test/tchlp62.pp

@@ -1,51 +0,0 @@
-{ a method defined in a parent helper has higher priority than a method defined
-  in the parent of the extended class - test 1}
-program tchlp62;
-
-{$ifdef fpc}
-  {$mode delphi}
-{$endif}
-{$apptype console}
-
-type
-  TFoo = class
-    function Test: Integer;
-  end;
-
-  TFooBar = class(TFoo)
-  end;
-
-  TFooBarHelper = class helper for TFooBar
-    function Test: Integer;
-  end;
-
-  TFooBarSubHelper = class helper(TFooBarHelper) for TFooBar
-    function AccessTest: Integer;
-  end;
-
-function TFoo.Test: Integer;
-begin
-  Result := 1;
-end;
-
-function TFooBarHelper.Test: Integer;
-begin
-  Result := 2;
-end;
-
-function TFooBarSubHelper.AccessTest: Integer;
-begin
-  Result := Test;
-end;
-
-var
-  f: TFooBar;
-  res: Integer;
-begin
-  f := TFooBar.Create;
-  res := f.AccessTest;
-  Writeln('f.AccessTest: ', res);
-  if res <> 2 then
-    Halt(1);
-  Writeln('ok');
-end.

+ 0 - 51
tests/test/tchlp63.pp

@@ -1,51 +0,0 @@
-{ a method defined in a parent helper has higher priority than a method defined
-  in the parent of the extended class - test 2 }
-program tchlp63;
-
-{$ifdef fpc}
-  {$mode delphi}
-{$endif}
-{$apptype console}
-
-type
-  TFoo = class
-    function Test: Integer;
-  end;
-
-  TFooBar = class(TFoo)
-  end;
-
-  TFooBarHelper = class helper for TFooBar
-    function Test: Integer;
-  end;
-
-  TFooBarSubHelper = class helper(TFooBarHelper) for TFooBar
-    function AccessTest: Integer;
-  end;
-
-function TFoo.Test: Integer;
-begin
-  Result := 1;
-end;
-
-function TFooBarHelper.Test: Integer;
-begin
-  Result := 2;
-end;
-
-function TFooBarSubHelper.AccessTest: Integer;
-begin
-  Result := inherited Test;
-end;
-
-var
-  f: TFooBar;
-  res: Integer;
-begin
-  f := TFooBar.Create;
-  res := f.AccessTest;
-  Writeln('f.AccessTest: ', res);
-  if res <> 2 then
-    Halt(1);
-  Writeln('ok');
-end.

+ 0 - 46
tests/test/tchlp64.pp

@@ -1,46 +0,0 @@
-{ a class helper can access methods defined in the parent of the extended
-  class }
-program tchlp64;
-
-{$ifdef fpc}
-  {$mode delphi}
-{$endif}
-{$apptype console}
-
-type
-  TFoo = class
-    function Test(aRecurse: Boolean): Integer;
-  end;
-
-  TFooBar = class(TFoo)
-  end;
-
-  TFooBarHelper = class helper for TFooBar
-    function Test(aRecurse: Boolean): Integer;
-  end;
-
-function TFoo.Test(aRecurse: Boolean): Integer;
-begin
-  Result := 1;
-end;
-
-function TFooBarHelper.Test(aRecurse: Boolean): Integer;
-begin
-  if aRecurse then
-    Result := inherited Test(False)
-  else
-    Result := 2;
-end;
-
-var
-  f: TFooBar;
-  res: Integer;
-begin
-  f := TFooBar.Create;
-  res := f.Test(True);
-  Writeln('f.Test: ', res);
-  if res <> 1 then
-    Halt(1);
-  Writeln('ok');
-end.
-

+ 0 - 47
tests/test/tchlp67.pp

@@ -1,47 +0,0 @@
-{ helper methods also influence calls to a parent's method in a derived class }
-program tchlp67;
-
-{$ifdef fpc}
-  {$mode delphi}
-{$endif}
-{$apptype console}
-
-type
-  TFoo = class
-    function Test: Integer;
-  end;
-
-  TFooBar = class(TFoo)
-    function AccessTest: Integer;
-  end;
-
-  TFooHelper = class helper for TFoo
-    function Test: Integer;
-  end;
-
-function TFoo.Test: Integer;
-begin
-  Result := 1;
-end;
-
-function TFooBar.AccessTest: Integer;
-begin
-  Result := Test;
-end;
-
-function TFooHelper.Test: Integer;
-begin
-  Result := 2;
-end;
-
-var
-  f: TFooBar;
-  res: Integer;
-begin
-  f := TFooBar.Create;
-  res := f.AccessTest;
-  Writeln('f.AccessTest: ', res);
-  if res <> 2 then
-    Halt(1);
-  Writeln('ok');
-end.

+ 0 - 48
tests/test/tchlp68.pp

@@ -1,48 +0,0 @@
-{ helper methods also influence calls to a parent's method in a derived class }
-program tchlp68;
-
-{$ifdef fpc}
-  {$mode delphi}
-{$endif}
-{$apptype console}
-
-type
-  TFoo = class
-    function Test: Integer;
-  end;
-
-  TFooBar = class(TFoo)
-    function AccessTest: Integer;
-  end;
-
-  TFooHelper = class helper for TFoo
-    function Test: Integer;
-  end;
-
-function TFoo.Test: Integer;
-begin
-  Result := 1;
-end;
-
-function TFooBar.AccessTest: Integer;
-begin
-  Result := inherited Test;
-end;
-
-function TFooHelper.Test: Integer;
-begin
-  Result := 2;
-end;
-
-var
-  f: TFooBar;
-  res: Integer;
-begin
-  f := TFooBar.Create;
-  res := f.AccessTest;
-  Writeln('f.AccessTest: ', res);
-  if res <> 2 then
-    Halt(1);
-  Writeln('ok');
-end.
-

+ 28 - 11
tests/test/tchlp7.pp

@@ -1,25 +1,42 @@
-{%FAIL}
-
-{ message methods are not allowed in mode ObjFPC }
+{ helpers may override existing default properties }
 program tchlp7;
 
-{$mode objfpc}
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+{$apptype console}
 
 type
-  TMessage = record
-    ID: LongWord;
+  TTest = class
+  private
+    function GetTest(aIndex: Integer): Integer;
+  public
+    property Test[Index: Integer]: Integer read GetTest; default;
   end;
 
-  TObjectHelper = class helper for TObject
-    procedure SomeMessage(var aMessage: TMessage); message 42;
+  TTestHelper = class helper for TTest
+    function GetTest(aIndex: Integer): Integer;
+    property Test[Index: Integer]: Integer read GetTest; default;
   end;
 
-procedure TObjectHelper.SomeMessage(var aMessage: TMessage);
+function TTest.GetTest(aIndex: Integer): Integer;
 begin
-
+  Result := - aIndex;
 end;
 
+function TTestHelper.GetTest(aIndex: Integer): Integer;
 begin
+  Result := aIndex;
+end;
 
+var
+  t: TTest;
+  res: Integer;
+begin
+  t := TTest.Create;
+  res := t[3];
+  Writeln('value: ', res);
+  if res <> 3 then
+    Halt(1);
+  Writeln('ok');
 end.
-

+ 0 - 18
tests/test/tchlp78.pp

@@ -1,18 +0,0 @@
-{ size of a class helper is size of a pointer }
-program tchlp78;
-
-{$ifdef fpc}
-  {$mode delphi}
-{$endif}
-{$apptype console}
-
-type
-  TObjectHelper = class helper for TObject
-  end;
-
-begin
-  Writeln('Size of TObjectHelper: ', SizeOf(TObjectHelper));
-  if SizeOf(TObjectHelper) <> SizeOf(Pointer) then
-    Halt(1);
-  Writeln('ok');
-end.

+ 0 - 23
tests/test/tchlp79.pp

@@ -1,23 +0,0 @@
-{ size of a record helper is the size of a pointer }
-program tchlp79;
-
-{$ifdef fpc}
-  {$mode delphi}
-{$endif}
-{$apptype console}
-
-type
-  TTestRecord = record
-    i: Integer;
-    j: Integer;
-  end;
-
-  TTestRecordHelper = record helper for TTestRecord
-  end;
-
-begin
-  Writeln('Size of TTestRecordHelper: ', SizeOf(TTestRecordHelper));
-  if SizeOf(TTestRecordHelper) <> SizeOf(Pointer) then
-    Halt(1);
-  Writeln('ok');
-end.

+ 27 - 7
tests/test/tchlp8.pp

@@ -1,18 +1,38 @@
-{%FAIL}
-
-{ abstract methods are not allowed }
+{ helpers may introduce new default properties (includes default properties
+  introudced by the helper's parent) }
 program tchlp8;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
+{$apptype console}
 
 type
-  TObjectHelper = class helper for TObject
-    procedure SomeMethod; virtual; abstract;
+  TTest = class
+
+  end;
+
+  TTestHelper = class helper for TTest
+    function GetTest(aIndex: Integer): Integer;
+    property Test[Index: Integer]: Integer read GetTest; default;
   end;
 
+  TTestHelperSub = class helper(TTestHelper) for TTest
+  end;
+
+function TTestHelper.GetTest(aIndex: Integer): Integer;
 begin
+  Result := aIndex;
+end;
 
+var
+  t: TTest;
+  res: Integer;
+begin
+  t := TTest.Create;
+  res := t[3];
+  Writeln('value: ', res);
+  if res <> 3 then
+    Halt(1);
+  Writeln('ok');
 end.
-

+ 0 - 26
tests/test/tchlp82.pp

@@ -1,26 +0,0 @@
-{ %FAIL }
-
-{ test visibility of symbols in the extended type - strict private }
-program tchlp82;
-
-{$ifdef fpc}
-  {$mode delphi}
-{$endif}
-{$apptype console}
-
-uses
-  uchlp82;
-
-type
-  TFooHelper = class helper for TFoo
-    function AccessField: Integer;
-  end;
-
-function TFooHelper.AccessField: Integer;
-begin
-  Result := Test1;
-end;
-
-begin
-
-end.

+ 0 - 26
tests/test/tchlp83.pp

@@ -1,26 +0,0 @@
-{ %FAIL }
-
-{ test visibility of symbols in the extended type - private }
-program tchlp83;
-
-{$ifdef fpc}
-  {$mode delphi}
-{$endif}
-{$apptype console}
-
-uses
-  uchlp82;
-
-type
-  TFooHelper = class helper for TFoo
-    function AccessField: Integer;
-  end;
-
-function TFooHelper.AccessField: Integer;
-begin
-  Result := Test2;
-end;
-
-begin
-
-end.

+ 0 - 26
tests/test/tchlp84.pp

@@ -1,26 +0,0 @@
-{ %NORUN }
-
-{ test visibility of symbols in the extended type - strict protected }
-program tchlp84;
-
-{$ifdef fpc}
-  {$mode delphi}
-{$endif}
-{$apptype console}
-
-uses
-  uchlp82;
-
-type
-  TFooHelper = class helper for TFoo
-    function AccessField: Integer;
-  end;
-
-function TFooHelper.AccessField: Integer;
-begin
-  Result := Test3;
-end;
-
-begin
-
-end.

+ 0 - 26
tests/test/tchlp85.pp

@@ -1,26 +0,0 @@
-{ %NORUN }
-
-{ test visibility of symbols in the extended type - protected }
-program tchlp85;
-
-{$ifdef fpc}
-  {$mode delphi}
-{$endif}
-{$apptype console}
-
-uses
-  uchlp82;
-
-type
-  TFooHelper = class helper for TFoo
-    function AccessField: Integer;
-  end;
-
-function TFooHelper.AccessField: Integer;
-begin
-  Result := Test4;
-end;
-
-begin
-
-end.

+ 0 - 30
tests/test/tchlp86.pp

@@ -1,30 +0,0 @@
-{ %FAIL } {???}
-
-program tchlp86;
-
-{$ifdef fpc}
-  {$mode delphi}
-{$endif}
-{$apptype console}
-
-type
-  TFoo = class
-    class var
-      Test: Integer;
-  end;
-
-  TFooHelper = class helper for TFoo
-    class constructor Create;
-  end;
-
-class constructor TFooHelper.Create;
-begin
-  TFoo.Test := 42;
-end;
-
-begin
-  Writeln('TFoo.Test: ', TFoo.Test);
-  if TFoo.Test <> 42 then
-    Halt(1);
-  Writeln('ok');
-end.

+ 0 - 33
tests/test/tchlp87.pp

@@ -1,33 +0,0 @@
-{ %NORUN }
-
-{ class helpers of a parent are available in a subclass as well }
-program tchlp87;
-
-{$ifdef fpc}
-  {$mode delphi}
-{$endif}
-{$apptype console}
-
-type
-  TFoo = class
-
-  end;
-
-  TBar = class(TFoo)
-
-  end;
-
-  TFooHelper = class helper for TFoo
-    procedure TestFoo;
-  end;
-
-procedure TFooHelper.TestFoo;
-begin
-
-end;
-
-var
-  b: TBar;
-begin
-  b.TestFoo;
-end.

+ 0 - 42
tests/test/tchlp88.pp

@@ -1,42 +0,0 @@
-{ a helper of a parent class hides the parent's methods }
-program tchlp88;
-
-{$ifdef fpc}
-  {$mode delphi}
-{$endif}
-{$apptype console}
-
-type
-  TFoo = class
-    function TestFoo: Integer;
-  end;
-
-  TBar = class(TFoo)
-
-  end;
-
-  TFooHelper = class helper for TFoo
-    function TestFoo: Integer;
-  end;
-
-function TFoo.TestFoo: Integer;
-begin
-  Result := 1;
-end;
-
-function TFooHelper.TestFoo: Integer;
-begin
-  Result := 2;
-end;
-
-var
-  b: TBar;
-  res: Integer;
-begin
-  b := TBar.Create;
-  res := b.TestFoo;
-  Writeln('b.TestFoo: ', res);
-  if res <> 2 then
-    Halt(1);
-  Writeln('ok');
-end.

+ 0 - 47
tests/test/tchlp89.pp

@@ -1,47 +0,0 @@
-{ a helper of a parent class does not hide methods in the child class }
-program tchlp89;
-
-{$ifdef fpc}
-  {$mode delphi}
-{$endif}
-{$apptype console}
-
-type
-  TFoo = class
-    function TestFoo: Integer;
-  end;
-
-  TBar = class(TFoo)
-     function TestFoo: Integer;
-  end;
-
-  TFooHelper = class helper for TFoo
-    function TestFoo: Integer;
-  end;
-
-function TFoo.TestFoo: Integer;
-begin
-  Result := 1;
-end;
-
-function TBar.TestFoo: Integer;
-begin
-  Result := 4;
-end;
-
-function TFooHelper.TestFoo: Integer;
-begin
-  Result := 2;
-end;
-
-var
-  b: TBar;
-  res: Integer;
-begin
-  b := TBar.Create;
-  res := b.TestFoo;
-  Writeln('b.TestFoo: ', res);
-  if res <> 4 then
-    Halt(1);
-  Writeln('ok');
-end.

+ 9 - 19
tests/test/tchlp9.pp

@@ -1,32 +1,22 @@
-{%NORUN}
+{ %FAIL }
 
-{ class helper inheritance syntax }
+{ inside a helper's declaration the methods/fields of the extended class can't
+  be accessed }
 program tchlp9;
 
 {$ifdef fpc}
-  {$mode objfpc}
+  {$mode delphi}
 {$endif}
 
 type
-  TObjectHelperA = class helper for TObject
-    procedure SomeMethodA;
+  TTest = class
+    Test: Integer;
+    function GetTest: Integer;
   end;
 
-  TObjectHelperB = class helper(TObjectHelperA) for TObject
-    procedure SomeMethodB;
+  TTestHelper = class helper for TTest
+    property AccessTest: Integer read Test;
   end;
 
-procedure TObjectHelperA.SomeMethodA;
 begin
-
-end;
-
-procedure TObjectHelperB.SomeMethodB;
-begin
-
-end;
-
-begin
-
 end.
-

+ 0 - 51
tests/test/tchlp90.pp

@@ -1,51 +0,0 @@
-{ a helper of a parent class hides methods in the child class if its also a
-  parent of the helper for the child class }
-program tchlp90;
-
-{$ifdef fpc}
-  {$mode delphi}
-{$endif}
-{$apptype console}
-
-type
-  TFoo = class
-    function TestFoo: Integer;
-  end;
-
-  TBar = class(TFoo)
-     function TestFoo: Integer;
-  end;
-
-  TFooHelper = class helper for TFoo
-    function TestFoo: Integer;
-  end;
-
-  TBarHelper = class helper(TFooHelper) for TBar
-  end;
-
-function TFoo.TestFoo: Integer;
-begin
-  Result := 1;
-end;
-
-function TBar.TestFoo: Integer;
-begin
-  Result := 4;
-end;
-
-function TFooHelper.TestFoo: Integer;
-begin
-  Result := 2;
-end;
-
-var
-  b: TBar;
-  res: Integer;
-begin
-  b := TBar.Create;
-  res := b.TestFoo;
-  Writeln('b.TestFoo: ', res);
-  if res <> 2 then
-    Halt(1);
-  Writeln('ok');
-end.

+ 18 - 0
tests/test/thlp1.pp

@@ -0,0 +1,18 @@
+{ %NORUN }
+
+{ tests the inheritance syntax of helpers }
+program thlp1;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TObjectHelper = class helper for TObject
+  end;
+
+  TObjectHelperSub = class helper(TObjectHelper) for TObject
+  end;
+
+begin
+end.

+ 20 - 0
tests/test/thlp10.pp

@@ -0,0 +1,20 @@
+{ %FAIL }
+
+{ destructors are not allowed }
+program thlp10;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TObjectHelper = class helper for TObject
+    destructor Destroy;
+  end;
+
+destructor TObjectHelper.Destroy;
+begin
+end;
+
+begin
+end.

+ 21 - 0
tests/test/thlp11.pp

@@ -0,0 +1,21 @@
+{ %FAIL }
+
+{ class destructors are not allowed }
+program thlp11;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TObjectHelper = class helper for TObject
+    class destructor Destroy;
+  end;
+
+class destructor TObjectHelper.Destroy;
+begin
+end;
+
+begin
+end.
+

+ 21 - 0
tests/test/thlp12.pp

@@ -0,0 +1,21 @@
+{ %FAIL }
+
+{ class constructors are not allowed }
+program thlp12;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TObjectHelper = class helper for TObject
+    class constructor Create;
+  end;
+
+class constructor TObjectHelper.Create;
+begin
+end;
+
+begin
+end.
+

+ 24 - 0
tests/test/thlp13.pp

@@ -0,0 +1,24 @@
+{ %NORUN }
+
+{ message methods are allowed in mode Delphi }
+program thlp13;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TMessage = record
+    ID: Word;
+  end;
+
+  TObjectHelper = class helper for TObject
+    procedure Message(var aMessage: TMessage); message 42;
+  end;
+
+procedure TObjectHelper.Message(var aMessage: TMessage);
+begin
+end;
+
+begin
+end.

+ 25 - 0
tests/test/thlp14.pp

@@ -0,0 +1,25 @@
+{ %FAIL }
+
+{ message methods are forbidden in mode ObjFPC }
+program thlp14;
+
+{$ifdef fpc}
+  {$mode objfpc}
+{$endif}
+
+type
+  TMessage = record
+    ID: Word;
+  end;
+
+  TObjectHelper = class helper for TObject
+    procedure Message(var aMessage: TMessage); message 42;
+  end;
+
+procedure TObjectHelper.Message(var aMessage: TMessage);
+begin
+end;
+
+begin
+end.
+

+ 18 - 0
tests/test/thlp15.pp

@@ -0,0 +1,18 @@
+{ %FAIL }
+
+{ helpers may not be referenced in any way - test 1 }
+program thlp15;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TObjectHelper = class helper for TObject
+  end;
+
+var
+  o: TObjectHelper;
+begin
+end.
+

+ 17 - 0
tests/test/thlp16.pp

@@ -0,0 +1,17 @@
+{ %FAIL }
+
+{ helpers may not be referenced in any way - test 2 }
+program thlp16;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TObjectHelper = class helper for TObject
+  end;
+
+begin
+  with TObjectHelper.Create do ;
+end.
+

+ 23 - 0
tests/test/thlp17.pp

@@ -0,0 +1,23 @@
+{ %FAIL }
+
+{ helpers may not be referenced in any way - test 3 }
+program thlp17;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TObjectHelper = class helper for TObject
+    class procedure Test;
+  end;
+
+class procedure TObjectHelper.Test;
+begin
+
+end;
+
+begin
+  TObjectHelper.Test;
+end.
+

+ 21 - 0
tests/test/thlp18.pp

@@ -0,0 +1,21 @@
+{ %FAIL }
+
+{ helpers may not be referenced in any way - test 4 }
+program thlp18;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TObjectHelper = class helper for TObject
+  end;
+
+procedure SomeProc(aHelper: TObjectHelper);
+begin
+
+end;
+
+begin
+end.
+

+ 20 - 0
tests/test/thlp19.pp

@@ -0,0 +1,20 @@
+{ %FAIL }
+
+{ helpers may not be referenced in any way - test 5 }
+program thlp19;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TObjectHelper = class helper for TObject
+  end;
+
+  TSomeRec = record
+    helper: TObjectHelper;
+  end;
+
+begin
+end.
+

+ 28 - 0
tests/test/thlp2.pp

@@ -0,0 +1,28 @@
+{ %NORUN }
+
+{ tests that helpers can introduce properties }
+program thlp2;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TObjectHelper = class helper for TObject
+    class function GetTest: Integer; static;
+    class procedure SetTest(aValue: Integer); static;
+    class property Test: Integer read GetTest write SetTest;
+  end;
+
+class function TObjectHelper.GetTest: Integer;
+begin
+end;
+
+class procedure TObjectHelper.SetTest(aValue: Integer);
+begin
+
+end;
+
+begin
+  TObject.Test := TObject.Test;
+end.

+ 19 - 0
tests/test/thlp20.pp

@@ -0,0 +1,19 @@
+{ %FAIL }
+
+{ helpers may not be referenced in any way - test 6 }
+program thlp20;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TObjectHelper = class helper for TObject
+  end;
+
+  TObjectHelperHelper = class helper for TObjectHelper
+  end;
+
+begin
+end.
+

+ 19 - 0
tests/test/thlp21.pp

@@ -0,0 +1,19 @@
+{ %FAIL }
+
+{ helpers may not be referenced in any way - test 7 }
+program thlp21;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TObjectHelper = class helper for TObject
+  end;
+
+  TObjectHelperHelper = record helper for TObjectHelper
+  end;
+
+begin
+end.
+

+ 19 - 0
tests/test/thlp22.pp

@@ -0,0 +1,19 @@
+{ %FAIL }
+
+{ helpers may not be referenced in any way - test 8 }
+program thlp22;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TObjectHelper = class helper for TObject
+  end;
+
+  TObjectHelperSub = class(TObjectHelper)
+  end;
+
+begin
+end.
+

+ 24 - 0
tests/test/thlp23.pp

@@ -0,0 +1,24 @@
+{ %FAIL }
+
+{ helpers may not be referenced in any way - test 9 }
+program thlp23;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+type
+  TObjectHelper = class helper for TObject
+    procedure Test;
+  end;
+
+procedure TObjectHelper.Test;
+begin
+
+end;
+
+var
+  o: TObject;
+begin
+  TObjectHelper(o).Test;
+end.

+ 1 - 2
tests/test/tchlp69.pp → tests/test/thlp24.pp

@@ -1,12 +1,11 @@
 { %FAIL }
 
 { a helper can not extend inline defined generics }
-program tchlp69;
+program thlp24;
 
 {$ifdef fpc}
   {$mode delphi}
 {$endif}
-{$apptype console}
 
 type
   TFoo<T> = class

+ 1 - 2
tests/test/tchlp70.pp → tests/test/thlp25.pp

@@ -1,12 +1,11 @@
 { %FAIL }
 
 { a helper can not extend unspecialized generics }
-program tchlp70;
+program thlp25;
 
 {$ifdef fpc}
   {$mode delphi}
 {$endif}
-{$apptype console}
 
 type
   TFoo<T> = class

+ 4 - 4
tests/test/tchlp71.pp → tests/test/thlp26.pp

@@ -1,12 +1,12 @@
-{ %FAIL }
+{ %NORUN }
 
-{ a helper can not extend specialized generics }
-program tchlp71;
+{ a helper may extend specialized generics }
+{ Note: this does currently not compile in Delphi }
+program thlp26;
 
 {$ifdef fpc}
   {$mode delphi}
 {$endif}
-{$apptype console}
 
 type
   TFoo<T> = class

+ 1 - 2
tests/test/tchlp72.pp → tests/test/thlp27.pp

@@ -1,12 +1,11 @@
 { %NORUN }
 
 { a helper can extend the subclass of a specialized generic }
-program tchlp72;
+program thlp27;
 
 {$ifdef fpc}
   {$mode delphi}
 {$endif}
-{$apptype console}
 
 type
   TFoo<T> = class

+ 1 - 2
tests/test/tchlp73.pp → tests/test/thlp28.pp

@@ -1,12 +1,11 @@
 { %FAIL }
 
 { a helper may not be defined as a generic type }
-program tchlp73;
+program thlp28;
 
 {$ifdef fpc}
   {$mode delphi}
 {$endif}
-{$apptype console}
 
 type
   TFoo = class

+ 5 - 7
tests/test/tchlp74.pp → tests/test/thlp29.pp

@@ -1,24 +1,22 @@
-{ %SKIP }
-{ .%NORUN }
+{ %NORUN }
 
 { a helper may contain generic methods }
-program tchlp74;
+program thlp29;
 
 {$ifdef fpc}
   {$mode delphi}
 {$endif}
-{$apptype console}
 
 type
-  TFoo = class
+  TTest = class
 
   end;
 
-  TFooHelper = class helper for TFoo
+  TTestHelper = class helper for TTest
     function Test<T>: T;
   end;
 
-function TFooHelper.Test<T>: T;
+function TTestHelper.Test<T>: T;
 begin
 
 end;

+ 28 - 0
tests/test/thlp3.pp

@@ -0,0 +1,28 @@
+{ %NORUN }
+
+{ test that virtual methods can be defined in mode Delphi }
+program thlp3;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+uses
+  uhlp3;
+
+type
+  TObjectHelperSub = class helper(TObjectHelper) for TObject
+    procedure TestOverride; override;
+    procedure TestFinal; override; final;
+  end;
+
+procedure TObjectHelperSub.TestOverride;
+begin
+end;
+
+procedure TObjectHelperSub.TestFinal;
+begin
+end;
+
+begin
+end.

+ 2 - 4
tests/test/tchlp75.pp → tests/test/thlp30.pp

@@ -1,13 +1,11 @@
-{ %SKIP }
-{ .%FAIL }
+{ %FAIL }
 
 { helpers can not extend type parameters even if they can only be classes }
-program tchlp75;
+program thlp30;
 
 {$ifdef fpc}
   {$mode delphi}
 {$endif}
-{$apptype console}
 
 type
   TFoo<T: class> = class

+ 18 - 0
tests/test/thlp31.pp

@@ -0,0 +1,18 @@
+{ %FAIL }
+
+{ access to helper methods adheres to visibility rules (here: strict private) }
+program thlp31;
+
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+
+uses
+  uhlp31;
+
+var
+  f: TFoo;
+begin
+  f := TFoo.Create;
+  f.Test1;
+end.

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff