Procházet zdrojové kódy

Merged revisions 10333,10343,10352-10356,10358-10360,10364-10366,10369-10370,10373-10374,10376-10381,10387-10391,10393,10398,10400,10403,10423,10430,10436,10441,10444-10446,10452-10453,10472,10489-10491,10503,10507,10509-10515,10522,10525-10527,10530-10531,10533 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
r10333 | florian | 2008-02-15 20:57:08 +0100 (Fr, 15 Feb 2008) | 2 lines

* according to Delphi in a Nutshell, EConvertPropertyError is risen by Seg/Get
........
r10453 | florian | 2008-03-06 23:15:04 +0100 (Do, 06 Mrz 2008) | 2 lines

* convert the array into a variant as well before calling fpc_variant_put, resolves #10495
........
r10533 | florian | 2008-03-22 16:35:44 +0100 (Sa, 22 Mrz 2008) | 2 lines

* handle integer operations on variants containing doubles correctly, resolves #11033
........

git-svn-id: branches/fixes_2_2@10787 -

florian před 17 roky
rodič
revize
283d712ab5
4 změnil soubory, kde provedl 148 přidání a 1 odebrání
  1. 2 0
      .gitattributes
  2. 1 1
      compiler/pexpr.pas
  3. 20 0
      tests/webtbs/tw10495.pp
  4. 125 0
      tests/webtbs/tw11033.pp

+ 2 - 0
.gitattributes

@@ -7907,6 +7907,7 @@ tests/webtbs/tw1044.pp svneol=native#text/plain
 tests/webtbs/tw10454.pp svneol=native#text/plain
 tests/webtbs/tw1046.pp svneol=native#text/plain
 tests/webtbs/tw10489.pp svneol=native#text/plain
+tests/webtbs/tw10495.pp svneol=native#text/plain
 tests/webtbs/tw1050.pp svneol=native#text/plain
 tests/webtbs/tw10519.pp svneol=native#text/plain
 tests/webtbs/tw10540.pp svneol=native#text/plain
@@ -7937,6 +7938,7 @@ tests/webtbs/tw1097.pp svneol=native#text/plain
 tests/webtbs/tw10979.pp svneol=native#text/plain
 tests/webtbs/tw11006.pp svneol=native#text/plain
 tests/webtbs/tw1103.pp svneol=native#text/plain
+tests/webtbs/tw11033.pp svneol=native#text/plain
 tests/webtbs/tw1104.pp svneol=native#text/plain
 tests/webtbs/tw11053.pp svneol=native#text/plain
 tests/webtbs/tw1111.pp svneol=native#text/plain

+ 1 - 1
compiler/pexpr.pas

@@ -1849,7 +1849,7 @@ implementation
                    ccallparanode.create(caddrnode.create_internal
                   (ctemprefnode.create(temp)),
                    ccallparanode.create(ctypeconvnode.create_internal(p4,cvarianttype),
-                   ccallparanode.create(p1
+                   ccallparanode.create(ctypeconvnode.create_internal(p1,cvarianttype)
                      ,nil))));
 
                 addstatement(newstatement,ccallnode.createintern('fpc_vararray_put',paras));

+ 20 - 0
tests/webtbs/tw10495.pp

@@ -0,0 +1,20 @@
+uses
+  variants;
+var
+  tmp: OleVariant;
+  a: OleVariant;
+  b: OleVariant;
+begin
+  tmp:=VarArrayCreate([0,2], varVariant);
+  a:=1234;
+  b:=4321;
+  tmp[0]:=a;
+  tmp[1]:=b;
+  a:=tmp[0];
+  b:=tmp[1];
+  if a<>1234 then
+    halt(1);
+  if b<>4321 then
+    halt(1);
+  writeln('ok');
+end.

+ 125 - 0
tests/webtbs/tw11033.pp

@@ -0,0 +1,125 @@
+{$ifdef fpc}
+{$mode objfpc}
+{$endif fpc}
+program t;
+
+uses SysUtils,variants;
+
+var a, b: Variant;
+
+procedure test_or(i : Integer);
+var
+  v : variant;
+begin
+  try
+    v:=a or b;
+    if v<>i then
+      halt(1);
+    writeln(v);
+  except
+    on E: exception do writeln(e.message);
+  end;
+end;
+
+
+procedure test_and(i : Integer);
+var
+  v : variant;
+begin
+  try
+    v:=a and b;
+    if v<>i then
+      halt(1);
+    writeln(v);
+  except
+    on E: exception do writeln(e.message);
+  end;
+end;
+
+
+procedure test_xor(i : Integer);
+var
+  v : variant;
+begin
+  try
+    v:=a xor b;
+    if v<>i then
+      halt(1);
+    writeln(v);
+  except
+    on E: exception do writeln(e.message);
+  end;
+end;
+
+
+procedure test_div(i : Integer);
+var
+  v : variant;
+begin
+  try
+    v:=a div b;
+    if v<>i then
+      halt(1);
+    writeln(v);
+  except
+    on E: exception do writeln(e.message);
+  end;
+end;
+
+
+procedure test_mod(i : Integer);
+var
+  v : variant;
+begin
+  try
+    v:=a mod b;
+    if v<>i then
+      halt(1);
+    writeln(v);
+  except
+    on E: exception do writeln(e.message);
+  end;
+end;
+
+
+procedure test_shl(i : Integer);
+var
+  v : variant;
+begin
+  try
+    v:=a shl b;
+    if v<>i then
+      halt(1);
+    writeln(v);
+  except
+    on E: exception do writeln(e.message);
+  end;
+end;
+
+procedure test_shr(i : Integer);
+var
+  v : variant;
+begin
+  try
+    v:=a shr b;
+    if v<>i then
+      halt(1);
+    writeln(v);
+  except
+    on E: exception do writeln(e.message);
+  end;
+end;
+
+
+begin
+  a := Integer(1);
+  b := 2.0;
+  write('or: '); test_or(3);
+  write('and: '); test_and(0);
+  write('xor: '); test_xor(3);
+  write('div: '); test_div(0);
+  write('mod: '); test_mod(1);
+  write('shl: '); test_shl(4);
+  write('shr: '); test_shr(0);
+  writeln('ok');
+end.