diff options
Diffstat (limited to 'js/src/tests/test262/language/global-code/script-decl-lex-var.js')
-rw-r--r-- | js/src/tests/test262/language/global-code/script-decl-lex-var.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/global-code/script-decl-lex-var.js b/js/src/tests/test262/language/global-code/script-decl-lex-var.js new file mode 100644 index 0000000000..41d413068e --- /dev/null +++ b/js/src/tests/test262/language/global-code/script-decl-lex-var.js @@ -0,0 +1,33 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-globaldeclarationinstantiation +es6id: 15.1.8 +description: Let binding collision with existing var declaration +info: | + [...] + 5. For each name in lexNames, do + a. If envRec.HasVarDeclaration(name) is true, throw a SyntaxError + exception. +---*/ + +var test262Var; +function test262Fn() {} + +assert.throws(SyntaxError, function() { + $262.evalScript('var x; let test262Var;'); +}, 'variable'); + +assert.throws(ReferenceError, function() { + x; +}, 'no bindings created (script shadowing variable)'); + +assert.throws(SyntaxError, function() { + $262.evalScript('var x; let test262Fn;'); +}, 'function'); + +assert.throws(ReferenceError, function() { + x; +}, 'no bindings created (script shadowing function)'); + +reportCompare(0, 0); |