array-rest-lref.js (1849B)
1 // This file was procedurally generated from the following sources: 2 // - src/dstr-assignment/array-rest-lref.case 3 // - src/dstr-assignment/default/assignment-expr.template 4 /*--- 5 description: Reference is evaluated during assignment (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 ---*/ 36 var nextCount = 0; 37 var returnCount = 0; 38 var iterable = {}; 39 var iterator = { 40 next: function() { 41 nextCount += 1; 42 return { done: true }; 43 }, 44 return: function() { 45 returnCount += 1; 46 } 47 }; 48 var obj = {}; 49 iterable[Symbol.iterator] = function() { 50 return iterator; 51 }; 52 53 var result; 54 var vals = iterable; 55 56 result = [...obj['a' + 'b']] = vals; 57 58 assert.sameValue(nextCount, 1); 59 assert.sameValue(returnCount, 0); 60 assert(!!obj.ab); 61 assert.sameValue(obj.ab.length, 0); 62 63 assert.sameValue(result, vals); 64 65 reportCompare(0, 0);