if-decl-else-decl-a-global-existing-non-enumerable-global-init.js (1820B)
1 // This file was procedurally generated from the following sources: 2 // - src/annex-b-fns/global-existing-non-enumerable-global-init.case 3 // - src/annex-b-fns/global/if-decl-else-decl-a.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 both statement positions 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: false, 30 writable: true, 31 configurable: true 32 }); 33 34 $262.evalScript(` 35 assert.sameValue(f, 'x'); 36 verifyProperty(global, 'f', { 37 enumerable: false, 38 writable: true, 39 configurable: true 40 }, { restore: true }); 41 `); 42 43 $262.evalScript(` 44 45 if (true) function f() { return 'inner declaration'; } else function _f() {} 46 47 `); 48 49 $262.evalScript(` 50 assert.sameValue(f(), 'inner declaration'); 51 verifyProperty(global, 'f', { 52 enumerable: false, 53 writable: true, 54 configurable: true 55 }); 56 `); 57 58 reportCompare(0, 0);