tor-browser

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

script-decl-lex-lex.js (1281B)


      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: Let binding collision with existing lexical declaration
      7 info: |
      8  [...]
      9  5. For each name in lexNames, do
     10     a. If envRec.HasVarDeclaration(name) is true, throw a SyntaxError
     11        exception.
     12     b. If envRec.HasLexicalDeclaration(name) is true, throw a SyntaxError
     13        exception.
     14 ---*/
     15 
     16 let test262Let;
     17 const test262Const = null;
     18 class test262Class {}
     19 
     20 assert.throws(SyntaxError, function() {
     21  $262.evalScript('var x; let test262Let;');
     22 }, '`let` binding');
     23 assert.throws(ReferenceError, function() {
     24  x;
     25 }, 'No bindings created for script containing `let` redeclaration');
     26 
     27 assert.throws(SyntaxError, function() {
     28  $262.evalScript('var x; let test262Const;');
     29 }, '`const` binding');
     30 assert.throws(ReferenceError, function() {
     31  x;
     32 }, 'No bindings created for script containing `const` redeclaration');
     33 
     34 assert.throws(SyntaxError, function() {
     35  $262.evalScript('var x; let test262Class;');
     36 }, '`class` binding');
     37 assert.throws(ReferenceError, function() {
     38  x;
     39 }, 'No bindings created for script containing `class` redeclaration');
     40 
     41 reportCompare(0, 0);