Bug 1892041 - Part 1: Update test262 features. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / annexB / language / eval-code / direct / func-switch-dflt-eval-func-existing-fn-update.js
blob2dfcdf766844d364e476040fe7eb40fa84b99d20
1 // This file was procedurally generated from the following sources:
2 // - src/annex-b-fns/eval-func-existing-fn-update.case
3 // - src/annex-b-fns/eval-func/direct-switch-dflt.template
4 /*---
5 description: Variable-scoped binding is updated following evaluation (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope)
6 esid: sec-web-compat-evaldeclarationinstantiation
7 flags: [generated, noStrict]
8 info: |
9     B.3.3.3 Changes to EvalDeclarationInstantiation
11     [...]
12     b. When the FunctionDeclaration f is evaluated, perform the following steps
13        in place of the FunctionDeclaration Evaluation algorithm provided in
14        14.1.21:
15        i. Let genv be the running execution context's VariableEnvironment.
16        ii. Let genvRec be genv's EnvironmentRecord.
17        iii. Let benv be the running execution context's LexicalEnvironment.
18        iv. Let benvRec be benv's EnvironmentRecord.
19        v. Let fobj be ! benvRec.GetBindingValue(F, false).
20        vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
21        vii. Return NormalCompletion(empty). 
22 ---*/
23 var after;
25 (function() {
26   eval(
27     'switch (1) {' +
28     '  default:' +
29     '    function f() { return "inner declaration"; }' +
30     '}\
31     after = f;\
32     \
33     function f() {\
34       return "outer declaration";\
35     }'
36   );
37 }());
39 assert.sameValue(typeof after, 'function');
40 assert.sameValue(after(), 'inner declaration');
42 reportCompare(0, 0);