Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/annexB/language/eval-code/direct/func-switch-case-eval-func-init.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/annex-b-fns/eval-func-init.case
3 // - src/annex-b-fns/eval-func/direct-switch-case.template
4 /*---
5 description: Variable binding is initialized to `undefined` in outer scope (Function declaration in the `case` clause of a `switch` statement in eval code)
6 esid: sec-web-compat-evaldeclarationinstantiation
7 es6id: B.3.3.3
8 flags: [generated, noStrict]
9 info: |
10 B.3.3.3 Changes to EvalDeclarationInstantiation
11
12 [...]
13 a. If declaredFunctionOrVarNames does not contain F, then
14 i. If varEnvRec is a global Environment Record, then
15 [...]
16 ii. Else,
17 i. Let bindingExists be varEnvRec.HasBinding(F).
18 ii. If bindingExists is false, then
19 i. Perform ! varEnvRec.CreateMutableBinding(F, true).
20 ii. Perform ! varEnvRec.InitializeBinding(F, undefined).
21 [...]
22 ---*/
23 var init, changed;
24
25 (function() {
26 eval(
27 'init = f;\
28 f = 123;\
29 changed = f;switch (1) {' +
30 ' case 1:' +
31 ' function f() { }' +
32 '}\
33 '
34 );
35 }());
36
37 assert.sameValue(init, undefined, 'binding is initialized to `undefined`');
38 assert.sameValue(changed, 123, 'binding is mutable');
39 assert.throws(ReferenceError, function() {
40 f;
41 }, 'global binding is not created');