Debian Codegraph @

js/src/tests/test262/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 features: [Symbol.iterator, destructuring-binding]
8 flags: [generated]
9 info: |
10 VariableDeclaration : BindingPattern Initializer
11
12 1. Let rhs be the result of evaluating Initializer.
13 2. Let rval be GetValue(rhs).
14 3. ReturnIfAbrupt(rval).
15 4. Return the result of performing BindingInitialization for
16 BindingPattern passing rval and undefined as arguments.
17
18 ArrayAssignmentPattern :
19 [ AssignmentElementList , Elisionopt AssignmentRestElementopt ]
20
21 [...]
22 6. If Elision is present, then
23 a. Let status be the result of performing
24 IteratorDestructuringAssignmentEvaluation of Elision with
25 iteratorRecord as the argument.
26 b. If status is an abrupt completion, then
27 i. If iteratorRecord.[[done]] is false, return
28 IteratorClose(iterator, status).
29 ii. Return Completion(status).
30
31 ---*/
32 var nextCount = 0;
33 var returnCount = 0;
34 var iterable = {};
35 var x;
36 var iterator = {
37 next: function() {
38 nextCount += 1;
39
40 if (nextCount === 2) {
41 throw new Test262Error();
42 }
43
44 // Set an upper-bound to limit unnecessary iteration in non-conformant
45 // implementations
46 return { done: nextCount > 10 };
47 },
48 return: function() {
49 returnCount += 1;
50 }
51 };
52 iterable[Symbol.iterator] = function() {
53 return iterator;
54 };
55
56
57 assert.throws(Test262Error, function() {
58 0, [ x , , ] = iterable;
59 });
60
61 assert.sameValue(nextCount, 2);
62 assert.sameValue(returnCount, 0);
63
64 reportCompare(0, 0);