diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/language/statements/for/scope-head-lex-close.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/language/statements/for/scope-head-lex-close.js')
-rw-r--r-- | js/src/tests/test262/language/statements/for/scope-head-lex-close.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/statements/for/scope-head-lex-close.js b/js/src/tests/test262/language/statements/for/scope-head-lex-close.js new file mode 100644 index 0000000000..a8f35a18e7 --- /dev/null +++ b/js/src/tests/test262/language/statements/for/scope-head-lex-close.js @@ -0,0 +1,41 @@ +// 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-for-statement-runtime-semantics-labelledevaluation +description: Removal of lexical environment for the statement "head" +info: | + [...] + 2. Let loopEnv be NewDeclarativeEnvironment(oldEnv). + 3. Let loopEnvRec be loopEnv's EnvironmentRecord. + 4. Let isConst be the result of performing IsConstantDeclaration of + LexicalDeclaration. + 5. Let boundNames be the BoundNames of LexicalDeclaration. + 6. For each element dn of boundNames do + a. If isConst is true, then + i. Perform ! loopEnvRec.CreateImmutableBinding(dn, true). + b. Else, + i. Perform ! loopEnvRec.CreateMutableBinding(dn, false). + 7. Set the running execution context's LexicalEnvironment to loopEnv. + [...] + 12. Set the running execution context's LexicalEnvironment to oldEnv. + 13. Return Completion(bodyResult). +features: [let] +---*/ + +let x = 'outside'; +var run = true; +var probeTest, probeIncr, probeBody; + +for ( + let x = 'inside'; + (probeTest = function() { return x; }) && run; + probeIncr = function() { return x; } + ) + probeBody = function() { return x; }, run = false; + +assert.sameValue(probeBody(), 'inside', 'reference from statement body'); +assert.sameValue(probeIncr(), 'inside', 'reference from "increment" position'); +assert.sameValue(probeTest(), 'inside', 'reference from "test" position'); +assert.sameValue(x, 'outside'); + +reportCompare(0, 0); |