| 1 |
// This file was procedurally generated from the following sources: |
| 2 |
// - src/dstr-binding/ary-ptrn-rest-ary-elision.case |
| 3 |
// - src/dstr-binding/default/for-var.template |
| 4 |
/*--- |
| 5 |
description: Rest element containing an elision (for statement) |
| 6 |
esid: sec-for-statement-runtime-semantics-labelledevaluation |
| 7 |
features: [generators, 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.6 Runtime Semantics: IteratorBindingInitialization |
| 33 |
|
| 34 |
BindingRestElement : ... BindingPattern |
| 35 |
|
| 36 |
1. Let A be ArrayCreate(0). |
| 37 |
[...] |
| 38 |
3. Repeat |
| 39 |
[...] |
| 40 |
b. If iteratorRecord.[[done]] is true, then |
| 41 |
i. Return the result of performing BindingInitialization of |
| 42 |
BindingPattern with A and environment as the arguments. |
| 43 |
[...] |
| 44 |
|
| 45 |
13.3.3.6 Runtime Semantics: IteratorBindingInitialization |
| 46 |
|
| 47 |
ArrayBindingPattern : [ Elision ] |
| 48 |
|
| 49 |
1. Return the result of performing |
| 50 |
IteratorDestructuringAssignmentEvaluation of Elision with iteratorRecord |
| 51 |
as the argument. |
| 52 |
|
| 53 |
12.14.5.3 Runtime Semantics: IteratorDestructuringAssignmentEvaluation |
| 54 |
|
| 55 |
Elision : , |
| 56 |
|
| 57 |
1. If iteratorRecord.[[done]] is false, then |
| 58 |
a. Let next be IteratorStep(iteratorRecord.[[iterator]]). |
| 59 |
b. If next is an abrupt completion, set iteratorRecord.[[done]] to true. |
| 60 |
c. ReturnIfAbrupt(next). |
| 61 |
d. If next is false, set iteratorRecord.[[done]] to true. |
| 62 |
2. Return NormalCompletion(empty). |
| 63 |
|
| 64 |
---*/ |
| 65 |
var first = 0; |
| 66 |
var second = 0; |
| 67 |
function* g() { |
| 68 |
first += 1; |
| 69 |
yield; |
| 70 |
second += 1; |
| 71 |
}; |
| 72 |
|
| 73 |
var iterCount = 0; |
| 74 |
|
| 75 |
for (var [...[,]] = g(); iterCount < 1; ) { |
| 76 |
assert.sameValue(first, 1); |
| 77 |
assert.sameValue(second, 1); |
| 78 |
iterCount += 1; |
| 79 |
} |
| 80 |
|
| 81 |
assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); |
| 82 |
|
| 83 |
reportCompare(0, 0); |