1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/ion/mathRound.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,48 @@ 1.4 +// Test Math.round() for IonMonkey. 1.5 +// Requires --ion-eager to enter at the top of each loop. 1.6 + 1.7 +var roundDTests = [ 1.8 + [-0, -0], 1.9 + [0.49999999999999997, 1], 1.10 + [0.5, 1], 1.11 + [1.0, 1], 1.12 + [1.5, 2], 1.13 + [792.8, 793], 1.14 + [-0.1, -0], 1.15 + [-1.0001, -1], 1.16 + [-3.14, -3], 1.17 + [2137483649.5, 2137483650], 1.18 + [2137483648.5, 2137483649], 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 roundITests = [ 1.30 + [0, 0], 1.31 + [4, 4], 1.32 + [2147483648, 2147483648], 1.33 + [-2147483649, -2147483649] 1.34 +]; 1.35 + 1.36 +// Typed functions to be compiled by Ion. 1.37 +function roundD(x) { return Math.round(x); } 1.38 +function roundI(x) { return Math.round(x); } 1.39 + 1.40 +function test() { 1.41 + // Always run this function in the interpreter. 1.42 + try {} catch (e) {} 1.43 + 1.44 + for (var i = 0; i < roundDTests.length; i++) 1.45 + assertEq(roundD(roundDTests[i][0]), roundDTests[i][1]); 1.46 + for (var i = 0; i < roundITests.length; i++) 1.47 + assertEq(roundI(roundITests[i][0]), roundITests[i][1]); 1.48 +} 1.49 + 1.50 +for (var i = 0; i < 40; i++) 1.51 + test();