| 1 |
// This file was procedurally generated from the following sources: |
| 2 |
// - src/dstr-binding/ary-init-iter-no-close.case |
| 3 |
// - src/dstr-binding/default/for-var.template |
| 4 |
/*--- |
| 5 |
description: Iterator is not closed when exhausted by pattern evaluation (for statement) |
| 6 |
esid: sec-for-statement-runtime-semantics-labelledevaluation |
| 7 |
features: [Symbol.iterator, destructuring-binding] |
| 8 |
flags: [generated] |
| 9 |
info: | |
| 10 |
IterationStatement : |
| 11 |
for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement |
| 12 |
|
| 13 |
1. Let varDcl be the result of evaluating VariableDeclarationList. |
| 14 |
[...] |
| 15 |
|
| 16 |
13.3.2.4 Runtime Semantics: Evaluation |
| 17 |
|
| 18 |
VariableDeclarationList : VariableDeclarationList , VariableDeclaration |
| 19 |
|
| 20 |
1. Let next be the result of evaluating VariableDeclarationList. |
| 21 |
2. ReturnIfAbrupt(next). |
| 22 |
3. Return the result of evaluating VariableDeclaration. |
| 23 |
|
| 24 |
VariableDeclaration : BindingPattern Initializer |
| 25 |
|
| 26 |
1. Let rhs be the result of evaluating Initializer. |
| 27 |
2. Let rval be GetValue(rhs). |
| 28 |
3. ReturnIfAbrupt(rval). |
| 29 |
4. Return the result of performing BindingInitialization for BindingPattern |
| 30 |
passing rval and undefined as arguments. |
| 31 |
|
| 32 |
13.3.3.5 Runtime Semantics: BindingInitialization |
| 33 |
|
| 34 |
BindingPattern : ArrayBindingPattern |
| 35 |
|
| 36 |
[...] |
| 37 |
4. If iteratorRecord.[[done]] is false, return ? IteratorClose(iterator, |
| 38 |
result). |
| 39 |
[...] |
| 40 |
|
| 41 |
---*/ |
| 42 |
var doneCallCount = 0; |
| 43 |
var iter = {}; |
| 44 |
iter[Symbol.iterator] = function() { |
| 45 |
return { |
| 46 |
next: function() { |
| 47 |
return { value: null, done: true }; |
| 48 |
}, |
| 49 |
return: function() { |
| 50 |
doneCallCount += 1; |
| 51 |
return {}; |
| 52 |
} |
| 53 |
}; |
| 54 |
}; |
| 55 |
|
| 56 |
var iterCount = 0; |
| 57 |
|
| 58 |
for (var [x] = iter; iterCount < 1; ) { |
| 59 |
assert.sameValue(doneCallCount, 0); |
| 60 |
iterCount += 1; |
| 61 |
} |
| 62 |
|
| 63 |
assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); |
| 64 |
|
| 65 |
reportCompare(0, 0); |