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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 94 |
95 testNext(g); | 95 testNext(g); |
96 testSend(g); | 96 testSend(g); |
97 testThrow(g); | 97 testThrow(g); |
98 | 98 |
99 testNext(function*() { return yield* g(); }); | 99 testNext(function*() { return yield* g(); }); |
100 testSend(function*() { return yield* g(); }); | 100 testSend(function*() { return yield* g(); }); |
101 testThrow(function*() { return yield* g(); }); | 101 testThrow(function*() { return yield* g(); }); |
102 | 102 |
103 if (g instanceof GeneratorFunction) { | 103 if (g instanceof GeneratorFunction) { |
104 testNext(function() { return new g(); }); | 104 testNext(g); |
105 testSend(function() { return new g(); }); | 105 testSend(g); |
106 testThrow(function() { return new g(); }); | 106 testThrow(g); |
107 } | 107 } |
108 } | 108 } |
109 | 109 |
110 TestGenerator(function* g1() { }, | 110 TestGenerator(function* g1() { }, |
111 [undefined], | 111 [undefined], |
112 "foo", | 112 "foo", |
113 [undefined]); | 113 [undefined]); |
114 | 114 |
115 TestGenerator(function* g2() { yield 1; }, | 115 TestGenerator(function* g2() { yield 1; }, |
116 [1, undefined], | 116 [1, undefined], |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 function g17() { | 252 function g17() { |
253 function* g() { yield this.x; yield this.y; } | 253 function* g() { yield this.x; yield this.y; } |
254 var o = { start: g, x: 1, y: 2 }; | 254 var o = { start: g, x: 1, y: 2 }; |
255 return o.start(); | 255 return o.start(); |
256 }, | 256 }, |
257 [1, 2, undefined], | 257 [1, 2, undefined], |
258 "foo", | 258 "foo", |
259 [1, 2, undefined]); | 259 [1, 2, undefined]); |
260 | 260 |
261 TestGenerator( | 261 TestGenerator( |
262 function g18() { | |
263 function* g() { yield this.x; yield this.y; } | |
264 var iter = new g; | |
265 iter.x = 1; | |
266 iter.y = 2; | |
267 return iter; | |
268 }, | |
269 [1, 2, undefined], | |
270 "foo", | |
271 [1, 2, undefined]); | |
272 | |
273 TestGenerator( | |
274 function* g19() { | 262 function* g19() { |
275 var x = 1; | 263 var x = 1; |
276 yield x; | 264 yield x; |
277 with({x:2}) { yield x; } | 265 with({x:2}) { yield x; } |
278 yield x; | 266 yield x; |
279 }, | 267 }, |
280 [1, 2, 1, undefined], | 268 [1, 2, 1, undefined], |
281 "foo", | 269 "foo", |
282 [1, 2, 1, undefined]); | 270 [1, 2, 1, undefined]); |
283 | 271 |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 function TestThrowRecursion() { | 674 function TestThrowRecursion() { |
687 function* g() { yield iter.throw(1); } | 675 function* g() { yield iter.throw(1); } |
688 var iter = g(); | 676 var iter = g(); |
689 return iter.next(); | 677 return iter.next(); |
690 } | 678 } |
691 assertThrows(TestNextRecursion, Error); | 679 assertThrows(TestNextRecursion, Error); |
692 assertThrows(TestSendRecursion, Error); | 680 assertThrows(TestSendRecursion, Error); |
693 assertThrows(TestThrowRecursion, Error); | 681 assertThrows(TestThrowRecursion, Error); |
694 } | 682 } |
695 TestRecursion(); | 683 TestRecursion(); |
OLD | NEW |