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 17a6e804f5c144b0891a73ecafe4c15035cfa4c5..3bfcf0f567436e9e54014c0ef22e9b4631f42295 100644 |
| --- a/test/mjsunit/harmony/generators-iteration.js |
| +++ b/test/mjsunit/harmony/generators-iteration.js |
| @@ -307,6 +307,16 @@ TestGenerator( |
| "foo", |
| [2, "1foo3", 5, "4foo6", "foofoo"]); |
| +// Delegating yield |
| +TestGenerator( |
| + function* g26() { |
| + function* g() { var x = yield 1; yield 2; yield x; return 3; } |
| + yield* g(); |
| + }, |
| + [1, 2, undefined, undefined], |
| + "foo", |
| + [1, 2, "foo", undefined]); |
| + |
| function TestTryCatch() { |
| function* g() { yield 1; try { yield 2; } catch (e) { yield e; } yield 3; } |
| function Sentinel() {} |
| @@ -346,6 +356,7 @@ function TestTryCatch() { |
| assertThrows(function() { iter.throw(new Sentinel); }, Sentinel); |
| assertThrows(function() { iter.next(); }, Error); |
| + // *** |
| iter = g(); |
| assertIteratorResult(1, false, iter.next()); |
| assertIteratorResult(2, false, iter.next()); |
| @@ -360,6 +371,15 @@ function TestTryCatch() { |
| assertIteratorResult(3, false, iter.next()); |
| assertIteratorResult(undefined, true, iter.next()); |
| assertThrows(function() { iter.next(); }, Error); |
| + |
| + // same as *** above with delegate |
|
rossberg
2013/05/13 11:14:56
Would be cool if all these Test functions were fac
|
| + iter = (function* () { yield* g(); })(); |
| + assertIteratorResult(1, false, iter.next()); |
| + assertIteratorResult(2, false, iter.next()); |
| + var exn = new Sentinel; |
| + assertIteratorResult(exn, false, iter.throw(exn)); |
| + assertThrows(function() { iter.throw(new Sentinel); }, Sentinel); |
| + assertThrows(function() { iter.next(); }, Error); |
| } |
| TestTryCatch(); |
| @@ -393,6 +413,7 @@ function TestTryFinally() { |
| assertThrows(function() { iter.next(); }, Sentinel); |
| assertThrows(function() { iter.next(); }, Error); |
| + // *** |
| iter = g(); |
| assertIteratorResult(1, false, iter.next()); |
| assertIteratorResult(2, false, iter.next()); |
| @@ -422,6 +443,14 @@ function TestTryFinally() { |
| assertIteratorResult(4, false, iter.next()); |
| assertIteratorResult(undefined, true, iter.next()); |
| assertThrows(function() { iter.next(); }, Error); |
| + |
| + // same as *** above with delegate |
| + iter = (function* () { yield* g(); })(); |
| + assertIteratorResult(1, false, iter.next()); |
| + assertIteratorResult(2, false, iter.next()); |
| + assertIteratorResult(3, false, iter.throw(new Sentinel)); |
| + assertThrows(function() { iter.throw(new Sentinel2); }, Sentinel2); |
| + assertThrows(function() { iter.next(); }, Error); |
| } |
| TestTryFinally(); |
| @@ -476,6 +505,7 @@ function TestNestedTry() { |
| assertIteratorResult(undefined, true, iter.next()); |
| assertThrows(function() { iter.next(); }, Error); |
| + // *** |
| iter = g(); |
| assertIteratorResult(1, false, iter.next()); |
| assertIteratorResult(2, false, iter.next()); |
| @@ -495,6 +525,16 @@ function TestNestedTry() { |
| assertThrows(function() { iter.next(); }, Sentinel2); |
| assertThrows(function() { iter.next(); }, Error); |
| + // same as *** above with delegate |
| + iter = (function* () { yield* g(); })(); |
| + assertIteratorResult(1, false, iter.next()); |
| + assertIteratorResult(2, false, iter.next()); |
| + var exn = new Sentinel; |
| + assertIteratorResult(exn, false, iter.throw(exn)); |
| + assertIteratorResult(4, false, iter.throw(new Sentinel2)); |
| + assertThrows(function() { iter.next(); }, Sentinel2); |
| + assertThrows(function() { iter.next(); }, Error); |
| + |
| // That's probably enough. |
| } |
| TestNestedTry(); |