Bug 1921345 - Remove global constructor from js/src/vm/SavedStacks.cpp r=arai
[gecko.git] / js / src / tests / test262 / annexB / language / eval-code / direct / func-switch-case-eval-func-init.js
bloba07ad2142d30d7d6f3540956556d6350b4ca6d28
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 flags: [generated, noStrict]
8 info: |
9     B.3.3.3 Changes to EvalDeclarationInstantiation
11     [...]
12     a. If declaredFunctionOrVarNames does not contain F, then
13        i. If varEnvRec is a global Environment Record, then
14           [...]
15        ii. Else,
16            i. Let bindingExists be varEnvRec.HasBinding(F).
17            ii. If bindingExists is false, then
18                i. Perform ! varEnvRec.CreateMutableBinding(F, true).
19                ii. Perform ! varEnvRec.InitializeBinding(F, undefined).
20     [...]
21 ---*/
22 var init, changed;
24 (function() {
25   eval(
26     'init = f;\
27     f = 123;\
28     changed = f;switch (1) {' +
29     '  case 1:' +
30     '    function f() {  }' +
31     '}\
32     '
33   );
34 }());
36 assert.sameValue(init, undefined, 'binding is initialized to `undefined`');
37 assert.sameValue(changed, 123, 'binding is mutable');
38 assert.throws(ReferenceError, function() {
39   f;
40 }, 'global binding is not created');
42 reportCompare(0, 0);