Explorar el Código

pastojs: fixed multi add element position

git-svn-id: trunk@49122 -
Mattias Gaertner hace 4 años
padre
commit
204f2a3bc1
Se han modificado 2 ficheros con 11 adiciones y 4 borrados
  1. 2 2
      packages/pastojs/src/fppas2js.pp
  2. 9 2
      packages/pastojs/tests/tcmodules.pas

+ 2 - 2
packages/pastojs/src/fppas2js.pp

@@ -9750,7 +9750,7 @@ begin
       B:=ConvertExpression(SubBin.right,AContext);
       if aResolver<>nil then
         begin
-        aResolver.ComputeElement(El.right,RightResolved,Flags);
+        aResolver.ComputeElement(SubBin.right,RightResolved,Flags);
         Result:=ConvertBinaryExpressionRes(SubBin,AContext,LeftResolved,RightResolved,A,B);
         if (Result<>nil) then
           begin
@@ -9763,7 +9763,7 @@ begin
       if Result=nil then
         begin
         // +
-        R:=TJSBinary(CreateElement(TJSAdditiveExpressionPlus,El));
+        R:=TJSBinary(CreateElement(TJSAdditiveExpressionPlus,SubBin));
         R.A:=A; A:=nil;
         R.B:=B; B:=nil;
         Result:=R;

+ 9 - 2
packages/pastojs/tests/tcmodules.pas

@@ -3314,8 +3314,10 @@ procedure TTestModule.TestMultiAdd;
 begin
   StartProgram(false);
   Add([
+  'function Fly: string; external name ''fly'';',
   'function TryEncodeDate(Year, Month, Day: Word): Boolean;',
-  'var Date: double;',
+  'var',
+  '  Date: double;',
   'begin',
   '  Result:=(Year>0) and (Year<10000) and',
   '          (Month >= 1) and (Month<=12) and',
@@ -3324,7 +3326,10 @@ begin
   'end;',
   'var s: string;',
   'begin',
-  '  s:=''a''+''b''+''c''+''d'';']);
+  '  s:=''a''+''b''+''c''+''d'';',
+  '  s:=s+Fly+''e'';',
+  '  s:=Fly+Fly+Fly;',
+  '']);
   ConvertProgram;
   CheckSource('TestMultiAdd',
     LinesToStr([ // statements
@@ -3339,6 +3344,8 @@ begin
     '']),
     LinesToStr([ // this.$main
     '$mod.s = "a" + "b" + "c" + "d";',
+    '$mod.s = $mod.s + fly() + "e";',
+    '$mod.s = fly() + fly() + fly();',
     '']));
 end;