js/src/tests/ecma_6/Generators/delegating-yield-9.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 // Test that yield* can appear in a loop, and inside yield.
     3 function* countdown(n) {
     4     while (n > 0) {
     5         yield (yield* countdown(--n));
     6     }
     7     return 34;
     8 }
    10 function collect_results(iter) {
    11     var ret = [];
    12     var result;
    13     do {
    14         result = iter.next();
    15         ret.push(result);
    16     } while (!result.done);
    17     return ret;
    18 }
    20 var expected = [
    21     // Only 34 yielded from the "yield" and the last return make it out.
    22     // Three yields in countdown(3), two in countdown(2), and one in
    23     // countdown(1) (called twice).
    24     {value: 34, done: false},
    25     {value: 34, done: false},
    26     {value: 34, done: false},
    27     {value: 34, done: false},
    28     {value: 34, done: false},
    29     {value: 34, done: false},
    30     {value: 34, done: false},
    31     {value: 34, done: true}, // final
    32 ];
    34 assertDeepEq(collect_results(countdown(3)), expected);
    36 if (typeof reportCompare == "function")
    37     reportCompare(true, true);

mercurial