js/src/jit-test/tests/ion/valueToInt32.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.

     1 // vim: set ts=8 sts=4 et sw=4 tw=99:
     3 function f(x, y) {
     4     // Confuse the type analysis to not know the type of x.
     5     var u;
     6     var a = x + u;
     7     var b = x + 3;
     8     return x + y;
     9 }
    11 function g_bool(x, y) {
    12     var t;
    13     if (x + 0)
    14         t = true;
    15     else
    16         t = false;
    17     return t + y;
    19 }
    20 function g_null(x) {
    21     return null + x;
    22 }
    24 assertEq(g_bool(1, 2), 3);
    25 assertEq(g_bool(0, 2), 2);
    26 assertEq(g_null(2), 2);
    28 // These will not bailout.
    29 assertEq(f(Math.cos(Math.PI), 2), 1);
    30 assertEq(f(null, 2), 2);
    31 assertEq(f(false, 2), 2);
    32 assertEq(f(true, 2), 3);
    33 assertEq(f(17, 2), 19);
    35 // These will bailout.
    36 assertEq(f(undefined, 2), Number.NaN);
    37 assertEq(f("20", 2), "202");
    38 assertEq(f(16.3, 2), 18.3);
    39 assertEq((1 / f(-0, -0)), -Infinity);

mercurial