1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/jaeger/inline/mathRound.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,41 @@ 1.4 + 1.5 +assertEq(Math.round(3.14), 3); 1.6 +assertEq(Math.round(0.5), 1); 1.7 +assertEq(Math.round(-0), -0); 1.8 +assertEq(Math.round(0), 0); 1.9 +assertEq(Math.round(-1.03), -1); 1.10 +assertEq(Math.round(2147483649), 2147483649); 1.11 +assertEq(Math.round(2147483647.5), 2147483648); 1.12 +assertEq(Math.floor(2147483647.1), 2147483647); 1.13 + 1.14 +/* Inferred as round(double). */ 1.15 +function round1(x) { 1.16 + return Math.round(x); 1.17 +} 1.18 +assertEq(round1(10.3), 10); 1.19 +assertEq(round1(-3.14), -3); 1.20 +assertEq(round1(-3.5), -3); 1.21 +assertEq(round1(-3.6), -4); 1.22 +assertEq(round1(3.5), 4); 1.23 +assertEq(round1(3.6), 4); 1.24 +assertEq(round1(0), 0); 1.25 +assertEq(round1(-0), -0); // recompile to return double 1.26 +assertEq(round1(12345), 12345); 1.27 +assertEq(round1(654.6), 655); 1.28 + 1.29 +/* Inferred as round(double). */ 1.30 +function round2(x) { 1.31 + return Math.round(x); 1.32 +} 1.33 +assertEq(round2(1234.5), 1235); 1.34 +assertEq(round2(NaN), NaN); // recompile to return double 1.35 +assertEq(round2(4.6), 5); 1.36 + 1.37 +/* Inferred as round(int). */ 1.38 +function round3(x) { 1.39 + return Math.round(x); 1.40 +} 1.41 +assertEq(round3(4), 4); 1.42 +assertEq(round3(-5), -5); 1.43 +assertEq(round3(0), 0); 1.44 +