Index: test/mjsunit/math-floor.js |
diff --git a/test/mjsunit/math-floor.js b/test/mjsunit/math-floor.js |
index 11f4cd789c7587e89c576ca9e38e9c81455a115a..2c1390583e250e84b748430b555c919dfab0a207 100644 |
--- a/test/mjsunit/math-floor.js |
+++ b/test/mjsunit/math-floor.js |
@@ -51,6 +51,17 @@ function test() { |
testFloor(-Infinity, -Infinity); |
testFloor(NaN, NaN); |
+ // Ensure that a negative zero coming from Math.floor is properly |
+ // handled by other ops that take unboxed doubles. See cr7514040. |
Kevin Millikin (Chromium)
2011/08/02 10:24:14
No need to cross reference the code review in the
|
+ function ifloor(x) { |
+ return 1/Math.floor(x); |
+ } |
+ assertEquals(-Infinity, ifloor(-0)); |
+ assertEquals(-Infinity, ifloor(-0)); |
+ assertEquals(-Infinity, ifloor(-0)); |
+ %OptimizeFunctionOnNextCall(ifloor); |
+ assertEquals(-Infinity, ifloor(-0)); |
+ |
testFloor(0, 0.1); |
testFloor(0, 0.49999999999999994); |
testFloor(0, 0.5); |
@@ -129,3 +140,20 @@ function test() { |
for (var i = 0; i < 500; i++) { |
test(); |
} |
+ |
+ |
+// Ensure that a negative zero coming from Math.floor is properly |
+// handled by other ops that take unboxed doubles. See cr7514040. |
+function floorsum(i,n) { |
+ var ret = Math.floor(n); |
+ while (--i > 0) { |
+ ret += Math.floor(n); |
+ } |
+ return ret; |
+} |
+assertEquals(-0, floorsum(1000,-0)); |
+%OptimizeFunctionOnNextCall(floorsum); |
+// It seems that %OptimizeFunctionOnNextCall doesn't always work! Here |
Kevin Millikin (Chromium)
2011/08/02 10:24:14
It should always work (or else that's a bug).
I t
|
+// we push iterations up to a large number to ensure that we try to |
+// unbox doubles as much as possible. |
+assertEquals(-0, floorsum(1000000,-0)); |