js/src/jit-test/tests/basic/testParseInt.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 /*
     2  * Any copyright is dedicated to the Public Domain.
     3  * http://creativecommons.org/licenses/publicdomain/
     4  */
     6 function testInt(n, result) {
     7     var x = 0;
     8     for (var i = 0; i < 15; i++) {
     9         assertEq(parseInt(n, 10), result);
    10         assertEq(parseInt(n, 0), result);
    11         assertEq(parseInt(n), result);
    12         assertEq(parseInt(n, x), result);
    14         if (x % 2 == 0)
    15             x = 10;
    16         else
    17             x = 0;
    18     }
    19 }
    21 function testDouble(n, result) {
    22     var x = 0;
    23     for (var i = 0; i < 15; i++) {
    24         assertEq(parseInt(n, 10), result);
    25         assertEq(parseInt(n, 0), result);
    26         assertEq(parseInt(n), result);
    27         assertEq(parseInt(n, x), result);
    29         if (x % 2 == 0)
    30             x = 10;
    31         else
    32             x = 0;
    33     }
    34 }
    36 testInt(2147483647, 2147483647);
    37 testInt(-2147483648, -2147483648);
    38 testInt(17, 17);
    39 testInt(-1, -1);
    40 testInt(0, 0);
    42 testDouble(1e21, 1);
    43 testDouble(-5.7, -5);
    44 testDouble(1.7, 1);
    45 testDouble(1.0e-6, 0);
    46 testDouble(1.0e-7, 1);
    47 testDouble(NaN, NaN);
    48 testDouble(1e20, 1e20);

mercurial