tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

decl-lex.js (1476B)


      1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 esid: sec-globaldeclarationinstantiation
      5 es6id: 15.1.8
      6 description: Declaration of lexical bindings
      7 info: |
      8  [...]
      9  16. For each element d in lexDeclarations do
     10      a. NOTE Lexically declared names are only instantiated here but not
     11         initialized.
     12      b. 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         ii. Else,
     16             1. Perform ? envRec.CreateMutableBinding(dn, false).
     17  [...]
     18 ---*/
     19 
     20 let test262let = 1;
     21 
     22 test262let = 2;
     23 
     24 assert.sameValue(test262let, 2, '`let` binding is mutable');
     25 assert.sameValue(
     26  this.hasOwnProperty('test262let'),
     27  false,
     28  'property not created on the global object (let)'
     29 );
     30 
     31 const test262const = 3;
     32 
     33 assert.throws(TypeError, function() {
     34  test262const = 4;
     35 }, '`const` binding is strictly immutable');
     36 assert.sameValue(test262const, 3, '`const` binding cannot be modified');
     37 assert.sameValue(
     38  this.hasOwnProperty('test262const'),
     39  false,
     40  'property not created on the global object (const)'
     41 );
     42 
     43 class test262class {}
     44 
     45 test262class = 5;
     46 
     47 assert.sameValue(test262class, 5, '`class` binding is mutable');
     48 assert.sameValue(
     49  this.hasOwnProperty('test262class'),
     50  false,
     51  'property not created on the global object (class)'
     52 );
     53 
     54 reportCompare(0, 0);