array-rest-elision-iter-abpt.js (1656B)
1 // This file was procedurally generated from the following sources: 2 // - src/dstr-assignment/array-rest-elision-iter-abpt.case 3 // - src/dstr-assignment/error/assignment-expr.template 4 /*--- 5 description: IteratorClose is not called when assignment 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 4. If Elision is present, then 22 a. Let status be the result of performing 23 IteratorDestructuringAssignmentEvaluation of Elision with 24 iteratorRecord as the argument. 25 b. If status is an abrupt completion, then 26 i. If iteratorRecord.[[done]] is false, return 27 IteratorClose(iterator, status). 28 ii. Return Completion(status). 29 30 ---*/ 31 var nextCount = 0; 32 var returnCount = 0; 33 var iterable = {}; 34 var iterator = { 35 next: function() { 36 nextCount += 1; 37 throw new Test262Error(); 38 }, 39 return: function() { 40 returnCount += 1; 41 } 42 }; 43 iterable[Symbol.iterator] = function() { 44 return iterator; 45 }; 46 var x; 47 48 assert.throws(Test262Error, function() { 49 0, [ , ...x] = iterable; 50 }); 51 52 assert.sameValue(nextCount, 1); 53 assert.sameValue(returnCount, 0); 54 55 reportCompare(0, 0);