Browse Source

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

git-svn-id: trunk@10533 -
florian 17 years ago
parent
commit
97bde1ecd6
2 changed files with 126 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 125 0
      tests/webtbs/tw11033.pp

+ 1 - 0
.gitattributes

@@ -8107,6 +8107,7 @@ tests/webtbs/tw10979.pp svneol=native#text/plain
 tests/webtbs/tw11006.pp svneol=native#text/plain
 tests/webtbs/tw11027.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/tw1111.pp svneol=native#text/plain
 tests/webtbs/tw1117.pp svneol=native#text/plain

+ 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.