Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/assignment/dstr-array-elem-trlg-iter-elision-iter-abpt.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/dstr-assignment/array-elem-trlg-iter-elision-iter-abpt.case
3 // - src/dstr-assignment/error/assignment-expr.template
4 /*---
5 description: Abrupt completion returned during evaluation of elision (AssignmentExpression)
6 esid: sec-variable-statement-runtime-semantics-evaluation
7 es6id: 13.3.2.4
8 features: [Symbol.iterator, destructuring-binding]
9 flags: [generated]
10 info: |
11 VariableDeclaration : BindingPattern Initializer
12
13 1. Let rhs be the result of evaluating Initializer.
14 2. Let rval be GetValue(rhs).
15 3. ReturnIfAbrupt(rval).
16 4. Return the result of performing BindingInitialization for
17 BindingPattern passing rval and undefined as arguments.
18
19 ArrayAssignmentPattern :
20 [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
21
22 [...]
23 6. If Elision is present, then
24 a. Let status be the result of performing
25 IteratorDestructuringAssignmentEvaluation of Elision with
26 iteratorRecord as the argument.
27 b. If status is an abrupt completion, then
28 i. If iteratorRecord.[[done]] is false, return
29 IteratorClose(iterator, status).
30 ii. Return Completion(status).
31
32 ---*/
33 var nextCount = 0;
34 var returnCount = 0;
35 var iterable = {};
36 var x;
37 var iterator = {
38 next: function() {
39 nextCount += 1;
40
41 if (nextCount === 2) {
42 throw new Test262Error();
43 }
44
45 // Set an upper-bound to limit unnecessary iteration in non-conformant
46 // implementations
47 return { done: nextCount > 10 };
48 },
49 return: function() {
50 returnCount += 1;
51 }
52 };
53 iterable[Symbol.iterator] = function() {
54 return iterator;
55 };
56
57
58 assert.throws(Test262Error, function() {
59 0, [ x , , ] = iterable;
60 });
61
62 assert.sameValue(nextCount, 2);
63 assert.sameValue(returnCount, 0);