OLD | NEW |
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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 [1, undefined], | 339 [1, undefined], |
340 "foo", | 340 "foo", |
341 [1, undefined]); | 341 [1, undefined]); |
342 | 342 |
343 TestGenerator( | 343 TestGenerator( |
344 function() { return GeneratorFunction('x', 'y', 'yield x + y;')(1, 2) }, | 344 function() { return GeneratorFunction('x', 'y', 'yield x + y;')(1, 2) }, |
345 [3, undefined], | 345 [3, undefined], |
346 "foo", | 346 "foo", |
347 [3, undefined]); | 347 [3, undefined]); |
348 | 348 |
| 349 // Access to this with formal arguments. |
| 350 TestGenerator( |
| 351 function () { |
| 352 return ({ x: 42, g: function* (a) { yield this.x } }).g(0); |
| 353 }, |
| 354 [42, undefined], |
| 355 "foo", |
| 356 [42, undefined]); |
| 357 |
349 // Test that yield* re-yields received results without re-boxing. | 358 // Test that yield* re-yields received results without re-boxing. |
350 function TestDelegatingYield() { | 359 function TestDelegatingYield() { |
351 function results(results) { | 360 function results(results) { |
352 var i = 0; | 361 var i = 0; |
353 function next() { | 362 function next() { |
354 return results[i++]; | 363 return results[i++]; |
355 } | 364 } |
356 return { next: next } | 365 return { next: next } |
357 } | 366 } |
358 function* yield_results(expected) { | 367 function* yield_results(expected) { |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 function TestThrowRecursion() { | 640 function TestThrowRecursion() { |
632 function* g() { yield iter.throw(1); } | 641 function* g() { yield iter.throw(1); } |
633 var iter = g(); | 642 var iter = g(); |
634 return iter.next(); | 643 return iter.next(); |
635 } | 644 } |
636 assertThrows(TestNextRecursion, Error); | 645 assertThrows(TestNextRecursion, Error); |
637 assertThrows(TestSendRecursion, Error); | 646 assertThrows(TestSendRecursion, Error); |
638 assertThrows(TestThrowRecursion, Error); | 647 assertThrows(TestThrowRecursion, Error); |
639 } | 648 } |
640 TestRecursion(); | 649 TestRecursion(); |
OLD | NEW |