js/src/jit-test/tests/jaeger/inline/mathRound.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1
michael@0 2 assertEq(Math.round(3.14), 3);
michael@0 3 assertEq(Math.round(0.5), 1);
michael@0 4 assertEq(Math.round(-0), -0);
michael@0 5 assertEq(Math.round(0), 0);
michael@0 6 assertEq(Math.round(-1.03), -1);
michael@0 7 assertEq(Math.round(2147483649), 2147483649);
michael@0 8 assertEq(Math.round(2147483647.5), 2147483648);
michael@0 9 assertEq(Math.floor(2147483647.1), 2147483647);
michael@0 10
michael@0 11 /* Inferred as round(double). */
michael@0 12 function round1(x) {
michael@0 13 return Math.round(x);
michael@0 14 }
michael@0 15 assertEq(round1(10.3), 10);
michael@0 16 assertEq(round1(-3.14), -3);
michael@0 17 assertEq(round1(-3.5), -3);
michael@0 18 assertEq(round1(-3.6), -4);
michael@0 19 assertEq(round1(3.5), 4);
michael@0 20 assertEq(round1(3.6), 4);
michael@0 21 assertEq(round1(0), 0);
michael@0 22 assertEq(round1(-0), -0); // recompile to return double
michael@0 23 assertEq(round1(12345), 12345);
michael@0 24 assertEq(round1(654.6), 655);
michael@0 25
michael@0 26 /* Inferred as round(double). */
michael@0 27 function round2(x) {
michael@0 28 return Math.round(x);
michael@0 29 }
michael@0 30 assertEq(round2(1234.5), 1235);
michael@0 31 assertEq(round2(NaN), NaN); // recompile to return double
michael@0 32 assertEq(round2(4.6), 5);
michael@0 33
michael@0 34 /* Inferred as round(int). */
michael@0 35 function round3(x) {
michael@0 36 return Math.round(x);
michael@0 37 }
michael@0 38 assertEq(round3(4), 4);
michael@0 39 assertEq(round3(-5), -5);
michael@0 40 assertEq(round3(0), 0);
michael@0 41

mercurial