js/src/jit-test/tests/ion/mathFloor.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/ion/mathFloor.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,50 @@
     1.4 +// Test Math.floor() for IonMonkey.
     1.5 +// Requires --ion-eager to enter at the top of each loop.
     1.6 +
     1.7 +var floorDTests = [
     1.8 +	[-0, -0],
     1.9 +	[0.49999999999999997, 0],
    1.10 +	[0.5, 0],
    1.11 +	[1.0, 1],
    1.12 +	[1.5, 1],
    1.13 +	[792.8, 792],
    1.14 +	[-0.1, -1],
    1.15 +	[-1.0001, -2],
    1.16 +	[-3.14, -4],
    1.17 +	[2137483649.5, 2137483649],
    1.18 +	[2137483648.5, 2137483648],
    1.19 +	[2137483647.1, 2137483647],
    1.20 +	[900000000000, 900000000000],
    1.21 +	[-0, -0],
    1.22 +	[-Infinity, -Infinity],
    1.23 +	[Infinity, Infinity],
    1.24 +	[NaN, NaN],
    1.25 +	[-2147483648.8, -2147483649],
    1.26 +	[-2147483649.8, -2147483650]
    1.27 +];
    1.28 +
    1.29 +var floorITests = [
    1.30 +	[0, 0],
    1.31 +	[4, 4],
    1.32 +	[-1, -1],
    1.33 +	[-7, -7],
    1.34 +	[2147483648, 2147483648],
    1.35 +	[-2147483649, -2147483649]
    1.36 +];
    1.37 +
    1.38 +// Typed functions to be compiled by Ion.
    1.39 +function floorD(x) { return Math.floor(x); }
    1.40 +function floorI(x) { return Math.floor(x); }
    1.41 +
    1.42 +function test() {
    1.43 +	// Always run this function in the interpreter.
    1.44 +	try {} catch (e) {}
    1.45 +
    1.46 +	for (var i = 0; i < floorDTests.length; i++)
    1.47 +		assertEq(floorD(floorDTests[i][0]), floorDTests[i][1]);
    1.48 +	for (var i = 0; i < floorITests.length; i++)
    1.49 +		assertEq(floorI(floorITests[i][0]), floorITests[i][1]);
    1.50 +}
    1.51 +
    1.52 +for (var i = 0; i < 40; i++)
    1.53 +	test();

mercurial