Debian Codegraph @

js/src/tests/test262/language/expressions/assignment/dstr/array-rest-put-prop-ref-user-err-iter-close-skip.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/dstr-assignment/array-rest-put-prop-ref-user-err-iter-close-skip.case
3 // - src/dstr-assignment/error/assignment-expr.template
4 /*---
5 description: IteratorClose is not called when value assignment 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 [...]
30 4. Repeat while iteratorRecord.[[done]] is false
31 [...]
32 d. If next is false, set iteratorRecord.[[done]] to true.
33 [...]
34 5. If DestructuringAssignmentTarget is neither an ObjectLiteral nor an
35 ArrayLiteral, then
36 a. Return PutValue(lref, A).
37
38 ---*/
39 var nextCount = 0;
40 var returnCount = 0;
41 var iterable = {};
42 var iterator = {
43 next: function() {
44 nextCount += 1;
45 return { done: true };
46 },
47 return: function() {
48 returnCount += 1;
49 }
50 };
51 var obj = Object.defineProperty({}, 'poisoned', {
52 set: function(x) {
53 throw new Test262Error();
54 }
55 });
56 iterable[Symbol.iterator] = function() {
57 return iterator;
58 };
59
60 assert.throws(Test262Error, function() {
61 0, [...obj.poisoned] = iterable;
62 });
63
64 assert.sameValue(nextCount, 1);
65 assert.sameValue(returnCount, 0);
66
67 reportCompare(0, 0);