Debian Codegraph @

js/src/tests/test262/annexB/language/eval-code/direct/global-switch-dflt-eval-global-existing-global-init.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/annex-b-fns/eval-global-existing-global-init.case
3 // - src/annex-b-fns/eval-global/direct-switch-dflt.template
4 /*---
5 description: Variable binding is left in place by legacy function hoisting (Funtion declaration in the `default` clause of a `switch` statement in eval code in the global scope)
6 esid: sec-web-compat-evaldeclarationinstantiation
7 flags: [generated, noStrict]
8 includes: [fnGlobalObject.js, propertyHelper.js]
9 info: |
10 B.3.3.3 Changes to EvalDeclarationInstantiation
11
12 [...]
13 i. If varEnvRec is a global Environment Record, then
14 i. Perform ? varEnvRec.CreateGlobalVarBinding(F, true).
15 [...]
16
17 ---*/
18 Object.defineProperty(fnGlobalObject(), 'f', {
19 value: 'x',
20 enumerable: true,
21 writable: true,
22 configurable: false
23 });
24
25 eval(
26 'var global = fnGlobalObject();\
27 assert.sameValue(f, "x", "binding is not reinitialized");\
28 \
29 verifyProperty(global, "f", {\
30 enumerable: true,\
31 writable: true,\
32 configurable: false\
33 }, { restore: true });switch (1) {' +
34 ' default:' +
35 ' function f() { }' +
36 '}\
37 '
38 );
39
40 assert.sameValue(typeof f, "function");
41 verifyProperty(global, "f", {
42 enumerable: true,
43 writable: true,
44 configurable: false
45 });
46
47 reportCompare(0, 0);