Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1572)

Unified Diff: test/mjsunit/div-mod.js

Issue 1118008: Fix an error in optimized modulus operator, add unit test. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/div-mod.js
===================================================================
--- test/mjsunit/div-mod.js (revision 4229)
+++ test/mjsunit/div-mod.js (working copy)
@@ -169,3 +169,24 @@
assertEquals(somenum, somenum % -0x40000000, "%minsmi-32");
assertEquals(somenum, somenum % -0x80000000, "%minsmi-64");
})();
+
+
+// Side-effect-free expressions containing bit operations use
+// an optimized compiler with int32 values. Ensure that modulus
+// produces negative zeros correctly.
+function negative_zero_modulus_test() {
+ var x = 4;
+ var y = -4;
+ x = x + x - x;
+ y = y + y - y;
+ var z = (y | y | y | y) % x;
+ assertEquals(-1 / 0, 1 / z);
+ z = (x | x | x | x) % x;
+ assertEquals(1 / 0, 1 / z);
+ z = (y | y | y | y) % y;
+ assertEquals(-1 / 0, 1 / z);
+ z = (x | x | x | x) % y;
+ assertEquals(1 / 0, 1 / z);
+}
+
+negative_zero_modulus_test();
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698