Browse Source

pastojs: eopPower

git-svn-id: trunk@35845 -
Mattias Gaertner 8 years ago
parent
commit
3f3f921b18
2 changed files with 44 additions and 0 deletions
  1. 8 0
      packages/pastojs/src/fppas2js.pp
  2. 36 0
      packages/pastojs/tests/tcmodules.pas

+ 8 - 0
packages/pastojs/src/fppas2js.pp

@@ -3911,6 +3911,14 @@ begin
               DoError(20161024191234,nBinaryOpcodeNotSupported,sBinaryOpcodeNotSupported,['logical XOR'],El);
               DoError(20161024191234,nBinaryOpcodeNotSupported,sBinaryOpcodeNotSupported,['logical XOR'],El);
             end;
             end;
           end;
           end;
+        eopPower:
+          begin
+          Call:=CreateCallExpression(El);
+          Call.Expr:=CreateBuiltInIdentifierExpr('Math.pow');
+          Call.AddArg(A);
+          Call.AddArg(B);
+          Result:=Call;
+          end
         else
         else
           if C=nil then
           if C=nil then
             DoError(20161024191244,nBinaryOpcodeNotSupported,sBinaryOpcodeNotSupported,[OpcodeStrings[El.OpCode]],El);
             DoError(20161024191244,nBinaryOpcodeNotSupported,sBinaryOpcodeNotSupported,[OpcodeStrings[El.OpCode]],El);

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

@@ -184,6 +184,9 @@ type
     Procedure TestVarExternal;
     Procedure TestVarExternal;
     Procedure TestVarExternalOtherUnit;
     Procedure TestVarExternalOtherUnit;
 
 
+    // numbers
+    Procedure TestDouble;
+
     // strings
     // strings
     Procedure TestCharConst;
     Procedure TestCharConst;
     Procedure TestChar_Compare;
     Procedure TestChar_Compare;
@@ -3511,6 +3514,39 @@ begin
     '']) );
     '']) );
 end;
 end;
 
 
+procedure TTestModule.TestDouble;
+begin
+  StartProgram(false);
+  Add([
+  'var',
+  '  d: double;',
+  'begin',
+  '  d:=1.0;',
+  '  d:=1.0/3.0;',
+  '  d:=1/3;',
+  '  d:=5.0E-324;',
+  '  d:=1.7E308;',
+  '  d:=10**3;',
+  '  d:=10 mod 3;',
+  '  d:=10 div 3;',
+  '']);
+  ConvertProgram;
+  CheckSource('TestDouble',
+    LinesToStr([
+    'this.d=0.0;'
+    ]),
+    LinesToStr([
+    '$mod.d = 1.0;',
+    '$mod.d = 1.0 / 3.0;',
+    '$mod.d = 1 / 3;',
+    '$mod.d = 5.0E-324;',
+    '$mod.d = 1.7E308;',
+    '$mod.d = Math.pow(10, 3);',
+    '$mod.d = 10 % 3;',
+    '$mod.d = Math.floor(10 / 3);',
+    '']));
+end;
+
 procedure TTestModule.TestCharConst;
 procedure TTestModule.TestCharConst;
 begin
 begin
   StartProgram(false);
   StartProgram(false);