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

Side by Side Diff: test/mjsunit/harmony/generators-iteration.js

Issue 14857009: GeneratorFunction() makes generator instances (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 throw (yield (1 + (yield 2) + 3)) 313 throw (yield (1 + (yield 2) + 3))
314 } catch (e) { 314 } catch (e) {
315 if (typeof e == 'object') throw e; 315 if (typeof e == 'object') throw e;
316 return e + (yield (4 + (yield 5) + 6)); 316 return e + (yield (4 + (yield 5) + 6));
317 } 317 }
318 }, 318 },
319 [2, NaN, 5, NaN, NaN], 319 [2, NaN, 5, NaN, NaN],
320 "foo", 320 "foo",
321 [2, "1foo3", 5, "4foo6", "foofoo"]); 321 [2, "1foo3", 5, "4foo6", "foofoo"]);
322 322
323 // Generator function instances.
324 TestGenerator(GeneratorFunction(),
325 [undefined],
326 "foo",
327 [undefined]);
328
329 TestGenerator(new GeneratorFunction(),
330 [undefined],
331 "foo",
332 [undefined]);
333
334 TestGenerator(GeneratorFunction('yield 1;'),
335 [1, undefined],
336 "foo",
337 [1, undefined]);
338
339 TestGenerator(
340 function() { return GeneratorFunction('x', 'y', 'yield x + y;')(1, 2) },
341 [3, undefined],
342 "foo",
343 [3, undefined]);
344
323 function TestTryCatch() { 345 function TestTryCatch() {
324 function* g() { yield 1; try { yield 2; } catch (e) { yield e; } yield 3; } 346 function* g() { yield 1; try { yield 2; } catch (e) { yield e; } yield 3; }
325 function Sentinel() {} 347 function Sentinel() {}
326 var iter; 348 var iter;
327 349
328 iter = g(); 350 iter = g();
329 assertIteratorResult(1, false, iter.next()); 351 assertIteratorResult(1, false, iter.next());
330 assertIteratorResult(2, false, iter.next()); 352 assertIteratorResult(2, false, iter.next());
331 assertIteratorResult(3, false, iter.next()); 353 assertIteratorResult(3, false, iter.next());
332 assertIteratorResult(undefined, true, iter.next()); 354 assertIteratorResult(undefined, true, iter.next());
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 function TestThrowRecursion() { 548 function TestThrowRecursion() {
527 function* g() { yield iter.throw(1); } 549 function* g() { yield iter.throw(1); }
528 var iter = g(); 550 var iter = g();
529 return iter.next(); 551 return iter.next();
530 } 552 }
531 assertThrows(TestNextRecursion, Error); 553 assertThrows(TestNextRecursion, Error);
532 assertThrows(TestSendRecursion, Error); 554 assertThrows(TestSendRecursion, Error);
533 assertThrows(TestThrowRecursion, Error); 555 assertThrows(TestThrowRecursion, Error);
534 } 556 }
535 TestRecursion(); 557 TestRecursion();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698