Debian Codegraph @

js/src/tests/test262/language/expressions/assignment/dstr/array-rest-lref-err.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/dstr-assignment/array-rest-lref-err.case
3 // - src/dstr-assignment/error/assignment-expr.template
4 /*---
5 description: IteratorClose is called when reference evaluation produces an abrupt completion (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 : [ Elisionopt AssignmentRestElement ]
19
20 [...]
21 5. Let result be the result of performing
22 IteratorDestructuringAssignmentEvaluation of AssignmentRestElement with
23 iteratorRecord as the argument
24 6. If iteratorRecord.[[done]] is false, return IteratorClose(iterator,
25 result).
26
27 AssignmentRestElement[Yield] : ... DestructuringAssignmentTarget
28
29 1. If DestructuringAssignmentTarget is neither an ObjectLiteral nor an
30 ArrayLiteral, then
31 a. Let lref be the result of evaluating DestructuringAssignmentTarget.
32 b. ReturnIfAbrupt(lref).
33
34 ---*/
35 var nextCount = 0;
36 var returnCount = 0;
37 var iterable = {};
38 var iterator = {
39 next: function() {
40 nextCount += 1;
41 return { done: true };
42 },
43 return: function() {
44 returnCount += 1;
45 }
46 };
47 var thrower = function() {
48 throw new Test262Error();
49 };
50 iterable[Symbol.iterator] = function() {
51 return iterator;
52 };
53
54 assert.throws(Test262Error, function() {
55 0, [...{}[thrower()]] = iterable;
56 });
57
58 assert.sameValue(nextCount, 0);
59 assert.sameValue(returnCount, 1);
60
61 reportCompare(0, 0);