| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Flags: --harmony-iterator-close | 5 // Flags: --harmony-iterator-close |
| 6 | 6 |
| 7 function* g() { yield 42; return 88 }; | 7 function* g() { yield 42; return 88 }; |
| 8 | 8 |
| 9 | 9 |
| 10 // Return method is "undefined". | 10 // Return method is "undefined". |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 })()); | 148 })()); |
| 149 assertEquals([[]], log); | 149 assertEquals([[]], log); |
| 150 | 150 |
| 151 log = []; | 151 log = []; |
| 152 assertEquals(42, eval('for (let x of g()) { x; }')); | 152 assertEquals(42, eval('for (let x of g()) { x; }')); |
| 153 assertEquals([], log); | 153 assertEquals([], log); |
| 154 | 154 |
| 155 log = []; | 155 log = []; |
| 156 assertEquals(42, eval('for (x of g()) { x; }')); | 156 assertEquals(42, eval('for (x of g()) { x; }')); |
| 157 assertEquals([], log); | 157 assertEquals([], log); |
| 158 |
| 159 // Even if doing the assignment throws, still call return |
| 160 x = { set attr(_) { throw 1234; } }; |
| 161 assertThrowsEquals(() => { |
| 162 for (x.attr of g()) { throw 456; } |
| 163 }, 1234); |
| 164 assertEquals([[]], log); |
| 158 } | 165 } |
| 159 | 166 |
| 160 | 167 |
| 161 // Return method throws. | 168 // Return method throws. |
| 162 { | 169 { |
| 163 let log = []; | 170 let log = []; |
| 164 g.prototype.return = (...args) => { log.push(args); throw 23 }; | 171 g.prototype.return = (...args) => { log.push(args); throw 23 }; |
| 165 | 172 |
| 166 log = []; | 173 log = []; |
| 167 assertThrowsEquals(() => { | 174 assertThrowsEquals(() => { |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 for (let x of g1()) { | 364 for (let x of g1()) { |
| 358 try { | 365 try { |
| 359 for (let y of g2()) { | 366 for (let y of g2()) { |
| 360 } | 367 } |
| 361 } catch (_) {} | 368 } catch (_) {} |
| 362 if (x == 2) break; | 369 if (x == 2) break; |
| 363 } | 370 } |
| 364 }, 5); | 371 }, 5); |
| 365 assertEquals([1], log); | 372 assertEquals([1], log); |
| 366 } | 373 } |
| OLD | NEW |