Debian Codegraph @

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

raw
1 // This file was procedurally generated from the following sources:
2 // - src/dstr-assignment/array-elem-trlg-iter-elision-iter-nrml-close-err.case
3 // - src/dstr-assignment/error/assignment-expr.template
4 /*---
5 description: Abrupt completion returned from IteratorClose (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 [...]
29 8. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
30 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 // Set an upper-bound to limit unnecessary iteration in non-conformant
42 // implementations
43 return { done: nextCount > 10 };
44 },
45 return: function() {
46 returnCount += 1;
47 throw new Test262Error();
48 }
49 };
50 iterable[Symbol.iterator] = function() {
51 return iterator;
52 };
53
54 assert.throws(Test262Error, function() {
55 0, [ x , , ] = iterable;
56 });
57
58 assert.sameValue(nextCount, 2);
59 assert.sameValue(returnCount, 1);