| 1 |
// Copyright (C) 2015 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
/*--- |
| 4 |
es6id: 13.6.4.13 |
| 5 |
description: > |
| 6 |
Control flow during body evaluation should honor `yield *` statements |
| 7 |
within the `finally` block of `try` statements. |
| 8 |
features: [generators] |
| 9 |
---*/ |
| 10 |
|
| 11 |
function* values() { |
| 12 |
yield 1; |
| 13 |
yield 1; |
| 14 |
} |
| 15 |
var dataIterator = values(); |
| 16 |
var controlIterator = (function*() { |
| 17 |
for (var x of dataIterator) { |
| 18 |
try { |
| 19 |
} finally { |
| 20 |
i++; |
| 21 |
yield * values(); |
| 22 |
j++; |
| 23 |
} |
| 24 |
k++; |
| 25 |
} |
| 26 |
|
| 27 |
l++; |
| 28 |
})(); |
| 29 |
var i = 0; |
| 30 |
var j = 0; |
| 31 |
var k = 0; |
| 32 |
var l = 0; |
| 33 |
|
| 34 |
controlIterator.next(); |
| 35 |
assert.sameValue(i, 1, 'First iteration: pre-yield'); |
| 36 |
assert.sameValue(j, 0, 'First iteration: post-yield'); |
| 37 |
assert.sameValue(k, 0, 'First iteration: post-try'); |
| 38 |
assert.sameValue(l, 0, 'First iteration: post-for-of'); |
| 39 |
|
| 40 |
controlIterator.next(); |
| 41 |
assert.sameValue(i, 1, 'Second iteration: pre-yield'); |
| 42 |
assert.sameValue(j, 0, 'Second iteration: post-yield'); |
| 43 |
assert.sameValue(k, 0, 'Second iteration: post-try'); |
| 44 |
assert.sameValue(l, 0, 'Second iteration: post-for-of'); |
| 45 |
|
| 46 |
controlIterator.next(); |
| 47 |
assert.sameValue(i, 2, 'Third iteration: pre-yield'); |
| 48 |
assert.sameValue(j, 1, 'Third iteration: post-yield'); |
| 49 |
assert.sameValue(k, 1, 'Third iteration: post-try'); |
| 50 |
assert.sameValue(l, 0, 'Third iteration: post-for-of'); |
| 51 |
|
| 52 |
controlIterator.next(); |
| 53 |
assert.sameValue(i, 2, 'Fourth iteration: pre-yield'); |
| 54 |
assert.sameValue(j, 1, 'Fourth iteration: post-yield'); |
| 55 |
assert.sameValue(k, 1, 'Fourth iteration: post-try'); |
| 56 |
assert.sameValue(l, 0, 'Fourth iteration: post-for-of'); |
| 57 |
|
| 58 |
controlIterator.next(); |
| 59 |
assert.sameValue(i, 2, 'Fifth iteration: pre-yield'); |
| 60 |
assert.sameValue(j, 2, 'Fifth iteration: post-yield'); |
| 61 |
assert.sameValue(k, 2, 'Fifth iteration: post-try'); |
| 62 |
assert.sameValue(l, 1, 'Fifth iteration: post-for-of'); |
| 63 |
|
| 64 |
reportCompare(0, 0); |