michael@0: // Test Math.floor() for IonMonkey. michael@0: // Requires --ion-eager to enter at the top of each loop. michael@0: michael@0: var floorDTests = [ michael@0: [-0, -0], michael@0: [0.49999999999999997, 0], michael@0: [0.5, 0], michael@0: [1.0, 1], michael@0: [1.5, 1], michael@0: [792.8, 792], michael@0: [-0.1, -1], michael@0: [-1.0001, -2], michael@0: [-3.14, -4], michael@0: [2137483649.5, 2137483649], michael@0: [2137483648.5, 2137483648], michael@0: [2137483647.1, 2137483647], michael@0: [900000000000, 900000000000], michael@0: [-0, -0], michael@0: [-Infinity, -Infinity], michael@0: [Infinity, Infinity], michael@0: [NaN, NaN], michael@0: [-2147483648.8, -2147483649], michael@0: [-2147483649.8, -2147483650] michael@0: ]; michael@0: michael@0: var floorITests = [ michael@0: [0, 0], michael@0: [4, 4], michael@0: [-1, -1], michael@0: [-7, -7], michael@0: [2147483648, 2147483648], michael@0: [-2147483649, -2147483649] michael@0: ]; michael@0: michael@0: // Typed functions to be compiled by Ion. michael@0: function floorD(x) { return Math.floor(x); } michael@0: function floorI(x) { return Math.floor(x); } michael@0: michael@0: function test() { michael@0: // Always run this function in the interpreter. michael@0: try {} catch (e) {} michael@0: michael@0: for (var i = 0; i < floorDTests.length; i++) michael@0: assertEq(floorD(floorDTests[i][0]), floorDTests[i][1]); michael@0: for (var i = 0; i < floorITests.length; i++) michael@0: assertEq(floorI(floorITests[i][0]), floorITests[i][1]); michael@0: } michael@0: michael@0: for (var i = 0; i < 40; i++) michael@0: test();