js/src/tests/ecma_6/Math/clz32.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 // Undefined and NaN end up as zero after ToUint32
     2 assertEq(Math.clz32(), 32);
     3 assertEq(Math.clz32(NaN), 32);
     4 assertEq(Math.clz32.call(), 32);
     5 // 0
     6 assertEq(Math.clz32(null), 32);
     7 assertEq(Math.clz32(false), 32);
     8 // 1
     9 assertEq(Math.clz32(true), 31);
    10 // 3
    11 assertEq(Math.clz32(3.5), 30);
    12 // NaN -> 0
    13 assertEq(Math.clz32({}), 32);
    14 // 2
    15 assertEq(Math.clz32({valueOf: function() { return 2; }}), 30);
    16 // 0 -> 0
    17 assertEq(Math.clz32([]), 32);
    18 assertEq(Math.clz32(""), 32);
    19 // NaN -> 0
    20 assertEq(Math.clz32([1, 2, 3]), 32);
    21 assertEq(Math.clz32("bar"), 32);
    22 // 15
    23 assertEq(Math.clz32("15"), 28);
    26 assertEq(Math.clz32(0x80000000), 0);
    27 assertEq(Math.clz32(0xF0FF1000), 0);
    28 assertEq(Math.clz32(0x7F8F0001), 1);
    29 assertEq(Math.clz32(0x3FFF0100), 2);
    30 assertEq(Math.clz32(0x1FF50010), 3);
    31 assertEq(Math.clz32(0x00800000), 8);
    32 assertEq(Math.clz32(0x00400000), 9);
    33 assertEq(Math.clz32(0x00008000), 16);
    34 assertEq(Math.clz32(0x00004000), 17);
    35 assertEq(Math.clz32(0x00000080), 24);
    36 assertEq(Math.clz32(0x00000040), 25);
    37 assertEq(Math.clz32(0x00000001), 31);
    38 assertEq(Math.clz32(0), 32);
    40 reportCompare(0, 0, 'ok');

mercurial