instn-local-bndng-const.js (1297B)
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 created in the lexical environment record prior to 7 execution for `const` 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 1. Perform ! envRec.CreateImmutableBinding(dn, true). 15 [...] 16 includes: [fnGlobalObject.js] 17 flags: [module] 18 ---*/ 19 20 var global = fnGlobalObject(); 21 22 assert.throws(ReferenceError, function() { 23 typeof test262; 24 }, 'Binding is created but not initialized.'); 25 assert.sameValue( 26 Object.getOwnPropertyDescriptor(global, 'test262'), undefined 27 ); 28 29 const test262 = 23; 30 31 assert.sameValue(test262, 23); 32 assert.sameValue( 33 Object.getOwnPropertyDescriptor(global, 'test262'), undefined 34 ); 35 36 assert.throws(TypeError, function() { 37 test262 = null; 38 }); 39 40 assert.sameValue(test262, 23, 'binding is not mutable'); 41 assert.sameValue( 42 Object.getOwnPropertyDescriptor(global, 'test262'), 43 undefined, 44 'global binding is not effected by attempts to modify' 45 ); 46 47 reportCompare(0, 0);