array-rest-nested-array-iter-thrw-close-skip.js (1966B)
1 // This file was procedurally generated from the following sources: 2 // - src/dstr-assignment/array-rest-nested-array-iter-thrw-close-skip.case 3 // - src/dstr-assignment/error/assignment-expr.template 4 /*--- 5 description: IteratorClose is not called when nested array pattern 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 [...] 30 4. Repeat while iteratorRecord.[[done]] is false 31 [...] 32 d. If next is false, set iteratorRecord.[[done]] to true. 33 [...] 34 7. Return the result of performing DestructuringAssignmentEvaluation of 35 nestedAssignmentPattern with A as the argument. 36 37 ---*/ 38 var nextCount = 0; 39 var returnCount = 0; 40 var iterable = {}; 41 var iterator = { 42 next: function() { 43 nextCount += 1; 44 return { done: true }; 45 }, 46 return: function() { 47 returnCount += 1; 48 } 49 }; 50 var thrower = function() { 51 throw new Test262Error(); 52 }; 53 iterable[Symbol.iterator] = function() { 54 return iterator; 55 }; 56 57 assert.throws(Test262Error, function() { 58 0, [...[...{}[thrower()]]] = iterable; 59 }); 60 61 assert.sameValue(nextCount, 1); 62 assert.sameValue(returnCount, 0); 63 64 reportCompare(0, 0);