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

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

Issue 15218004: 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
« no previous file with comments | « src/v8natives.js ('k') | test/mjsunit/harmony/generators-runtime.js » ('j') | 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 throw (yield (1 + (yield 2) + 3)) 317 throw (yield (1 + (yield 2) + 3))
318 } catch (e) { 318 } catch (e) {
319 if (typeof e == 'object') throw e; 319 if (typeof e == 'object') throw e;
320 return e + (yield (4 + (yield 5) + 6)); 320 return e + (yield (4 + (yield 5) + 6));
321 } 321 }
322 }, 322 },
323 [2, NaN, 5, NaN, NaN], 323 [2, NaN, 5, NaN, NaN],
324 "foo", 324 "foo",
325 [2, "1foo3", 5, "4foo6", "foofoo"]); 325 [2, "1foo3", 5, "4foo6", "foofoo"]);
326 326
327 // Generator function instances.
328 TestGenerator(GeneratorFunction(),
329 [undefined],
330 "foo",
331 [undefined]);
332
333 TestGenerator(new GeneratorFunction(),
334 [undefined],
335 "foo",
336 [undefined]);
337
338 TestGenerator(GeneratorFunction('yield 1;'),
339 [1, undefined],
340 "foo",
341 [1, undefined]);
342
343 TestGenerator(
344 function() { return GeneratorFunction('x', 'y', 'yield x + y;')(1, 2) },
345 [3, undefined],
346 "foo",
347 [3, undefined]);
348
327 function TestTryCatch(instantiate) { 349 function TestTryCatch(instantiate) {
328 function* g() { yield 1; try { yield 2; } catch (e) { yield e; } yield 3; } 350 function* g() { yield 1; try { yield 2; } catch (e) { yield e; } yield 3; }
329 function Sentinel() {} 351 function Sentinel() {}
330 352
331 function Test1(iter) { 353 function Test1(iter) {
332 assertIteratorResult(1, false, iter.next()); 354 assertIteratorResult(1, false, iter.next());
333 assertIteratorResult(2, false, iter.next()); 355 assertIteratorResult(2, false, iter.next());
334 assertIteratorResult(3, false, iter.next()); 356 assertIteratorResult(3, false, iter.next());
335 assertIteratorResult(undefined, true, iter.next()); 357 assertIteratorResult(undefined, true, iter.next());
336 assertThrows(function() { iter.next(); }, Error); 358 assertThrows(function() { iter.next(); }, Error);
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 function TestThrowRecursion() { 601 function TestThrowRecursion() {
580 function* g() { yield iter.throw(1); } 602 function* g() { yield iter.throw(1); }
581 var iter = g(); 603 var iter = g();
582 return iter.next(); 604 return iter.next();
583 } 605 }
584 assertThrows(TestNextRecursion, Error); 606 assertThrows(TestNextRecursion, Error);
585 assertThrows(TestSendRecursion, Error); 607 assertThrows(TestSendRecursion, Error);
586 assertThrows(TestThrowRecursion, Error); 608 assertThrows(TestThrowRecursion, Error);
587 } 609 }
588 TestRecursion(); 610 TestRecursion();
OLDNEW
« no previous file with comments | « src/v8natives.js ('k') | test/mjsunit/harmony/generators-runtime.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698