js/src/jit-test/tests/basic/truthies.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 load(libdir + 'andTestHelper.js');
     2 load(libdir + 'orTestHelper.js');
     4 (function () {
     5    var opsies   = ["||", "&&"];
     6    var falsies  = [null, undefined, false, NaN, 0, ""];
     7    var truthies = [{}, true, 1, 42, 1/0, -1/0, "blah"];
     8    var boolies  = [falsies, truthies];
    10    // The for each here should abort tracing, so that this test framework
    11    // relies only on the interpreter while the orTestHelper and andTestHelper
    12    //  functions get trace-JITed.
    13    for each (var op in opsies) {
    14      for (var i in boolies) {
    15        for (var j in boolies[i]) {
    16 	 var x = uneval(boolies[i][j]);
    17 	 for (var k in boolies) {
    18 	   for (var l in boolies[k]) {
    19 	     var y = uneval(boolies[k][l]);
    20 	     var prefix = (op == "||") ? "or" : "and";
    21 	     var f = new Function("return " + prefix + "TestHelper(" + x + "," + y + ",10)");
    22 	     var expected = eval(x + op + y) ? 45 : 0;
    23 	     assertEq(f(), expected);
    24 	   }
    25 	 }
    26        }
    27      }
    28    }
    29  })();

mercurial