Debian Codegraph @

js/src/tests/test262/language/global-code/script-decl-lex-var.js

raw
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 var 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 ---*/
13
14 var test262Var;
15 function test262Fn() {}
16
17 assert.throws(SyntaxError, function() {
18 $262.evalScript('var x; let test262Var;');
19 }, 'variable');
20
21 assert.throws(ReferenceError, function() {
22 x;
23 }, 'no bindings created (script shadowing variable)');
24
25 assert.throws(SyntaxError, function() {
26 $262.evalScript('var x; let test262Fn;');
27 }, 'function');
28
29 assert.throws(ReferenceError, function() {
30 x;
31 }, 'no bindings created (script shadowing function)');
32
33 reportCompare(0, 0);