Pewarta Proxy

📋 Server Request & Proxy Logs

Loading active proxy settings...
Developed by Khairul Adha (adhexa.id)
Mengambil log server...

⚙️ Pengaturan Proxy Target

Skip to content

Commit 7e1096f

Browse files
JLHwungnicolo-ribaudo
authored andcommitted
test: add replacement-static-decorator-initializer-this test (#16288)
1 parent 2c8f3c1 commit 7e1096f

5 files changed

Lines changed: 185 additions & 0 deletions

File tree

  • packages/babel-plugin-proposal-decorators/test/fixtures
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
let original, replaced, accessorThis, getterThis, setterThis, methodThis, propertyThis;
3+
4+
function dec(Klass) {
5+
original = Klass;
6+
replaced = class extends Klass {};
7+
8+
return replaced;
9+
}
10+
11+
function captureInitializerThis(callback) {
12+
return function (_, context) {
13+
context.addInitializer(function () {
14+
callback(this);
15+
})
16+
}
17+
}
18+
19+
@dec
20+
class Foo {
21+
@(captureInitializerThis(v => accessorThis = v))
22+
static accessor;
23+
@(captureInitializerThis(v => getterThis = v))
24+
static get getter() {};
25+
@(captureInitializerThis(v => setterThis = v))
26+
static set setter(_) {};
27+
@(captureInitializerThis(v => methodThis = v))
28+
static method() {}
29+
@(captureInitializerThis(v => propertyThis = v))
30+
static property;
31+
}
32+
33+
expect(getterThis).toBe(original);
34+
expect(setterThis).toBe(original);
35+
expect(methodThis).toBe(original);
36+
37+
expect(accessorThis).toBe(replaced);
38+
expect(propertyThis).toBe(replaced);
39+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
let original, replaced, accessorThis, getterThis, setterThis, methodThis, propertyThis;
3+
4+
function dec(Klass) {
5+
original = Klass;
6+
replaced = class extends Klass {};
7+
8+
return replaced;
9+
}
10+
11+
function captureInitializerThis(callback) {
12+
return function (_, context) {
13+
context.addInitializer(function () {
14+
callback(this);
15+
})
16+
}
17+
}
18+
19+
@dec
20+
class Foo {
21+
@(captureInitializerThis(v => accessorThis = v))
22+
static accessor;
23+
@(captureInitializerThis(v => getterThis = v))
24+
static get getter() {};
25+
@(captureInitializerThis(v => setterThis = v))
26+
static set setter(_) {};
27+
@(captureInitializerThis(v => methodThis = v))
28+
static method() {}
29+
@(captureInitializerThis(v => propertyThis = v))
30+
static property;
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
var _initStatic, _initClass, _accessorDecs, _init_accessor, _init_extra_accessor, _getterDecs, _setterDecs, _methodDecs, _propertyDecs, _init_property, _init_extra_property, _temp;
2+
let original, replaced, accessorThis, getterThis, setterThis, methodThis, propertyThis;
3+
function dec(Klass) {
4+
original = Klass;
5+
replaced = class extends Klass {};
6+
return replaced;
7+
}
8+
function captureInitializerThis(callback) {
9+
return function (_, context) {
10+
context.addInitializer(function () {
11+
callback(this);
12+
});
13+
};
14+
}
15+
_accessorDecs = captureInitializerThis(v => accessorThis = v);
16+
_getterDecs = captureInitializerThis(v => getterThis = v);
17+
_setterDecs = captureInitializerThis(v => setterThis = v);
18+
_methodDecs = captureInitializerThis(v => methodThis = v);
19+
_propertyDecs = captureInitializerThis(v => propertyThis = v);
20+
let _Foo;
21+
new (_temp = class extends babelHelpers.identity {
22+
constructor() {
23+
(super(_Foo), babelHelpers.defineProperty(this, "accessor", _init_accessor(this)), babelHelpers.defineProperty(this, "property", (_init_extra_accessor(this), _init_property(this)))), (() => {
24+
_init_extra_property(this);
25+
})(), _initClass();
26+
}
27+
}, (_Foo2 => {
28+
class Foo {
29+
static get getter() {}
30+
static set setter(_) {}
31+
static method() {}
32+
}
33+
_Foo2 = Foo;
34+
(() => {
35+
({
36+
e: [_init_accessor, _init_extra_accessor, _init_property, _init_extra_property, _initStatic],
37+
c: [_Foo, _initClass]
38+
} = babelHelpers.applyDecs2311(_Foo2, [[_getterDecs, 11, "getter"], [_setterDecs, 12, "setter"], [_methodDecs, 10, "method"], [_accessorDecs, 8, "accessor"], [_propertyDecs, 8, "property"]], [dec]));
39+
_initStatic(_Foo2);
40+
})();
41+
})(), _temp)();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
let original, replaced, accessorThis, getterThis, setterThis, methodThis, propertyThis;
3+
4+
function dec(Klass) {
5+
original = Klass;
6+
replaced = class extends Klass {};
7+
8+
return replaced;
9+
}
10+
11+
function captureInitializerThis(callback) {
12+
return function (_, context) {
13+
context.addInitializer(function () {
14+
callback(this);
15+
})
16+
}
17+
}
18+
19+
@dec
20+
class Foo {
21+
@(captureInitializerThis(v => accessorThis = v))
22+
static accessor;
23+
@(captureInitializerThis(v => getterThis = v))
24+
static get getter() {};
25+
@(captureInitializerThis(v => setterThis = v))
26+
static set setter(_) {};
27+
@(captureInitializerThis(v => methodThis = v))
28+
static method() {}
29+
@(captureInitializerThis(v => propertyThis = v))
30+
static property;
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
var _initStatic, _initClass, _accessorDecs, _init_accessor, _init_extra_accessor, _getterDecs, _setterDecs, _methodDecs, _propertyDecs, _init_property, _init_extra_property;
2+
let original, replaced, accessorThis, getterThis, setterThis, methodThis, propertyThis;
3+
function dec(Klass) {
4+
original = Klass;
5+
replaced = class extends Klass {};
6+
return replaced;
7+
}
8+
function captureInitializerThis(callback) {
9+
return function (_, context) {
10+
context.addInitializer(function () {
11+
callback(this);
12+
});
13+
};
14+
}
15+
_accessorDecs = captureInitializerThis(v => accessorThis = v);
16+
_getterDecs = captureInitializerThis(v => getterThis = v);
17+
_setterDecs = captureInitializerThis(v => setterThis = v);
18+
_methodDecs = captureInitializerThis(v => methodThis = v);
19+
_propertyDecs = captureInitializerThis(v => propertyThis = v);
20+
let _Foo;
21+
new class extends babelHelpers.identity {
22+
static {
23+
class Foo {
24+
static {
25+
({
26+
e: [_init_accessor, _init_extra_accessor, _init_property, _init_extra_property, _initStatic],
27+
c: [_Foo, _initClass]
28+
} = babelHelpers.applyDecs2311(this, [[_getterDecs, 11, "getter"], [_setterDecs, 12, "setter"], [_methodDecs, 10, "method"], [_accessorDecs, 8, "accessor"], [_propertyDecs, 8, "property"]], [dec]));
29+
_initStatic(this);
30+
}
31+
static get getter() {}
32+
static set setter(_) {}
33+
static method() {}
34+
}
35+
}
36+
accessor = _init_accessor(this);
37+
property = (_init_extra_accessor(this), _init_property(this));
38+
constructor() {
39+
super(_Foo), (() => {
40+
_init_extra_property(this);
41+
})(), _initClass();
42+
}
43+
}();

0 commit comments

Comments
 (0)