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

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

Issue 136003003: Closed generator returns a completed object instead of throwing a error (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Rev 2 Created 6 years, 11 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 7fad97e9445ce1f5b4a85180be3e6b013c2789fa..b74ddcd8021f6bfdcad6ac5f8bc14eb6931c2736 100644
--- a/test/mjsunit/harmony/generators-iteration.js
+++ b/test/mjsunit/harmony/generators-iteration.js
@@ -35,6 +35,18 @@ function assertIteratorResult(value, done, result) {
assertEquals({ value: value, done: done}, result);
}
+function assertIteratorIsClosed(iter) {
+ assertIteratorResult(undefined, true, iter.next());
+ assertDoesNotThrow(function() { iter.next(); });
+}
+
+function assertThrownIteratorIsClosed(iter) {
+ // TODO(yusukesuzuki): Since status of a thrown generator is "executing",
+ // following tests are failed.
+ // https://code.google.com/p/v8/issues/detail?id=3096
+ // assertIteratorIsClosed(iter);
+}
+
function TestGeneratorResultPrototype() {
function* g() { yield 1; }
var iter = g();
@@ -57,7 +69,7 @@ function TestGenerator(g, expected_values_for_next,
i == expected_values_for_next.length - 1,
iter.next());
}
- assertThrows(function() { iter.next(); }, Error);
+ assertIteratorIsClosed(iter);
}
function testSend(thunk) {
var iter = thunk();
@@ -66,7 +78,7 @@ function TestGenerator(g, expected_values_for_next,
i == expected_values_for_send.length - 1,
iter.next(send_val));
}
- assertThrows(function() { iter.next(send_val); }, Error);
+ assertIteratorIsClosed(iter);
}
function testThrow(thunk) {
for (var i = 0; i < expected_values_for_next.length; i++) {
@@ -78,7 +90,7 @@ function TestGenerator(g, expected_values_for_next,
}
function Sentinel() {}
assertThrows(function () { iter.throw(new Sentinel); }, Sentinel);
- assertThrows(function () { iter.next(); }, Error);
+ assertThrownIteratorIsClosed(iter);
}
}
@@ -393,21 +405,20 @@ function TestTryCatch(instantiate) {
assertIteratorResult(1, false, iter.next());
assertIteratorResult(2, false, iter.next());
assertIteratorResult(3, false, iter.next());
- assertIteratorResult(undefined, true, iter.next());
- assertThrows(function() { iter.next(); }, Error);
+ assertIteratorIsClosed(iter);
}
Test1(instantiate(g));
function Test2(iter) {
assertThrows(function() { iter.throw(new Sentinel); }, Sentinel);
- assertThrows(function() { iter.next(); }, Error);
+ assertThrownIteratorIsClosed(iter);
}
Test2(instantiate(g));
function Test3(iter) {
assertIteratorResult(1, false, iter.next());
assertThrows(function() { iter.throw(new Sentinel); }, Sentinel);
- assertThrows(function() { iter.next(); }, Error);
+ assertThrownIteratorIsClosed(iter);
}
Test3(instantiate(g));
@@ -417,8 +428,7 @@ function TestTryCatch(instantiate) {
var exn = new Sentinel;
assertIteratorResult(exn, false, iter.throw(exn));
assertIteratorResult(3, false, iter.next());
- assertIteratorResult(undefined, true, iter.next());
- assertThrows(function() { iter.next(); }, Error);
+ assertIteratorIsClosed(iter);
}
Test4(instantiate(g));
@@ -429,8 +439,7 @@ function TestTryCatch(instantiate) {
assertIteratorResult(exn, false, iter.throw(exn));
assertIteratorResult(3, false, iter.next());
assertThrows(function() { iter.throw(new Sentinel); }, Sentinel);
- assertThrows(function() { iter.next(); }, Error);
-
+ assertThrownIteratorIsClosed(iter);
}
Test5(instantiate(g));
@@ -440,7 +449,7 @@ function TestTryCatch(instantiate) {
var exn = new Sentinel;
assertIteratorResult(exn, false, iter.throw(exn));
assertThrows(function() { iter.throw(new Sentinel); }, Sentinel);
- assertThrows(function() { iter.next(); }, Error);
+ assertThrownIteratorIsClosed(iter);
}
Test6(instantiate(g));
@@ -448,8 +457,7 @@ function TestTryCatch(instantiate) {
assertIteratorResult(1, false, iter.next());
assertIteratorResult(2, false, iter.next());
assertIteratorResult(3, false, iter.next());
- assertIteratorResult(undefined, true, iter.next());
- assertThrows(function() { iter.next(); }, Error);
+ assertIteratorIsClosed(iter);
}
Test7(instantiate(g));
}
@@ -466,21 +474,20 @@ function TestTryFinally(instantiate) {
assertIteratorResult(2, false, iter.next());
assertIteratorResult(3, false, iter.next());
assertIteratorResult(4, false, iter.next());
- assertIteratorResult(undefined, true, iter.next());
- assertThrows(function() { iter.next(); }, Error);
+ assertIteratorIsClosed(iter);
}
Test1(instantiate(g));
function Test2(iter) {
assertThrows(function() { iter.throw(new Sentinel); }, Sentinel);
- assertThrows(function() { iter.next(); }, Error);
+ assertThrownIteratorIsClosed(iter);
}
Test2(instantiate(g));
function Test3(iter) {
assertIteratorResult(1, false, iter.next());
assertThrows(function() { iter.throw(new Sentinel); }, Sentinel);
- assertThrows(function() { iter.next(); }, Error);
+ assertThrownIteratorIsClosed(iter);
}
Test3(instantiate(g));
@@ -489,8 +496,7 @@ function TestTryFinally(instantiate) {
assertIteratorResult(2, false, iter.next());
assertIteratorResult(3, false, iter.throw(new Sentinel));
assertThrows(function() { iter.next(); }, Sentinel);
- assertThrows(function() { iter.next(); }, Error);
-
+ assertThrownIteratorIsClosed(iter);
}
Test4(instantiate(g));
@@ -499,7 +505,7 @@ function TestTryFinally(instantiate) {
assertIteratorResult(2, false, iter.next());
assertIteratorResult(3, false, iter.throw(new Sentinel));
assertThrows(function() { iter.throw(new Sentinel2); }, Sentinel2);
- assertThrows(function() { iter.next(); }, Error);
+ assertThrownIteratorIsClosed(iter);
}
Test5(instantiate(g));
@@ -508,7 +514,7 @@ function TestTryFinally(instantiate) {
assertIteratorResult(2, false, iter.next());
assertIteratorResult(3, false, iter.next());
assertThrows(function() { iter.throw(new Sentinel); }, Sentinel);
- assertThrows(function() { iter.next(); }, Error);
+ assertThrownIteratorIsClosed(iter);
}
Test6(instantiate(g));
@@ -518,7 +524,7 @@ function TestTryFinally(instantiate) {
assertIteratorResult(3, false, iter.next());
assertIteratorResult(4, false, iter.next());
assertThrows(function() { iter.throw(new Sentinel); }, Sentinel);
- assertThrows(function() { iter.next(); }, Error);
+ assertThrownIteratorIsClosed(iter);
}
Test7(instantiate(g));
@@ -527,9 +533,7 @@ function TestTryFinally(instantiate) {
assertIteratorResult(2, false, iter.next());
assertIteratorResult(3, false, iter.next());
assertIteratorResult(4, false, iter.next());
- assertIteratorResult(undefined, true, iter.next());
- assertThrows(function() { iter.next(); }, Error);
-
+ assertIteratorIsClosed(iter);
}
Test8(instantiate(g));
}
@@ -556,14 +560,13 @@ function TestNestedTry(instantiate) {
assertIteratorResult(3, false, iter.next());
assertIteratorResult(4, false, iter.next());
assertIteratorResult(5, false, iter.next());
- assertIteratorResult(undefined, true, iter.next());
- assertThrows(function() { iter.next(); }, Error);
+ assertIteratorIsClosed(iter);
}
Test1(instantiate(g));
function Test2(iter) {
assertThrows(function() { iter.throw(new Sentinel); }, Sentinel);
- assertThrows(function() { iter.next(); }, Error);
+ assertThrownIteratorIsClosed(iter);
}
Test2(instantiate(g));
@@ -571,7 +574,7 @@ function TestNestedTry(instantiate) {
assertIteratorResult(1, false, iter.next());
assertIteratorResult(4, false, iter.throw(new Sentinel));
assertThrows(function() { iter.next(); }, Sentinel);
- assertThrows(function() { iter.next(); }, Error);
+ assertThrownIteratorIsClosed(iter);
}
Test3(instantiate(g));
@@ -579,7 +582,7 @@ function TestNestedTry(instantiate) {
assertIteratorResult(1, false, iter.next());
assertIteratorResult(4, false, iter.throw(new Sentinel));
assertThrows(function() { iter.throw(new Sentinel2); }, Sentinel2);
- assertThrows(function() { iter.next(); }, Error);
+ assertThrownIteratorIsClosed(iter);
}
Test4(instantiate(g));
@@ -591,9 +594,7 @@ function TestNestedTry(instantiate) {
assertIteratorResult(3, false, iter.next());
assertIteratorResult(4, false, iter.next());
assertIteratorResult(5, false, iter.next());
- assertIteratorResult(undefined, true, iter.next());
- assertThrows(function() { iter.next(); }, Error);
-
+ assertIteratorIsClosed(iter);
}
Test5(instantiate(g));
@@ -604,7 +605,7 @@ function TestNestedTry(instantiate) {
assertIteratorResult(exn, false, iter.throw(exn));
assertIteratorResult(4, false, iter.throw(new Sentinel2));
assertThrows(function() { iter.next(); }, Sentinel2);
- assertThrows(function() { iter.next(); }, Error);
+ assertThrownIteratorIsClosed(iter);
}
Test6(instantiate(g));
@@ -616,8 +617,7 @@ function TestNestedTry(instantiate) {
assertIteratorResult(3, false, iter.next());
assertIteratorResult(4, false, iter.throw(new Sentinel2));
assertThrows(function() { iter.next(); }, Sentinel2);
- assertThrows(function() { iter.next(); }, Error);
-
+ assertThrownIteratorIsClosed(iter);
}
Test7(instantiate(g));
« 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