Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/annexB/language/eval-code/direct/global-switch-dflt-eval-global-existing-global-update.js

raw
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-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 es6id: B.3.3.3
8 flags: [generated, noStrict]
9 includes: [fnGlobalObject.js]
10 info: |
11 B.3.3.3 Changes to EvalDeclarationInstantiation
12
13 [...]
14 b. When the FunctionDeclaration f is evaluated, perform the following steps
15 in place of the FunctionDeclaration Evaluation algorithm provided in
16 14.1.21:
17 i. Let genv be the running execution context's VariableEnvironment.
18 ii. Let genvRec be genv's EnvironmentRecord.
19 iii. Let benv be the running execution context's LexicalEnvironment.
20 iv. Let benvRec be benv's EnvironmentRecord.
21 v. Let fobj be ! benvRec.GetBindingValue(F, false).
22 vi. Perform ? genvRec.SetMutableBinding(F, fobj, false).
23 vii. Return NormalCompletion(empty).
24
25 ---*/
26 Object.defineProperty(fnGlobalObject(), 'f', {
27 value: function() { return 'Another function'; },
28 enumerable: true,
29 writable: true,
30 configurable: false
31 });
32
33 eval(
34 'switch (1) {' +
35 ' default:' +
36 ' function f() { return "function declaration"; }' +
37 '}\
38 '
39 );
40
41 assert.sameValue(typeof f, 'function');
42 assert.sameValue(f(), 'function declaration');