pastojs: test generic class classproperty

git-svn-id: trunk@43216 -
This commit is contained in:
Mattias Gaertner 2019-10-17 16:46:32 +00:00
parent 8872deed26
commit 6f13582b11
2 changed files with 37 additions and 1 deletions

View File

@ -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);

View File

@ -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>