Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/annexB/language/function-code/switch-dflt-func-init.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/annex-b-fns/func-init.case
3 // - src/annex-b-fns/func/switch-dflt.template
4 /*---
5 description: Variable binding is initialized to `undefined` in outer scope (Funtion declaration in the `default` clause of a `switch` statement in function scope)
6 esid: sec-web-compat-functiondeclarationinstantiation
7 es6id: B.3.3.1
8 flags: [generated, noStrict]
9 info: |
10 B.3.3.1 Changes to FunctionDeclarationInstantiation
11
12 [...]
13 2. If instantiatedVarNames does not contain F, then
14 a. Perform ! varEnvRec.CreateMutableBinding(F, false).
15 b. Perform varEnvRec.InitializeBinding(F, undefined).
16 c. Append F to instantiatedVarNames.
17 [...]
18 ---*/
19 var init, changed;
20
21 (function() {
22 init = f;
23 f = 123;
24 changed = f;
25
26 switch (1) {
27 default:
28 function f() { }
29 }
30
31
32 }());
33
34 assert.sameValue(init, undefined, 'binding is initialized to `undefined`');
35 assert.sameValue(changed, 123, 'binding is mutable');
36 assert.throws(ReferenceError, function() {
37 f;
38 }, 'global binding is not created');