Debian Codegraph @

js/src/tests/non262/class/outerBinding.js

raw
1 // |reftest| skip-if(!xulRuntime.shell)
2 //
3 // The above skip-if is because global lexicals aren't yet implemented. Remove
4 // that and the |evaluate| call below once they are.
5 //
6 // A class statement creates a mutable lexical outer binding.
7
8 class Foo { constructor() { } }
9 assertEq(typeof Foo, "function");
10 Foo = 5;
11 assertEq(Foo, 5);
12
13 {
14 class foo { constructor() { } }
15 assertEq(typeof foo, "function");
16 foo = 4;
17 assertEq(foo, 4);
18 }
19
20 {
21 class PermanentBinding { constructor() { } }
22 delete PermanentBinding;
23 // That...didn't actually work, right?
24 assertEq(typeof PermanentBinding, "function");
25 }
26
27 evaluate("const globalConstant = 0; var earlyError = true;");
28
29 try {
30 evaluate("earlyError = false; class globalConstant { constructor() { } }");
31 } catch (e) {
32 if (!(e instanceof SyntaxError))
33 throw e;
34 }
35 assertEq(earlyError, true);
36
37 function strictEvalShadows() {
38 "use strict";
39 let x = 4;
40 eval(`class x { constructor() { } }
41 assertEq(typeof x, "function");
42 `);
43 assertEq(x, 4);
44 }
45 strictEvalShadows()
46
47 if (typeof reportCompare === "function")
48 reportCompare(0, 0, "OK");