mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-29 09:40:20 +02:00
pastojs: test generic class classproperty
git-svn-id: trunk@43216 -
This commit is contained in:
parent
8872deed26
commit
6f13582b11
@ -24,6 +24,7 @@ type
|
|||||||
Procedure TestGen_ClassAncestor;
|
Procedure TestGen_ClassAncestor;
|
||||||
Procedure TestGen_Class_TypeInfo;
|
Procedure TestGen_Class_TypeInfo;
|
||||||
Procedure TestGen_Class_TypeOverload; // ToDo TBird, TBird<T>, TBird<S,T>
|
Procedure TestGen_Class_TypeOverload; // ToDo TBird, TBird<T>, TBird<S,T>
|
||||||
|
Procedure TestGen_Class_ClassProperty;
|
||||||
// ToDo: rename local const T
|
// ToDo: rename local const T
|
||||||
|
|
||||||
// generic external class
|
// generic external class
|
||||||
@ -337,6 +338,41 @@ begin
|
|||||||
'']));
|
'']));
|
||||||
end;
|
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;
|
procedure TTestGenerics.TestGen_ExtClass_Array;
|
||||||
begin
|
begin
|
||||||
StartProgram(false);
|
StartProgram(false);
|
||||||
|
@ -2693,7 +2693,7 @@ function(){
|
|||||||
external name is the member name. Keep in mind that JS is case sensitive.<br>
|
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>
|
Properties work the same as with Pascal classes, i.e. are replaced by Getter/Setter.<br>
|
||||||
Destructors are not allowed.<br>
|
Destructors are not allowed.<br>
|
||||||
Constructors are supported in three ways:
|
Constructors are supported in four ways:
|
||||||
<ul>
|
<ul>
|
||||||
<li><i>constructor New</i> is translated to <i>new ExtClass(params)</i>.</li>
|
<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>
|
<li><i>constructor New; external name ''GlobalFunc''</i> is translated to <i>new GlobalFunc(params)</i>.</li>
|
||||||
|
Loading…
Reference in New Issue
Block a user