js/src/jit-test/tests/basic/spread-array.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");
     3 load(libdir + "eqArrayHelper.js");
     5 assertEqArray([...[1, 2, 3]], [1, 2, 3]);
     6 assertEqArray([1, ...[2, 3, 4], 5], [1, 2, 3, 4, 5]);
     7 assertEqArray([1, ...[], 2], [1, 2]);
     8 assertEqArray([1, ...[2, 3], 4, ...[5, 6]], [1, 2, 3, 4, 5, 6]);
     9 assertEqArray([1, ...[], 2], [1, 2]);
    10 assertEqArray([1,, ...[2]], [1,, 2]);
    11 assertEqArray([1,, ...[2],, 3,, 4,], [1,, 2,, 3,, 4,]);
    12 assertEqArray([...[1, 2, 3],,,,], [1, 2, 3,,,,]);
    13 assertEqArray([,,...[1, 2, 3],,,,], [,,1,2,3,,,,]);
    15 assertEqArray([...[undefined]], [undefined]);
    17 // other iterable objects
    18 assertEqArray([...new Int32Array([1, 2, 3])], [1, 2, 3]);
    19 assertEqArray([..."abc"], ["a", "b", "c"]);
    20 assertEqArray([...[1, 2, 3][std_iterator]()], [1, 2, 3]);
    21 assertEqArray([...Set([1, 2, 3])], [1, 2, 3]);
    22 assertEqArray([...Map([["a", "A"], ["b", "B"], ["c", "C"]])].map(([k, v]) => k + v), ["aA", "bB", "cC"]);
    23 let itr = {};
    24 itr[std_iterator] = function () {
    25     return {
    26         i: 1,
    27         next: function() {
    28             if (this.i < 4)
    29                 return { value: this.i++, done: false };
    30             else
    31                 return { value: undefined, done: true };
    32         }
    33     };
    34 }
    35 assertEqArray([...itr], [1, 2, 3]);
    36 function* gen() {
    37     for (let i = 1; i < 4; i ++)
    38         yield i;
    39 }
    40 assertEqArray([...gen()], [1, 2, 3]);
    42 let a, b = [1, 2, 3];
    43 assertEqArray([...a=b], [1, 2, 3]);
    45 // According to the draft spec, null and undefined are to be treated as empty
    46 // arrays. However, they are not iterable. If the spec is not changed to be in
    47 // terms of iterables, these tests should be fixed.
    48 //assertEqArray([1, ...null, 2], [1, 2]);
    49 //assertEqArray([1, ...undefined, 2], [1, 2]);
    50 assertThrowsInstanceOf(() => [...null], TypeError);
    51 assertThrowsInstanceOf(() => [...undefined], TypeError);

mercurial