diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/tests/test262/language/global-code/script-decl-var-collision.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/language/global-code/script-decl-var-collision.js')
-rw-r--r-- | js/src/tests/test262/language/global-code/script-decl-var-collision.js | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/global-code/script-decl-var-collision.js b/js/src/tests/test262/language/global-code/script-decl-var-collision.js new file mode 100644 index 0000000000..dcc247e536 --- /dev/null +++ b/js/src/tests/test262/language/global-code/script-decl-var-collision.js @@ -0,0 +1,64 @@ +// 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: Var binding collision with existing lexical declaration +info: | + [...] + 6. For each name in varNames, do + a. If envRec.HasLexicalDeclaration(name) is true, throw a SyntaxError + exception. +---*/ + +var test262Var; +let test262Let; +const test262Const = null; +class test262Class {} + +$262.evalScript('var test262Var;'); +$262.evalScript('function test262Var() {}'); + +assert.throws(SyntaxError, function() { + $262.evalScript('var x; var test262Let;'); +}, '`var` on `let` binding'); +assert.throws(ReferenceError, function() { + x; +}, 'no bindings created (script declaring a `var` on a `let` binding)'); + +assert.throws(SyntaxError, function() { + $262.evalScript('var x; var test262Const;'); +}, '`var` on `const` binding'); +assert.throws(ReferenceError, function() { + x; +}, 'no bindings created (script declaring a `var` on a `const` binding)'); + +assert.throws(SyntaxError, function() { + $262.evalScript('var x; var test262Class;'); +}, '`var` on `class` binding'); +assert.throws(ReferenceError, function() { + x; +}, 'no bindings created (script declaring a `var` on a `class` binding)'); + +assert.throws(SyntaxError, function() { + $262.evalScript('var x; function test262Let() {}'); +}, 'function on `let` binding'); +assert.throws(ReferenceError, function() { + x; +}, 'no bindings created (script declaring a function on a `let` binding)'); + +assert.throws(SyntaxError, function() { + $262.evalScript('var x; function test262Const() {}'); +}, 'function on `const` binding'); +assert.throws(ReferenceError, function() { + x; +}, 'no bindings created (script declaring a function on a `const` binding)'); + +assert.throws(SyntaxError, function() { + $262.evalScript('var x; function test262Class() {}'); +} , 'function on `class` binding'); +assert.throws(ReferenceError, function() { + x; +}, 'no bindings created (script declaring a function on a class binding)'); + +reportCompare(0, 0); |