From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../global-code/script-decl-var-collision.js | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 js/src/tests/test262/language/global-code/script-decl-var-collision.js (limited to 'js/src/tests/test262/language/global-code/script-decl-var-collision.js') 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); -- cgit v1.2.3