js/src/jit-test/tests/basic/parseIntTests.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 function parseIntHelper(n) {
     2     var a;
     3     for (var i = 0; i < 5; i++)
     4       a = parseInt(n);
     5     return a;
     6 }
     7 function doParseIntTests() {
     8     var inputs = [0, -0, .1, -.1, .7, -.7, 1.3, -1.3];
     9     var outputs = new Array(8);
    10     //avoid jit, unrolled
    11     outputs[0] = outputs[1] = outputs[2] = outputs[4] = 0;
    12     outputs[3] = outputs[5] = -0;
    13     outputs[6] = 1;
    14     outputs[7] = -1;
    15     for (var i = 0; i < 8; i++) {
    16         var testfn = new Function('return parseIntHelper(' + uneval(inputs[i]) + ');');
    17         assertEq(testfn(), outputs[i]);
    18     }
    19 }
    20 doParseIntTests();
    22 assertEq(parseInt("08"), 8);
    23 assertEq(parseInt("09"), 9);

mercurial