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 --- js/src/tests/non262/Scope/browser.js | 0 js/src/tests/non262/Scope/regress-154693.js | 64 ++++++++ js/src/tests/non262/Scope/regress-181834.js | 146 ++++++++++++++++++ js/src/tests/non262/Scope/regress-184107.js | 90 ++++++++++++ js/src/tests/non262/Scope/regress-185485.js | 126 ++++++++++++++++ js/src/tests/non262/Scope/regress-191276.js | 91 ++++++++++++ js/src/tests/non262/Scope/regress-192226.js | 88 +++++++++++ js/src/tests/non262/Scope/regress-202678-001.js | 99 +++++++++++++ js/src/tests/non262/Scope/regress-202678-002.js | 100 +++++++++++++ js/src/tests/non262/Scope/regress-208496-001.js | 137 +++++++++++++++++ js/src/tests/non262/Scope/regress-208496-002.js | 129 ++++++++++++++++ js/src/tests/non262/Scope/regress-220362.js | 79 ++++++++++ js/src/tests/non262/Scope/regress-446026-01.js | 51 +++++++ js/src/tests/non262/Scope/regress-446026-02.js | 27 ++++ js/src/tests/non262/Scope/regress-77578-001.js | 114 ++++++++++++++ js/src/tests/non262/Scope/scope-002.js | 105 +++++++++++++ js/src/tests/non262/Scope/scope-003.js | 106 +++++++++++++ js/src/tests/non262/Scope/scope-004.js | 188 ++++++++++++++++++++++++ js/src/tests/non262/Scope/shell.js | 0 19 files changed, 1740 insertions(+) create mode 100644 js/src/tests/non262/Scope/browser.js create mode 100644 js/src/tests/non262/Scope/regress-154693.js create mode 100644 js/src/tests/non262/Scope/regress-181834.js create mode 100644 js/src/tests/non262/Scope/regress-184107.js create mode 100644 js/src/tests/non262/Scope/regress-185485.js create mode 100644 js/src/tests/non262/Scope/regress-191276.js create mode 100644 js/src/tests/non262/Scope/regress-192226.js create mode 100644 js/src/tests/non262/Scope/regress-202678-001.js create mode 100644 js/src/tests/non262/Scope/regress-202678-002.js create mode 100644 js/src/tests/non262/Scope/regress-208496-001.js create mode 100644 js/src/tests/non262/Scope/regress-208496-002.js create mode 100644 js/src/tests/non262/Scope/regress-220362.js create mode 100644 js/src/tests/non262/Scope/regress-446026-01.js create mode 100644 js/src/tests/non262/Scope/regress-446026-02.js create mode 100644 js/src/tests/non262/Scope/regress-77578-001.js create mode 100644 js/src/tests/non262/Scope/scope-002.js create mode 100644 js/src/tests/non262/Scope/scope-003.js create mode 100644 js/src/tests/non262/Scope/scope-004.js create mode 100644 js/src/tests/non262/Scope/shell.js (limited to 'js/src/tests/non262/Scope') diff --git a/js/src/tests/non262/Scope/browser.js b/js/src/tests/non262/Scope/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/non262/Scope/regress-154693.js b/js/src/tests/non262/Scope/regress-154693.js new file mode 100644 index 0000000000..d0f0a5ea86 --- /dev/null +++ b/js/src/tests/non262/Scope/regress-154693.js @@ -0,0 +1,64 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * + * Date: 26 Nov 2002 + * SUMMARY: Testing scope + * See http://bugzilla.mozilla.org/show_bug.cgi?id=154693 + * + */ +//----------------------------------------------------------------------------- +var UBound = 0; +var BUGNUMBER = 154693; +var summary = 'Testing scope'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +function f() +{ + function nested() {} + return nested; +} +var f1 = f(); +var f2 = f(); + +status = inSection(1); +actual = (f1 != f2); +expect = true; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i0, we end up calling inner() N+1 times: + * inner(N), inner(N-1), ... , inner(0). + * + * Each call to inner() increments |outer_d| by 1. + * The last call, inner(0), returns the final value + * of |outer_d|, which should be N+1. + */ +function outer(N) +{ + var outer_d = 0; + return inner(N); + + function inner(level) + { + outer_d++; + + if (level > 0) + return inner(level - 1); + else + return outer_d; + } +} + + +/* + * This only has meaning in Rhino - + */ +setDynamicScope(true); + +/* + * Recompile the function |outer| via eval() in order to + * feel the effect of the dynamic scope mode we have set. + */ +var s = outer.toString(); +eval(s); + +status = inSection(1); +actual = outer(-5); +expect = 1; +addThis(); + +status = inSection(2); +actual = outer(0); +expect = 1; +addThis(); + +status = inSection(3); +actual = outer(5); +expect = 6; +addThis(); + + +/* + * Sanity check: do same steps with the dynamic flag off + */ +setDynamicScope(false); + +/* + * Recompile the function |outer| via eval() in order to + * feel the effect of the dynamic scope mode we have set. + */ +eval(s); + +status = inSection(4); +actual = outer(-5); +expect = 1; +addThis(); + +status = inSection(5); +actual = outer(0); +expect = 1; +addThis(); + +status = inSection(6); +actual = outer(5); +expect = 6; +addThis(); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function setDynamicScope(flag) +{ + if (this.Packages) + { + var cx = this.Packages.org.mozilla.javascript.Context.getCurrentContext(); + cx.setCompileFunctionsWithDynamicScope(flag); + } +} + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i