Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 // This file was written by Andy Wingo <wingo@igalia.com> and originally
2 // contributed to V8 as generators-objects.js, available here:
3 //
4 // http://code.google.com/p/v8/source/browse/branches/bleeding_edge/test/mjsunit/harmony/generators-objects.js
6 // Test that yield* re-yields received results without re-boxing.
8 function results(results) {
9 var i = 0;
10 function next() {
11 return results[i++];
12 }
13 var iter = { next: next }
14 var ret = {};
15 ret[std_iterator] = function () { return iter; }
16 return ret;
17 }
19 function* yield_results(expected) {
20 return yield* results(expected);
21 }
23 function collect_results(iterable) {
24 var ret = [];
25 var result;
26 var iter = iterable[std_iterator]();
27 do {
28 result = iter.next();
29 ret.push(result);
30 } while (!result.done);
31 return ret;
32 }
34 // We have to put a full result for the end, because the return will re-box.
35 var expected = [{value: 1}, 13, "foo", {value: 34, done: true}];
37 // Sanity check.
38 assertDeepEq(expected, collect_results(results(expected)));
39 assertDeepEq(expected, collect_results(yield_results(expected)));
41 if (typeof reportCompare == "function")
42 reportCompare(true, true);