array-rest-iter-thrw-close.js (2349B)
1 // This file was procedurally generated from the following sources: 2 // - src/dstr-assignment/array-rest-iter-thrw-close.case 3 // - src/dstr-assignment/error/assignment-expr.template 4 /*--- 5 description: IteratorClose is called when reference evaluation produces a "throw" 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 7.4.6 IteratorClose( iterator, completion ) 35 36 [...] 37 6. Let innerResult be Call(return, iterator, « »). 38 [...] 39 40 ---*/ 41 var nextCount = 0; 42 var returnCount = 0; 43 var thisValue = null; 44 var args = null; 45 var x; 46 var iterable = {}; 47 var iterator = { 48 next: function() { 49 nextCount += 1; 50 // Set an upper-bound to limit unnecessary iteration in non-conformant 51 // implementations 52 return { done: nextCount > 10 }; 53 }, 54 return: function() { 55 returnCount += 1; 56 thisValue = this; 57 args = arguments; 58 } 59 }; 60 var thrower = function() { 61 throw new Test262Error(); 62 }; 63 iterable[Symbol.iterator] = function() { 64 return iterator; 65 }; 66 67 assert.throws(Test262Error, function() { 68 0, [...{}[thrower()]] = iterable; 69 }); 70 71 assert.sameValue(nextCount, 0); 72 assert.sameValue(returnCount, 1); 73 assert.sameValue(thisValue, iterator, 'correct `this` value'); 74 assert(!!args, 'arguments object provided'); 75 assert.sameValue(args.length, 0, 'zero arguments specified'); 76 77 reportCompare(0, 0);