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

Side by Side Diff: test/mjsunit/es6/iteration-semantics.js

Issue 946943003: Revert of for-of should throw if result object is not an object (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « src/runtime/runtime-internal.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 results([{ done: false }, 193 results([{ done: false },
194 { value: 1, done: false }, 194 { value: 1, done: false },
195 // A missing "done" is the same as undefined, which 195 // A missing "done" is the same as undefined, which
196 // is false. 196 // is false.
197 { value: 2 }, 197 { value: 2 },
198 // Not done. 198 // Not done.
199 { value: 3, done: 0 }, 199 { value: 3, done: 0 },
200 // Done. 200 // Done.
201 { value: 4, done: 42 }]))); 201 { value: 4, done: 42 }])));
202 // Results that are not objects. 202 // Results that are not objects.
203 assertThrows(function() { 203 assertEquals([undefined, undefined, undefined],
204 assertEquals([undefined, undefined, undefined], 204 fold(append, [],
205 fold(append, [], 205 results([10, "foo", /qux/, { value: 37, done: true }])));
206 results([10, "foo", /qux/, { value: 37, done: true }])));
207 }, TypeError);
208 // Getters (shudder). 206 // Getters (shudder).
209 assertEquals([1, 2], 207 assertEquals([1, 2],
210 fold(append, [], 208 fold(append, [],
211 results([one_time_getter({ value: 1 }, 'done', false), 209 results([one_time_getter({ value: 1 }, 'done', false),
212 one_time_getter({ done: false }, 'value', 2), 210 one_time_getter({ done: false }, 'value', 2),
213 { value: 37, done: true }, 211 { value: 37, done: true },
214 never_getter(never_getter({}, 'done'), 'value')]))); 212 never_getter(never_getter({}, 'done'), 'value')])));
215 213
216 // Unlike the case with for-in, null and undefined cause an error. 214 // Unlike the case with for-in, null and undefined cause an error.
217 assertThrows('fold(sum, 0, unreachable(null))', TypeError); 215 assertThrows('fold(sum, 0, unreachable(null))', TypeError);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 if (name == 'next' && n-- < 0) throw "unreachable"; 327 if (name == 'next' && n-- < 0) throw "unreachable";
330 return iterator[name]; 328 return iterator[name];
331 }, 329 },
332 // Needed for integers_until(10)'s this.n++. 330 // Needed for integers_until(10)'s this.n++.
333 set: function(receiver, name, val) { 331 set: function(receiver, name, val) {
334 return iterator[name] = val; 332 return iterator[name] = val;
335 } 333 }
336 })); 334 }));
337 } 335 }
338 assertEquals(45, fold(sum, 0, poison_proxy_after(integers_until(10), 10))); 336 assertEquals(45, fold(sum, 0, poison_proxy_after(integers_until(10), 10)));
339
340
341 function test_iterator_result_object_non_object(value, descr) {
342 var arr = [];
343 var ex;
344 var message = 'Iterator result ' + (descr || value) + ' is not an object';
345 try {
346 fold(append, arr,
347 results([{value: 1}, {}, value, {value: 2}, {done: true}]));
348 } catch (e) {
349 ex = e;
350 }
351 assertInstanceof(ex, TypeError);
352 assertEquals(message, ex.message);
353 assertArrayEquals([1, undefined], arr);
354 }
355 test_iterator_result_object_non_object(null);
356 test_iterator_result_object_non_object(undefined);
357 test_iterator_result_object_non_object(42);
358 test_iterator_result_object_non_object('abc');
359 test_iterator_result_object_non_object(false);
360 test_iterator_result_object_non_object(Symbol('x'), 'Symbol(x)');
OLDNEW
« 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