if-stmt-else-decl-global-existing-global-init.js (1750B)
1 // This file was procedurally generated from the following sources: 2 // - src/annex-b-fns/global-existing-global-init.case 3 // - src/annex-b-fns/global/if-stmt-else-decl.template 4 /*--- 5 description: Variable binding is left in place by legacy function hoisting. CreateGlobalVariableBinding leaves the binding as non-enumerable even if it has the chance to change it to be enumerable. (IfStatement with a declaration in the second statement position in the global scope) 6 esid: sec-functiondeclarations-in-ifstatement-statement-clauses 7 flags: [generated, noStrict] 8 includes: [fnGlobalObject.js, propertyHelper.js] 9 info: | 10 The following rules for IfStatement augment those in 13.6: 11 12 IfStatement[Yield, Return]: 13 if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] 14 if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] 15 if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] 16 if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] 17 18 19 B.3.3.3 Changes to GlobalDeclarationInstantiation 20 21 [...] 22 Perform ? varEnvRec.CreateGlobalVarBinding(F, true). 23 [...] 24 25 ---*/ 26 var global = fnGlobalObject(); 27 Object.defineProperty(global, 'f', { 28 value: 'x', 29 enumerable: true, 30 writable: true, 31 configurable: false 32 }); 33 34 $262.evalScript(` 35 assert.sameValue(f, 'x'); 36 verifyProperty(global, 'f', { 37 enumerable: true, 38 writable: true, 39 configurable: false 40 }, { restore: true }); 41 `); 42 43 $262.evalScript(` 44 45 if (false) ; else function f() { return 'inner declaration'; } 46 47 `); 48 49 $262.evalScript(` 50 verifyProperty(global, 'f', { 51 enumerable: true, 52 writable: true, 53 configurable: false 54 }); 55 `); 56 57 reportCompare(0, 0);