Debian Codegraph @

js/src/tests/test262/language/statements/for/dstr/var-ary-ptrn-rest-ary-rest.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/dstr-binding/ary-ptrn-rest-ary-rest.case
3 // - src/dstr-binding/default/for-var.template
4 /*---
5 description: Rest element containing a rest element (for statement)
6 esid: sec-for-statement-runtime-semantics-labelledevaluation
7 features: [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 var values = [1, 2, 3];
46
47 var iterCount = 0;
48
49 for (var [...[...x]] = values; iterCount < 1; ) {
50 assert(Array.isArray(x));
51 assert.sameValue(x.length, 3);
52 assert.sameValue(x[0], 1);
53 assert.sameValue(x[1], 2);
54 assert.sameValue(x[2], 3);
55 assert.notSameValue(x, values);
56
57 iterCount += 1;
58 }
59
60 assert.sameValue(iterCount, 1, 'Iteration occurred as expected');
61
62 reportCompare(0, 0);