obj-rest-same-name.js (1173B)
1 // This file was procedurally generated from the following sources: 2 // - src/dstr-assignment/obj-rest-same-name.case 3 // - src/dstr-assignment/default/assignment-expr.template 4 /*--- 5 description: Proper setting in the values for rest name equal to a property name. (AssignmentExpression) 6 esid: sec-variable-statement-runtime-semantics-evaluation 7 features: [object-rest, 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 var o = { 19 x: 42, 20 y: 39, 21 z: 'cheeseburger' 22 }; 23 24 var x, y, z; 25 26 var result; 27 var vals = o; 28 29 result = { x, ...z } = vals; 30 31 assert.sameValue(x, 42); 32 assert.sameValue(y, undefined); 33 assert.sameValue(z.y, 39); 34 assert.sameValue(z.z, 'cheeseburger'); 35 36 var keys = Object.getOwnPropertyNames(z); 37 assert.sameValue(keys.length, 2); 38 assert.sameValue(keys[0], 'y'); 39 assert.sameValue(keys[1], 'z'); 40 41 assert.sameValue(result, vals); 42 43 reportCompare(0, 0);