js/src/tests/ecma_6/Generators/delegating-yield-1.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 // This file was written by Andy Wingo <wingo@igalia.com> and originally
michael@0 2 // contributed to V8 as generators-objects.js, available here:
michael@0 3 //
michael@0 4 // http://code.google.com/p/v8/source/browse/branches/bleeding_edge/test/mjsunit/harmony/generators-objects.js
michael@0 5
michael@0 6 // Test that yield* re-yields received results without re-boxing.
michael@0 7
michael@0 8 function results(results) {
michael@0 9 var i = 0;
michael@0 10 function next() {
michael@0 11 return results[i++];
michael@0 12 }
michael@0 13 var iter = { next: next }
michael@0 14 var ret = {};
michael@0 15 ret[std_iterator] = function () { return iter; }
michael@0 16 return ret;
michael@0 17 }
michael@0 18
michael@0 19 function* yield_results(expected) {
michael@0 20 return yield* results(expected);
michael@0 21 }
michael@0 22
michael@0 23 function collect_results(iterable) {
michael@0 24 var ret = [];
michael@0 25 var result;
michael@0 26 var iter = iterable[std_iterator]();
michael@0 27 do {
michael@0 28 result = iter.next();
michael@0 29 ret.push(result);
michael@0 30 } while (!result.done);
michael@0 31 return ret;
michael@0 32 }
michael@0 33
michael@0 34 // We have to put a full result for the end, because the return will re-box.
michael@0 35 var expected = [{value: 1}, 13, "foo", {value: 34, done: true}];
michael@0 36
michael@0 37 // Sanity check.
michael@0 38 assertDeepEq(expected, collect_results(results(expected)));
michael@0 39 assertDeepEq(expected, collect_results(yield_results(expected)));
michael@0 40
michael@0 41 if (typeof reportCompare == "function")
michael@0 42 reportCompare(true, true);

mercurial