instn-local-bndng-fun.js (1728B)
1 // |reftest| module 2 // Copyright (C) 2016 the V8 project authors. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 /*--- 5 description: > 6 Mutable bindings are initialized in the lexical environment record prior to 7 execution for function declarations 8 esid: sec-moduledeclarationinstantiation 9 info: | 10 [...] 11 17. For each element d in lexDeclarations do 12 a. For each element dn of the BoundNames of d do 13 i. If IsConstantDeclaration of d is true, then 14 [...] 15 ii. Else, 16 1. Perform ! envRec.CreateMutableBinding(dn, false). 17 iii. If d is a GeneratorDeclaration production or a 18 FunctionDeclaration production, then 19 1. Let fo be the result of performing InstantiateFunctionObject 20 for d with argument env. 21 2. Call envRec.InitializeBinding(dn, fo). 22 [...] 23 includes: [fnGlobalObject.js] 24 flags: [module] 25 ---*/ 26 27 var global = fnGlobalObject(); 28 29 assert.sameValue(typeof test262, 'function', 'function value is hoisted'); 30 assert.sameValue(test262(), 'test262', 'hoisted function value is correct'); 31 assert.sameValue( 32 Object.getOwnPropertyDescriptor(global, 'test262'), undefined 33 ); 34 35 test262 = null; 36 assert.sameValue(test262, null, 'binding is mutable'); 37 assert.sameValue( 38 Object.getOwnPropertyDescriptor(global, 'test262'), undefined 39 ); 40 41 function test262() { return 'test262'; } 42 43 assert.sameValue( 44 test262, null, 'binding is not effected by evaluation of declaration' 45 ); 46 assert.sameValue( 47 Object.getOwnPropertyDescriptor(global, 'test262'), 48 undefined, 49 'global binding is not effected by evaluation of declaration' 50 ); 51 52 reportCompare(0, 0);