| 1 |
// This file was procedurally generated from the following sources: |
| 2 |
// - src/dstr-assignment/obj-rest-computed-property.case |
| 3 |
// - src/dstr-assignment/default/assignment-expr.template |
| 4 |
/*--- |
| 5 |
description: Destructuring field can be a computed property, i.e it can be defined only at runtime. Rest operantion needs to skip these properties as well. (AssignmentExpression) |
| 6 |
esid: sec-variable-statement-runtime-semantics-evaluation |
| 7 |
es6id: 13.3.2.4 |
| 8 |
features: [object-rest, destructuring-binding] |
| 9 |
flags: [generated] |
| 10 |
includes: [propertyHelper.js] |
| 11 |
info: | |
| 12 |
VariableDeclaration : BindingPattern Initializer |
| 13 |
|
| 14 |
1. Let rhs be the result of evaluating Initializer. |
| 15 |
2. Let rval be GetValue(rhs). |
| 16 |
3. ReturnIfAbrupt(rval). |
| 17 |
4. Return the result of performing BindingInitialization for |
| 18 |
BindingPattern passing rval and undefined as arguments. |
| 19 |
---*/ |
| 20 |
var a = "foo"; |
| 21 |
var b, rest; |
| 22 |
|
| 23 |
var result; |
| 24 |
var vals = { foo: 1, bar: 2, baz: 3 }; |
| 25 |
|
| 26 |
result = {[a]:b, ...rest} = vals; |
| 27 |
|
| 28 |
assert.sameValue(b, 1); |
| 29 |
assert.sameValue(rest.bar, 2); |
| 30 |
assert.sameValue(rest.baz, 3); |
| 31 |
|
| 32 |
assert.sameValue(Object.getOwnPropertyDescriptor(rest, "foo"), undefined); |
| 33 |
|
| 34 |
verifyProperty(rest, "bar", { |
| 35 |
enumerable: true, |
| 36 |
writable: true, |
| 37 |
configurable: true |
| 38 |
}); |
| 39 |
|
| 40 |
verifyProperty(rest, "baz", { |
| 41 |
enumerable: true, |
| 42 |
writable: true, |
| 43 |
configurable: true |
| 44 |
}); |
| 45 |
|
| 46 |
|
| 47 |
assert.sameValue(result, vals); |