var-obj-ptrn-prop-id-init-skipped.js (2084B)
1 // This file was procedurally generated from the following sources: 2 // - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case 3 // - src/dstr-binding/default/for-var.template 4 /*--- 5 description: Destructuring initializer is not evaluated when value is not `undefined` (for statement) 6 esid: sec-for-statement-runtime-semantics-labelledevaluation 7 features: [destructuring-binding] 8 flags: [generated] 9 info: | 10 IterationStatement : 11 for ( var VariableDeclarationList ; Expressionopt ; Expressionopt ) Statement 12 13 1. Let varDcl be the result of evaluating VariableDeclarationList. 14 [...] 15 16 13.3.2.4 Runtime Semantics: Evaluation 17 18 VariableDeclarationList : VariableDeclarationList , VariableDeclaration 19 20 1. Let next be the result of evaluating VariableDeclarationList. 21 2. ReturnIfAbrupt(next). 22 3. Return the result of evaluating VariableDeclaration. 23 24 VariableDeclaration : BindingPattern Initializer 25 26 1. Let rhs be the result of evaluating Initializer. 27 2. Let rval be GetValue(rhs). 28 3. ReturnIfAbrupt(rval). 29 4. Return the result of performing BindingInitialization for BindingPattern 30 passing rval and undefined as arguments. 31 32 13.3.3.7 Runtime Semantics: KeyedBindingInitialization 33 34 BindingElement : BindingPattern Initializeropt 35 36 [...] 37 3. If Initializer is present and v is undefined, then 38 [...] 39 ---*/ 40 var initCount = 0; 41 function counter() { 42 initCount += 1; 43 } 44 45 var iterCount = 0; 46 47 for (var { s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }; iterCount < 1; ) { 48 assert.sameValue(t, null); 49 assert.sameValue(v, 0); 50 assert.sameValue(x, false); 51 assert.sameValue(z, ''); 52 assert.sameValue(initCount, 0); 53 54 assert.throws(ReferenceError, function() { 55 s; 56 }); 57 assert.throws(ReferenceError, function() { 58 u; 59 }); 60 assert.throws(ReferenceError, function() { 61 w; 62 }); 63 assert.throws(ReferenceError, function() { 64 y; 65 }); 66 iterCount += 1; 67 } 68 69 assert.sameValue(iterCount, 1, 'Iteration occurred as expected'); 70 71 reportCompare(0, 0);