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.

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

mercurial