Ver Fonte

pastojs: test generic class classproperty

git-svn-id: trunk@43216 -
Mattias Gaertner há 5 anos atrás
pai
commit
6f13582b11

+ 36 - 0
packages/pastojs/tests/tcgenerics.pas

@@ -24,6 +24,7 @@ type
     Procedure TestGen_ClassAncestor;
     Procedure TestGen_Class_TypeInfo;
     Procedure TestGen_Class_TypeOverload; // ToDo TBird, TBird<T>, TBird<S,T>
+    Procedure TestGen_Class_ClassProperty;
     // ToDo: rename local const T
 
     // generic external class
@@ -337,6 +338,41 @@ begin
     '']));
 end;
 
+procedure TTestGenerics.TestGen_Class_ClassProperty;
+begin
+  StartProgram(false);
+  Add([
+  '{$mode delphi}',
+  'type',
+  '  TObject = class end;',
+  '  TBird<T> = class',
+  '  private',
+  '    class var fSize: T;',
+  '  public',
+  '    class property Size: T read fSize write fSize;',
+  '  end;',
+  '  TEagle = TBird<word>;',
+  'begin',
+  '  TBird<word>.Size:=3+TBird<word>.Size;',
+  '']);
+  ConvertProgram;
+  CheckSource('TestGen_Class_ClassProperty',
+    LinesToStr([ // statements
+    'rtl.createClass($mod, "TObject", null, function () {',
+    '  this.$init = function () {',
+    '  };',
+    '  this.$final = function () {',
+    '  };',
+    '});',
+    'rtl.createClass($mod, "TBird$G1", $mod.TObject, function () {',
+    '  this.fSize = 0;',
+    '});',
+    '']),
+    LinesToStr([ // $mod.$main
+    '$mod.TBird$G1.fSize = 3 + $mod.TBird$G1.fSize;',
+    '']));
+end;
+
 procedure TTestGenerics.TestGen_ExtClass_Array;
 begin
   StartProgram(false);

+ 1 - 1
utils/pas2js/docs/translation.html

@@ -2693,7 +2693,7 @@ function(){
     external name is the member name. Keep in mind that JS is case sensitive.<br>
     Properties work the same as with Pascal classes, i.e. are replaced by Getter/Setter.<br>
     Destructors are not allowed.<br>
-    Constructors are supported in three ways:
+    Constructors are supported in four ways:
     <ul>
       <li><i>constructor New</i> is translated to <i>new ExtClass(params)</i>.</li>
       <li><i>constructor New; external name ''GlobalFunc''</i> is translated to <i>new GlobalFunc(params)</i>.</li>