Browse Source

--- Merging r32054 into '.':
U compiler/ncnv.pas
A tests/webtbs/tw28748.pp
--- Recording mergeinfo for merge of r32054 into '.':
U .
--- Merging r33334 into '.':
U compiler/nadd.pas
A tests/webtbs/tw28749.pp
--- Recording mergeinfo for merge of r33334 into '.':
G .

# revisions: 32054,33334

git-svn-id: branches/fixes_3_0@33417 -

marco 9 years ago
parent
commit
ef951c96be
5 changed files with 36 additions and 0 deletions
  1. 2 0
      .gitattributes
  2. 4 0
      compiler/nadd.pas
  3. 2 0
      compiler/ncnv.pas
  4. 14 0
      tests/webtbs/tw28748.pp
  5. 14 0
      tests/webtbs/tw28749.pp

+ 2 - 0
.gitattributes

@@ -14320,6 +14320,8 @@ tests/webtbs/tw28718a.pp svneol=native#text/plain
 tests/webtbs/tw28718b.pp svneol=native#text/plain
 tests/webtbs/tw28718c.pp svneol=native#text/plain
 tests/webtbs/tw28718d.pp svneol=native#text/plain
+tests/webtbs/tw28748.pp svneol=native#text/plain
+tests/webtbs/tw28749.pp svneol=native#text/plain
 tests/webtbs/tw2876.pp svneol=native#text/plain
 tests/webtbs/tw2883.pp svneol=native#text/plain
 tests/webtbs/tw2885.pp svneol=native#text/plain

+ 4 - 0
compiler/nadd.pas

@@ -437,6 +437,10 @@ implementation
              (lt in [pointerconstn,niln]) and
              (rt in [pointerconstn,niln]) and
              (nodetype in [ltn,lten,gtn,gten,equaln,unequaln,subn])
+            ) or
+            (
+             (lt = ordconstn) and (ld.typ = orddef) and is_currency(ld) and
+             (rt = ordconstn) and (rd.typ = orddef) and is_currency(rd)
             ) then
           begin
              t:=nil;

+ 2 - 0
compiler/ncnv.pas

@@ -1429,6 +1429,8 @@ implementation
         else
           begin
             result:=cinlinenode.create(in_round_real,false,left);
+            { Internal type cast to currency }
+            result:=ctypeconvnode.create_internal(result,s64currencytype);
             left:=nil;
           end;
       end;

+ 14 - 0
tests/webtbs/tw28748.pp

@@ -0,0 +1,14 @@
+var
+  d: Double;
+  c, ce: Currency;
+begin
+  d := 1;
+  c := 2;
+  ce := 3;
+  c:=c + d;
+  writeln('c=', c);
+  if c <> ce then begin
+    writeln('Invalid currency value. Expected: ', ce);
+    halt(1);
+  end;
+end.

+ 14 - 0
tests/webtbs/tw28749.pp

@@ -0,0 +1,14 @@
+uses
+  SysUtils;
+var
+  s: string;
+  c: currency;
+begin
+  c:=Currency(0.12) + Currency(0.14);
+  s:=CurrToStr(c);
+  s:=StringReplace(s, FormatSettings.DecimalSeparator, '.', []);
+  writeln('s=', s);
+  if s <> '0.26' then
+    Halt(1);
+  writeln('OK');
+end.