Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Unified Diff: test/mjsunit/harmony/generators-iteration.js

Issue 14582007: Implement yield* (delegating yield) (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/ia32/full-codegen-ia32.cc ('K') | « src/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« src/ia32/full-codegen-ia32.cc ('K') | « src/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698