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

Unified Diff: test/mjsunit/math-floor.js

Issue 7514040: tighten invariants of HValue::InferRange (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: another wee presubmit thing, sigh Created 9 years, 5 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
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));

Powered by Google App Engine
This is Rietveld 408576698