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/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-block-scoping.js | |
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/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-block-scoping.js')
-rw-r--r-- | js/src/tests/test262/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-block-scoping.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/js/src/tests/test262/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-block-scoping.js b/js/src/tests/test262/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-block-scoping.js new file mode 100644 index 0000000000..42be9b1467 --- /dev/null +++ b/js/src/tests/test262/annexB/language/eval-code/indirect/global-if-decl-else-stmt-eval-global-block-scoping.js @@ -0,0 +1,55 @@ +// This file was procedurally generated from the following sources: +// - src/annex-b-fns/eval-global-block-scoping.case +// - src/annex-b-fns/eval-global/indirect-if-decl-else-stmt.template +/*--- +description: A block-scoped binding is created (IfStatement with a declaration in the first statement position in eval code) +esid: sec-functiondeclarations-in-ifstatement-statement-clauses +flags: [generated, noStrict] +info: | + The following rules for IfStatement augment those in 13.6: + + IfStatement[Yield, Return]: + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else Statement[?Yield, ?Return] + if ( Expression[In, ?Yield] ) Statement[?Yield, ?Return] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] else FunctionDeclaration[?Yield] + if ( Expression[In, ?Yield] ) FunctionDeclaration[?Yield] + + + 13.2.14 Runtime Semantics: BlockDeclarationInstantiation + + [...] + 4. For each element d in declarations do + a. For each element dn of the BoundNames of d do + i. If IsConstantDeclaration of d is true, then + [...] + ii. Else, + 2. Perform ! envRec.CreateMutableBinding(dn, false). + + b. If d is a GeneratorDeclaration production or a FunctionDeclaration + production, then + i. Let fn be the sole element of the BoundNames of d. + ii. Let fo be the result of performing InstantiateFunctionObject for + d with argument env. + iii. Perform envRec.InitializeBinding(fn, fo). +---*/ +var initialBV, currentBV; + +(0,eval)( + 'if (true) function f() { initialBV = f; f = 123; currentBV = f; return "decl"; } else ;' +); + +f(); + +assert.sameValue( + initialBV(), + 'decl', + 'Block-scoped binding value is function object at execution time' +); +assert.sameValue(currentBV, 123, 'Block-scoped binding is mutable'); +assert.sameValue( + f(), + 'decl', + 'Block-scoped binding is independent of outer var-scoped binding' +); + +reportCompare(0, 0); |