js/src/jit-test/tests/basic/spread-call-eval.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 + "asserts.js");
     2 load(libdir + "iteration.js");
     4 assertEq(eval(...[]), undefined);
     5 assertEq(eval(...["1 + 2"]), 3);
     7 let a = 10, b = 1;
     8 assertEq(eval(...["a + b"]), 11);
    10 (function() {
    11   let a = 20;
    12   assertEq(eval(...["a + b"]), 21);
    13 })();
    15 with ({ a: 30 }) {
    16   assertEq(eval(...["a + b"]), 31);
    17 }
    19 let line0 = Error().lineNumber;
    20 try {             // line0 + 1
    21   eval(...["("]); // line0 + 2
    22 } catch (e) {
    23   assertEq(e.lineNumber, 1);
    24 }
    26 // other iterable objects
    27 assertEq(eval(...["a + b"][std_iterator]()), 11);
    28 assertEq(eval(...Set(["a + b"])), 11);
    29 let itr = {};
    30 itr[std_iterator] = function() {
    31     return {
    32         i: 0,
    33         next: function() {
    34             this.i++;
    35             if (this.i == 1)
    36                 return { value: "a + b", done: false };
    37             else
    38                 return { value: undefined, done: true };
    39         }
    40     };
    41 };
    42 assertEq(eval(...itr), 11);
    43 function* gen() {
    44     yield "a + b";
    45 }
    46 assertEq(eval(...gen()), 11);
    48 let c = ["C"], d = "D";
    49 assertEq(eval(...c=["c[0] + d"]), "c[0] + dD");
    51 // According to the draft spec, null and undefined are to be treated as empty
    52 // arrays. However, they are not iterable. If the spec is not changed to be in
    53 // terms of iterables, these tests should be fixed.
    54 //assertEq(eval("a + b", ...null), 11);
    55 //assertEq(eval("a + b", ...undefined), 11);
    56 assertThrowsInstanceOf(() => eval("a + b", ...null), TypeError);
    57 assertThrowsInstanceOf(() => eval("a + b", ...undefined), TypeError);

mercurial