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

Unified Diff: test/mjsunit/es6/iteration-semantics.js

Issue 929733003: for-of should throw if result object is not an object (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: add strings and move runtime function Created 5 years, 10 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
« no previous file with comments | « src/runtime/runtime-internal.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/iteration-semantics.js
diff --git a/test/mjsunit/es6/iteration-semantics.js b/test/mjsunit/es6/iteration-semantics.js
index 544c94d915c21029ccdba9c92eee0441500a2c06..57c558de64ad0b0042919213129699981eb8da53 100644
--- a/test/mjsunit/es6/iteration-semantics.js
+++ b/test/mjsunit/es6/iteration-semantics.js
@@ -200,9 +200,11 @@ assertEquals([undefined, 1, 2, 3],
// Done.
{ value: 4, done: 42 }])));
// Results that are not objects.
-assertEquals([undefined, undefined, undefined],
- fold(append, [],
- results([10, "foo", /qux/, { value: 37, done: true }])));
+assertThrows(function() {
+ assertEquals([undefined, undefined, undefined],
+ fold(append, [],
+ results([10, "foo", /qux/, { value: 37, done: true }])));
+}, TypeError);
// Getters (shudder).
assertEquals([1, 2],
fold(append, [],
@@ -334,3 +336,25 @@ function poison_proxy_after(iterable, n) {
}));
}
assertEquals(45, fold(sum, 0, poison_proxy_after(integers_until(10), 10)));
+
+
+function test_iterator_result_object_non_object(value, descr) {
+ var arr = [];
+ var ex;
+ var message = 'Iterator result ' + (descr || value) + ' is not an object';
+ try {
+ fold(append, arr,
+ results([{value: 1}, {}, value, {value: 2}, {done: true}]));
+ } catch (e) {
+ ex = e;
+ }
+ assertInstanceof(ex, TypeError);
+ assertEquals(message, ex.message);
+ assertArrayEquals([1, undefined], arr);
+}
+test_iterator_result_object_non_object(null);
+test_iterator_result_object_non_object(undefined);
+test_iterator_result_object_non_object(42);
+test_iterator_result_object_non_object('abc');
+test_iterator_result_object_non_object(false);
+test_iterator_result_object_non_object(Symbol('x'), 'Symbol(x)');
« no previous file with comments | « src/runtime/runtime-internal.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698