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..dc210d5b1167521c833365e4a120ed8a6fc45439 100644 |
--- a/test/mjsunit/harmony/generators-iteration.js |
+++ b/test/mjsunit/harmony/generators-iteration.js |
@@ -346,6 +346,36 @@ 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* yield_results(expected) { |
+ return yield* results(expected); |
+ } |
+ 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(yield_results(expected))); |
+} |
+TestDelegatingYield(); |
+ |
function TestTryCatch(instantiate) { |
function* g() { yield 1; try { yield 2; } catch (e) { yield e; } yield 3; } |
function Sentinel() {} |