js/src/tests/ecma_6/Generators/delegating-yield-7.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.

michael@0 1 // The iteratee of yield* can be a proxy.
michael@0 2
michael@0 3 function results(results) {
michael@0 4 var i = 0;
michael@0 5 function iterator() {
michael@0 6 return this;
michael@0 7 }
michael@0 8 function next() {
michael@0 9 return results[i++];
michael@0 10 }
michael@0 11 var ret = { next: next }
michael@0 12 ret[std_iterator] = iterator;
michael@0 13 return ret;
michael@0 14 }
michael@0 15
michael@0 16 function* yield_results(expected) {
michael@0 17 return yield* Proxy(results(expected), {});
michael@0 18 }
michael@0 19
michael@0 20 function collect_results(iter) {
michael@0 21 var ret = [];
michael@0 22 var result;
michael@0 23 do {
michael@0 24 result = iter.next();
michael@0 25 ret.push(result);
michael@0 26 } while (!result.done);
michael@0 27 return ret;
michael@0 28 }
michael@0 29
michael@0 30 // We have to put a full result for the end, because the return will re-box.
michael@0 31 var expected = [{value: 1}, 13, "foo", {value: 34, done: true}];
michael@0 32
michael@0 33 // Sanity check.
michael@0 34 assertDeepEq(expected, collect_results(results(expected)));
michael@0 35 assertDeepEq(expected, collect_results(yield_results(expected)));
michael@0 36
michael@0 37 if (typeof reportCompare == "function")
michael@0 38 reportCompare(true, true);

mercurial