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/block-scope/shadowing | |
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/block-scope/shadowing')
17 files changed, 386 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/block-scope/shadowing/browser.js b/js/src/tests/test262/language/block-scope/shadowing/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/block-scope/shadowing/browser.js diff --git a/js/src/tests/test262/language/block-scope/shadowing/catch-parameter-shadowing-catch-parameter.js b/js/src/tests/test262/language/block-scope/shadowing/catch-parameter-shadowing-catch-parameter.js new file mode 100644 index 0000000000..77bfd22f4a --- /dev/null +++ b/js/src/tests/test262/language/block-scope/shadowing/catch-parameter-shadowing-catch-parameter.js @@ -0,0 +1,28 @@ +// Copyright (C) 2011 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 13.1 +description: > + catch parameter shadowing catch parameter +---*/ +function fn() { + var c = 1; + try { + throw 'stuff3'; + } catch (c) { + try { + throw 'stuff4'; + } catch(c) { + assert.sameValue(c,'stuff4'); + // catch parameter shadowing catch parameter + c = 3; + assert.sameValue(c, 3); + } + assert.sameValue(c, 'stuff3'); + } + assert.sameValue(c, 1); +} +fn(1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/block-scope/shadowing/catch-parameter-shadowing-function-parameter-name.js b/js/src/tests/test262/language/block-scope/shadowing/catch-parameter-shadowing-function-parameter-name.js new file mode 100644 index 0000000000..30f54026fa --- /dev/null +++ b/js/src/tests/test262/language/block-scope/shadowing/catch-parameter-shadowing-function-parameter-name.js @@ -0,0 +1,21 @@ +// Copyright (C) 2011 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 13.1 +description: > + catch parameter shadowing function parameter name +---*/ +function fn(a) { + try { + throw 'stuff1'; + } catch (a) { + assert.sameValue(a, 'stuff1'); + // catch parameter shadowing function parameter name + a = 2; + assert.sameValue(a, 2); + } +} +fn(1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/block-scope/shadowing/catch-parameter-shadowing-let-declaration.js b/js/src/tests/test262/language/block-scope/shadowing/catch-parameter-shadowing-let-declaration.js new file mode 100644 index 0000000000..215fcf758b --- /dev/null +++ b/js/src/tests/test262/language/block-scope/shadowing/catch-parameter-shadowing-let-declaration.js @@ -0,0 +1,22 @@ +// Copyright (C) 2011 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 13.1 +description: > + catch parameter shadowing let declaration +---*/ +{ + let a = 3; + try { + throw 'stuff2'; + } catch (a) { + assert.sameValue(a, 'stuff2'); + // catch parameter shadowing let declaration + a = 4; + assert.sameValue(a, 4); + } + assert.sameValue(a, 3); +} + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/block-scope/shadowing/catch-parameter-shadowing-var-variable.js b/js/src/tests/test262/language/block-scope/shadowing/catch-parameter-shadowing-var-variable.js new file mode 100644 index 0000000000..f12b667704 --- /dev/null +++ b/js/src/tests/test262/language/block-scope/shadowing/catch-parameter-shadowing-var-variable.js @@ -0,0 +1,21 @@ +// Copyright (C) 2011 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 13.1 +description: > + catch parameter shadowing var variable +---*/ +function fn() { + var a = 1; + try { + throw 'stuff3'; + } catch (a) { + // catch parameter shadowing var variable + assert.sameValue(a, 'stuff3'); + } + assert.sameValue(a, 1); +} +fn(); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/block-scope/shadowing/const-declaration-shadowing-catch-parameter.js b/js/src/tests/test262/language/block-scope/shadowing/const-declaration-shadowing-catch-parameter.js new file mode 100644 index 0000000000..963ed3302e --- /dev/null +++ b/js/src/tests/test262/language/block-scope/shadowing/const-declaration-shadowing-catch-parameter.js @@ -0,0 +1,25 @@ +// Copyright (C) 2011 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 13.1 +description: > + const declaration shadowing catch parameter +---*/ +function fn() { + var a = 1; + try { + throw 'stuff3'; + } catch (a) { + { + // const declaration shadowing catch parameter + const a = 3; + assert.sameValue(a, 3); + } + assert.sameValue(a, 'stuff3'); + } + assert.sameValue(a, 1); +} +fn(); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/block-scope/shadowing/const-declarations-shadowing-parameter-name-let-const-and-var-variables.js b/js/src/tests/test262/language/block-scope/shadowing/const-declarations-shadowing-parameter-name-let-const-and-var-variables.js new file mode 100644 index 0000000000..fa31e802cb --- /dev/null +++ b/js/src/tests/test262/language/block-scope/shadowing/const-declarations-shadowing-parameter-name-let-const-and-var-variables.js @@ -0,0 +1,31 @@ +// Copyright (C) 2011 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 13.1 +description: > + const declarations shadowing parameter name, let, const and var variables +---*/ +function fn(a) { + let b = 1; + var c = 1; + const d = 1; + { + const a = 2; + const b = 2; + const c = 2; + const d = 2; + assert.sameValue(a, 2); + assert.sameValue(b, 2); + assert.sameValue(c, 2); + assert.sameValue(d, 2); + } + + assert.sameValue(a, 1); + assert.sameValue(b, 1); + assert.sameValue(c, 1); + assert.sameValue(d, 1); +} +fn(1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/block-scope/shadowing/dynamic-lookup-from-closure.js b/js/src/tests/test262/language/block-scope/shadowing/dynamic-lookup-from-closure.js new file mode 100644 index 0000000000..0f69d01cfe --- /dev/null +++ b/js/src/tests/test262/language/block-scope/shadowing/dynamic-lookup-from-closure.js @@ -0,0 +1,30 @@ +// Copyright (C) 2011 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 13.1 +description: > + dynamic lookup from closure +---*/ +function fn(one) { + var x = one + 1; + let y = one + 2; + const u = one + 4; + { + let z = one + 3; + const v = one + 5; + function f() { + assert.sameValue(one, 1); + assert.sameValue(x, 2); + assert.sameValue(y, 3); + assert.sameValue(z, 4); + assert.sameValue(u, 5); + assert.sameValue(v, 6); + } + + f(); + } +} +fn(1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/block-scope/shadowing/dynamic-lookup-in-and-through-block-contexts.js b/js/src/tests/test262/language/block-scope/shadowing/dynamic-lookup-in-and-through-block-contexts.js new file mode 100644 index 0000000000..038e71b55b --- /dev/null +++ b/js/src/tests/test262/language/block-scope/shadowing/dynamic-lookup-in-and-through-block-contexts.js @@ -0,0 +1,27 @@ +// Copyright (C) 2011 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 13.1 +description: > + dynamic lookup in and through block contexts +---*/ +function fn(one) { + var x = one + 1; + let y = one + 2; + const u = one + 4; + { + let z = one + 3; + const v = one + 5; + assert.sameValue(one, 1); + assert.sameValue(x, 2); + assert.sameValue(y, 3); + assert.sameValue(z, 4); + assert.sameValue(u, 5); + assert.sameValue(v, 6); + } +} + +fn(1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/block-scope/shadowing/hoisting-var-declarations-out-of-blocks.js b/js/src/tests/test262/language/block-scope/shadowing/hoisting-var-declarations-out-of-blocks.js new file mode 100644 index 0000000000..de270a9f74 --- /dev/null +++ b/js/src/tests/test262/language/block-scope/shadowing/hoisting-var-declarations-out-of-blocks.js @@ -0,0 +1,19 @@ +// Copyright (C) 2011 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 13.1 +description: > + hoisting var declarations out of blocks +---*/ +function fn() { + { + var x = 1; + var y; + } + assert.sameValue(x, 1); + assert.sameValue(y, undefined); +} +fn(); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/block-scope/shadowing/let-declaration-shadowing-catch-parameter.js b/js/src/tests/test262/language/block-scope/shadowing/let-declaration-shadowing-catch-parameter.js new file mode 100644 index 0000000000..cbe153281f --- /dev/null +++ b/js/src/tests/test262/language/block-scope/shadowing/let-declaration-shadowing-catch-parameter.js @@ -0,0 +1,20 @@ +// Copyright (C) 2011 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 13.1 +description: > + let declaration shadowing catch parameter +---*/ +try { + throw 'stuff1'; +} catch (a) { + { + // let declaration shadowing catch parameter + let a = 3; + assert.sameValue(a, 3); + } + assert.sameValue(a, 'stuff1'); +} + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/block-scope/shadowing/let-declarations-shadowing-parameter-name-let-const-and-var.js b/js/src/tests/test262/language/block-scope/shadowing/let-declarations-shadowing-parameter-name-let-const-and-var.js new file mode 100644 index 0000000000..3f1a781bf8 --- /dev/null +++ b/js/src/tests/test262/language/block-scope/shadowing/let-declarations-shadowing-parameter-name-let-const-and-var.js @@ -0,0 +1,26 @@ +// Copyright (C) 2011 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 13.1 +description: > + let declarations shadowing parameter name, let, const and var +---*/ +function fn(a) { + let b = 1; + var c = 1; + const d = 1; + { + let a = 2; + let b = 2; + let c = 2; + let d = 2; + assert.sameValue(a, 2); + assert.sameValue(b, 2); + assert.sameValue(c, 2); + assert.sameValue(d, 2); + } +} +fn(1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/block-scope/shadowing/lookup-from-closure.js b/js/src/tests/test262/language/block-scope/shadowing/lookup-from-closure.js new file mode 100644 index 0000000000..38139e812c --- /dev/null +++ b/js/src/tests/test262/language/block-scope/shadowing/lookup-from-closure.js @@ -0,0 +1,30 @@ +// Copyright (C) 2011 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 13.1 +description: > + lookup from closure +---*/ +function f5(one) { + var x = one + 1; + let y = one + 2; + const u = one + 4; + { + let z = one + 3; + const v = one + 5; + function f() { + assert.sameValue(one, 1); + assert.sameValue(x, 2); + assert.sameValue(y, 3); + assert.sameValue(z, 4); + assert.sameValue(u, 5); + assert.sameValue(v, 6); + } + + f(); + } +} +f5(1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/block-scope/shadowing/lookup-in-and-through-block-contexts.js b/js/src/tests/test262/language/block-scope/shadowing/lookup-in-and-through-block-contexts.js new file mode 100644 index 0000000000..3700de243d --- /dev/null +++ b/js/src/tests/test262/language/block-scope/shadowing/lookup-in-and-through-block-contexts.js @@ -0,0 +1,27 @@ +// Copyright (C) 2011 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 13.1 +description: > + lookup in and through block contexts +---*/ +function fn(one) { + var x = one + 1; + let y = one + 2; + const u = one + 4; + { + let z = one + 3; + const v = one + 5; + assert.sameValue(one, 1); + assert.sameValue(x, 2); + assert.sameValue(y, 3); + assert.sameValue(z, 4); + assert.sameValue(u, 5); + assert.sameValue(v, 6); + } +} + +fn(1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/block-scope/shadowing/parameter-name-shadowing-catch-parameter.js b/js/src/tests/test262/language/block-scope/shadowing/parameter-name-shadowing-catch-parameter.js new file mode 100644 index 0000000000..1ec2063cee --- /dev/null +++ b/js/src/tests/test262/language/block-scope/shadowing/parameter-name-shadowing-catch-parameter.js @@ -0,0 +1,25 @@ +// Copyright (C) 2011 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 13.1 +description: > + parameter name shadowing catch parameter +---*/ +function fn() { + var c = 1; + try { + throw 'stuff3'; + } catch (c) { + (function(c) { + // parameter name shadowing catch parameter + c = 3; + assert.sameValue(c, 3); + })(); + assert.sameValue(c, 'stuff3'); + } + assert.sameValue(c, 1); +} +fn(); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/block-scope/shadowing/parameter-name-shadowing-parameter-name-let-const-and-var.js b/js/src/tests/test262/language/block-scope/shadowing/parameter-name-shadowing-parameter-name-let-const-and-var.js new file mode 100644 index 0000000000..e8194ce346 --- /dev/null +++ b/js/src/tests/test262/language/block-scope/shadowing/parameter-name-shadowing-parameter-name-let-const-and-var.js @@ -0,0 +1,34 @@ +// Copyright (C) 2011 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +es6id: 13.1 +description: > + parameter name shadowing parameter name, let, const and var +---*/ +function fn(a) { + let b = 1; + var c = 1; + const d = 1; + + (function(a, b, c, d) { + a = 2; + b = 2; + c = 2; + d = 2; + + assert.sameValue(a, 2); + assert.sameValue(b, 2); + assert.sameValue(c, 2); + assert.sameValue(d, 2); + })(1, 1); + + assert.sameValue(a, 1); + assert.sameValue(b, 1); + assert.sameValue(c, 1); + assert.sameValue(d, 1); +} + +fn(1); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/language/block-scope/shadowing/shell.js b/js/src/tests/test262/language/block-scope/shadowing/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/language/block-scope/shadowing/shell.js |