Chromium Code Reviews| Index: test/mjsunit/harmony/generators-iteration.js |
| diff --git a/test/mjsunit/harmony/generators-iteration.js b/test/mjsunit/harmony/generators-iteration.js |
| index 2ca35f2ee8a4037e86867fe4ecb49fa2eff0b9b6..7211896c6c9a4d78ea08579d5a5a5e6f4463cb1e 100644 |
| --- a/test/mjsunit/harmony/generators-iteration.js |
| +++ b/test/mjsunit/harmony/generators-iteration.js |
| @@ -346,6 +346,34 @@ TestGenerator( |
| "foo", |
| [3, undefined]); |
| +// Test that yield* re-yields received results without re-boxing. |
| +function TestDelegatingYield() { |
| + function results(results) { |
| + var i = 0; |
| + function next() { |
| + return results[i++]; |
| + } |
| + return { next: next } |
| + } |
| + function collect_results(iter) { |
| + var ret = []; |
| + var result; |
| + do { |
| + result = iter.next(); |
| + ret.push(result); |
| + } while (!result.done); |
| + return ret; |
| + } |
| + // We have to put a full result for the end, because the return will re-box. |
| + var expected = [{value: 1}, 13, "foo", {value: 34, done: true}]; |
| + |
| + // Sanity check. |
| + assertEquals(expected, collect_results(results(expected))); |
| + assertEquals(expected, |
| + collect_results((function*(){return yield* results(expected);})())); |
|
rossberg
2013/06/13 09:53:18
Nit: spacing
|
| +} |
| +TestDelegatingYield(); |
| + |
| function TestTryCatch(instantiate) { |
| function* g() { yield 1; try { yield 2; } catch (e) { yield e; } yield 3; } |
| function Sentinel() {} |