js/src/jit-test/tests/ion/truncateToInt32.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 w(y)
     4 {
     5     var x = 23.5;
     6     return x & y;
     7 }
     9 function f(x, y) {
    10     // Confuse the type analysis to not know the type of x.
    11     var t = 3.5 + x;
    12     t + 3.5;
    13     return x & y;
    14 }
    16 function g_bool(x, y) {
    17     var t;
    18     if (x + 0)
    19         t = true;
    20     else
    21         t = false;
    22     return t & y;
    24 }
    26 function g_null(x) {
    27     return null & x;
    28 }
    30 var obj = { valueOf: function () { return 5; } }
    32 assertEq(w(93), 21);
    33 assertEq(g_bool(1, 3), 1);
    34 assertEq(g_bool(0, 3), 0);
    35 assertEq(g_null(2), 0);
    37 assertEq(f(1, 7), 1);
    38 assertEq(f(true, 7), 1);
    39 assertEq(f(false, 7), 0);
    40 assertEq(f("3", 7), 3);
    41 assertEq(f(obj, 7), 5);
    42 assertEq(f(3.5, 7), 3);
    43 assertEq(f(undefined, 7), 0);
    44 assertEq(f(null, 7), 0);
    45 assertEq(f(Math.NaN, 7), 0);

mercurial