blob: 54032b03ff8f9113a3117668c50f8308bf6bbb68 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
// Static field initialisers can access the inner name binding for class definitions.
{
class C {
static field = C;
}
assertEq(C.field, C);
}
{
let C = class Inner {
static field = Inner;
};
assertEq(C.field, C);
}
// Static field initialisers can't access the outer name binding for class expressions
// before it has been initialised.
{
assertThrowsInstanceOf(() => {
let C = class {
static field = C;
};
}, ReferenceError);
}
// Static field initialisers can access the outer name binding for class expressions after
// the binding has been initialised
{
let C = class {
static field = () => C;
};
assertEq(C.field(), C);
}
// Static field initialiser expressions always resolve the inner name binding.
{
class C {
static field = () => C;
}
assertEq(C.field(), C);
const D = C;
C = null;
assertEq(D.field(), D);
}
{
let C = class Inner {
static field = () => Inner;
}
assertEq(C.field(), C);
const D = C;
C = null;
assertEq(D.field(), D);
}
if (typeof reportCompare === "function")
reportCompare(true, true);
|