Bug 1909234 - Vendor libwebrtc from e0b28a6a81
[gecko.git] / js / src / tests / test262 / annexB / language / eval-code / direct / global-switch-case-eval-global-existing-global-update.js
blob2e399df93cd848b85ecde7b4cf23d77448101697
1 // This file was procedurally generated from the following sources:
2 // - src/annex-b-fns/eval-global-existing-global-update.case
3 // - src/annex-b-fns/eval-global/direct-switch-case.template
4 /*---
5 description: Variable-scoped binding is updated following evaluation (Function declaration in the `case` clause of a `switch` statement in eval code)
6 esid: sec-web-compat-evaldeclarationinstantiation
7 flags: [generated, noStrict]
8 includes: [fnGlobalObject.js]
9 info: |
10     B.3.3.3 Changes to EvalDeclarationInstantiation
12     [...]
13     b. When the FunctionDeclaration f is evaluated, perform the following steps
14        in place of the FunctionDeclaration Evaluation algorithm provided in
15        14.1.21:
16        i. Let genv be the running execution context's VariableEnvironment.
17        ii. Let genvRec be genv's EnvironmentRecord.
18        iii. Let benv be the running execution context's LexicalEnvironment.
19        iv. Let benvRec be benv's EnvironmentRecord.
20        v. Let fobj be ! benvRec.GetBindingValue(F, false).
21        vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
22        vii. Return NormalCompletion(empty). 
24 ---*/
25 Object.defineProperty(fnGlobalObject(), 'f', {
26   value: function() { return 'Another function'; },
27   enumerable: true,
28   writable: true,
29   configurable: false
30 });
32 eval(
33   'switch (1) {' +
34   '  case 1:' +
35   '    function f() { return "function declaration"; }' +
36   '}\
37   '
40 assert.sameValue(typeof f, 'function');
41 assert.sameValue(f(), 'function declaration');
43 reportCompare(0, 0);