keith_miller@apple.com | bcc77f2 | 2016-07-15 06:03:25 +0000 | [diff] [blame] | 1 | // This file was procedurally generated from the following sources: |
| 2 | // - src/dstr-binding/obj-ptrn-id-init-skipped.case |
| 3 | // - src/dstr-binding/default/const-stmt.template |
| 4 | /*--- |
| 5 | description: Destructuring initializer is not evaluated when value is not `undefined` (`const` statement) |
| 6 | esid: sec-let-and-const-declarations-runtime-semantics-evaluation |
| 7 | es6id: 13.3.1.4 |
| 8 | features: [destructuring-binding] |
| 9 | flags: [generated] |
| 10 | info: | |
| 11 | LexicalBinding : BindingPattern Initializer |
| 12 | |
| 13 | 1. Let rhs be the result of evaluating Initializer. |
| 14 | 2. Let value be GetValue(rhs). |
| 15 | 3. ReturnIfAbrupt(value). |
| 16 | 4. Let env be the running execution context's LexicalEnvironment. |
| 17 | 5. Return the result of performing BindingInitialization for BindingPattern |
| 18 | using value and env as the arguments. |
| 19 | |
| 20 | 13.3.3.7 Runtime Semantics: KeyedBindingInitialization |
| 21 | |
| 22 | SingleNameBinding : BindingIdentifier Initializeropt |
| 23 | |
| 24 | [...] |
| 25 | 6. If Initializer is present and v is undefined, then |
| 26 | [...] |
| 27 | [...] |
| 28 | ---*/ |
| 29 | var initCount = 0; |
| 30 | function counter() { |
| 31 | initCount += 1; |
| 32 | } |
| 33 | |
| 34 | const { w = counter(), x = counter(), y = counter(), z = counter() } = { w: null, x: 0, y: false, z: '' }; |
| 35 | |
| 36 | assert.sameValue(w, null); |
| 37 | assert.sameValue(x, 0); |
| 38 | assert.sameValue(y, false); |
| 39 | assert.sameValue(z, ''); |
| 40 | assert.sameValue(initCount, 0); |