summaryrefslogtreecommitdiff
path: root/deps/v8/test/mjsunit/math-floor.js
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2011-08-18 16:59:21 -0700
committerRyan Dahl <ry@tinyclouds.org>2011-08-18 16:59:30 -0700
commit05e6f318c6ecccea73698367010e51812c5b3862 (patch)
tree965d1c3bcdd518dd7411d8f39dd45189e1526d3d /deps/v8/test/mjsunit/math-floor.js
parent63607a0304e99259d3b7a24c44f7d29384b93cb4 (diff)
downloadnode-05e6f318c6ecccea73698367010e51812c5b3862.tar.gz
Upgrade V8 to 3.5.6
Diffstat (limited to 'deps/v8/test/mjsunit/math-floor.js')
-rw-r--r--deps/v8/test/mjsunit/math-floor.js34
1 files changed, 31 insertions, 3 deletions
diff --git a/deps/v8/test/mjsunit/math-floor.js b/deps/v8/test/mjsunit/math-floor.js
index 11f4cd789..f211ce2e5 100644
--- a/deps/v8/test/mjsunit/math-floor.js
+++ b/deps/v8/test/mjsunit/math-floor.js
@@ -27,10 +27,11 @@
// Flags: --max-new-space-size=256 --allow-natives-syntax
+var test_id = 0;
+
function testFloor(expect, input) {
- function test(n) {
- return Math.floor(n);
- }
+ var test = new Function('n',
+ '"' + (test_id++) + '";return Math.floor(n)');
assertEquals(expect, test(input));
assertEquals(expect, test(input));
assertEquals(expect, test(input));
@@ -51,6 +52,17 @@ function test() {
testFloor(-Infinity, -Infinity);
testFloor(NaN, NaN);
+ // Ensure that a negative zero coming from Math.floor is properly handled
+ // by other operations.
+ 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 +141,19 @@ function test() {
for (var i = 0; i < 500; i++) {
test();
}
+
+
+// Regression test for a bug where a negative zero coming from Math.floor
+// was not properly handled by other operations.
+function floorsum(i, n) {
+ var ret = Math.floor(n);
+ while (--i > 0) {
+ ret += Math.floor(n);
+ }
+ return ret;
+}
+assertEquals(-0, floorsum(1, -0));
+%OptimizeFunctionOnNextCall(floorsum);
+// The optimized function will deopt. Run it with enough iterations to try
+// to optimize via OSR (triggering the bug).
+assertEquals(-0, floorsum(100000, -0));