diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/tests/test262/annexB/language/statements/try | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/annexB/language/statements/try')
7 files changed, 132 insertions, 0 deletions
diff --git a/js/src/tests/test262/annexB/language/statements/try/browser.js b/js/src/tests/test262/annexB/language/statements/try/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/try/browser.js diff --git a/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-for-in-var.js b/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-for-in-var.js new file mode 100644 index 0000000000..2a8efd5591 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-for-in-var.js @@ -0,0 +1,29 @@ +// 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-variablestatements-in-catch-blocks +es6id: B.3.5 +description: Re-declaration of catch parameter (for-in statement) +info: | + It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block, unless CatchParameter is + CatchParameter : BindingIdentifier. +---*/ + +var before, during, after; + +try { + throw 'exception'; +} catch (err) { + before = err; + for (var err in { propertyName: null }) { + during = err; + } + after = err; +} + +assert.sameValue(before, 'exception'); +assert.sameValue(during, 'propertyName', 'during loop body evaluation'); +assert.sameValue(after, 'propertyName', 'after loop body evaluation'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-for-of-var.js b/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-for-of-var.js new file mode 100644 index 0000000000..2a9da1e1f9 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-for-of-var.js @@ -0,0 +1,29 @@ +// Copyright (C) 2019 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +author: Ross Kirsling +esid: sec-variablestatements-in-catch-blocks +description: Re-declaration of catch parameter (for-of statement) +info: | + It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block, unless CatchParameter is + CatchParameter : BindingIdentifier. +---*/ + +var before, during, after; + +try { + throw 'exception'; +} catch (err) { + before = err; + for (var err of [2]) { + during = err; + } + after = err; +} + +assert.sameValue(before, 'exception'); +assert.sameValue(during, 2, 'during loop body evaluation'); +assert.sameValue(after, 2, 'after loop body evaluation'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-for-var.js b/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-for-var.js new file mode 100644 index 0000000000..0ca15f0af9 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-for-var.js @@ -0,0 +1,29 @@ +// 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-variablestatements-in-catch-blocks +es6id: B.3.5 +description: Re-declaration of catch parameter (for statement) +info: | + It is a Syntax Error if any element of the BoundNames of CatchParameter + also occurs in the VarDeclaredNames of Block, unless CatchParameter is + CatchParameter : BindingIdentifier. +---*/ + +var before, during, after; + +try { + throw 'exception'; +} catch (err) { + before = err; + for (var err = 'loop initializer'; err !== 'increment'; err = 'increment') { + during = err; + } + after = err; +} + +assert.sameValue(before, 'exception'); +assert.sameValue(during, 'loop initializer'); +assert.sameValue(after, 'increment'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-var-statement-captured.js b/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-var-statement-captured.js new file mode 100644 index 0000000000..b9865d0a03 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-var-statement-captured.js @@ -0,0 +1,23 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 12.14-2 +es6id: B.3.5 +description: > + catch doesn't change declaration scope - var initializer in catch + with same name as catch parameter changes parameter +---*/ + + function capturedFoo() {return foo}; + foo = "prior to throw"; + try { + throw new Error(); + } + catch (foo) { + var foo = "initializer in catch"; + } + +assert.sameValue(capturedFoo(), "prior to throw"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-var-statement.js b/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-var-statement.js new file mode 100644 index 0000000000..6cfcbde4f7 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/try/catch-redeclared-var-statement.js @@ -0,0 +1,22 @@ +// Copyright (c) 2012 Ecma International. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +es5id: 12.14-1 +es6id: B.3.5 +description: > + catch doesn't change declaration scope - var initializer in catch + with same name as catch parameter changes parameter +---*/ + + foo = "prior to throw"; + try { + throw new Error(); + } + catch (foo) { + var foo = "initializer in catch"; + } + +assert.sameValue(foo, "prior to throw"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/annexB/language/statements/try/shell.js b/js/src/tests/test262/annexB/language/statements/try/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/annexB/language/statements/try/shell.js |