Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(es/typescript): Migrate inline tests to fixture tests (#6546)
- Loading branch information
Showing
28 changed files
with
101 additions
and
164 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
crates/swc_ecma_transforms_typescript/tests/fixture/constructor-1/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Foo { | ||
constructor(public readonly foo) { } | ||
} |
5 changes: 5 additions & 0 deletions
5
crates/swc_ecma_transforms_typescript/tests/fixture/constructor-1/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Foo { | ||
constructor(foo){ | ||
this.foo = foo; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
crates/swc_ecma_transforms_typescript/tests/fixture/constructor-2/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Foo { | ||
constructor(readonly foo) { | ||
this.bar = 1; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
crates/swc_ecma_transforms_typescript/tests/fixture/constructor-2/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Foo { | ||
constructor(foo){ | ||
this.foo = foo; | ||
this.bar = 1; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_transforms_typescript/tests/fixture/export-equals/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export = Foo |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_transforms_typescript/tests/fixture/export-equals/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = Foo; |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_transforms_typescript/tests/fixture/export-import/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export import A = B |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_transforms_typescript/tests/fixture/export-import/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export var A = B; |
2 changes: 2 additions & 0 deletions
2
crates/swc_ecma_transforms_typescript/tests/fixture/issue-179/1/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import { Types } from 'other'; | ||
const a: Types.foo = {}; |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_transforms_typescript/tests/fixture/issue-179/1/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
const a = {}; |
2 changes: 2 additions & 0 deletions
2
crates/swc_ecma_transforms_typescript/tests/fixture/issue-179/2/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import { Types } from 'other'; | ||
const a: Types = Types.foo; |
2 changes: 2 additions & 0 deletions
2
crates/swc_ecma_transforms_typescript/tests/fixture/issue-179/2/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import { Types } from 'other'; | ||
const a = Types.foo; |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_transforms_typescript/tests/fixture/issue-196/1/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type Link = { key: string; text: string }; |
2 changes: 2 additions & 0 deletions
2
crates/swc_ecma_transforms_typescript/tests/fixture/issue-196/2/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
type Link = { key: string; text: string }; | ||
export { Link } |
3 changes: 3 additions & 0 deletions
3
crates/swc_ecma_transforms_typescript/tests/fixture/issue-196/3/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
type Link = { key: string; text: string }; | ||
const Link = 'Boo'; | ||
export { Link } |
2 changes: 2 additions & 0 deletions
2
crates/swc_ecma_transforms_typescript/tests/fixture/issue-196/3/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const Link = 'Boo'; | ||
export { Link }; |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_transforms_typescript/tests/fixture/issue-236/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
function foo(this: any, $scope: angular.IScope) { } |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_transforms_typescript/tests/fixture/issue-236/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
function foo($scope) {} |
23 changes: 23 additions & 0 deletions
23
crates/swc_ecma_transforms_typescript/tests/fixture/issue-357/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export function addProp<T, K extends string, V>( | ||
obj: T, | ||
prop: K, | ||
value: V | ||
): T & { [x in K]: V }; | ||
export function addProp<T, K extends string, V>( | ||
prop: K, | ||
value: V | ||
): (obj: T) => T & { [x in K]: V }; | ||
|
||
export function addProp(arg1: any, arg2: any, arg3?: any): any { | ||
if (arguments.length === 2) { | ||
return (object: any) => _addProp(object, arg1, arg2); | ||
} | ||
return _addProp(arg1, arg2, arg3); | ||
} | ||
|
||
function _addProp(obj: any, prop: string, value: any) { | ||
return { | ||
...obj, | ||
[prop]: value, | ||
}; | ||
} |
12 changes: 12 additions & 0 deletions
12
crates/swc_ecma_transforms_typescript/tests/fixture/issue-357/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export function addProp(arg1, arg2, arg3) { | ||
if (arguments.length === 2) { | ||
return (object)=>_addProp(object, arg1, arg2); | ||
} | ||
return _addProp(arg1, arg2, arg3); | ||
} | ||
function _addProp(obj, prop, value) { | ||
return { | ||
...obj, | ||
[prop]: value | ||
}; | ||
} |
5 changes: 5 additions & 0 deletions
5
crates/swc_ecma_transforms_typescript/tests/fixture/issue-366/1/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class App { | ||
public enter?(): void; | ||
public leave?(): void; | ||
public destroy?(): void; | ||
} |
2 changes: 2 additions & 0 deletions
2
crates/swc_ecma_transforms_typescript/tests/fixture/issue-366/1/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class App { | ||
} |
2 changes: 2 additions & 0 deletions
2
crates/swc_ecma_transforms_typescript/tests/fixture/issue-366/2/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
function enter(): string; | ||
function enter(foo: string): number; |
2 changes: 2 additions & 0 deletions
2
crates/swc_ecma_transforms_typescript/tests/fixture/issue-392/1/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import { PlainObject } from 'simplytyped'; | ||
const dict: PlainObject = {}; |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_transforms_typescript/tests/fixture/issue-392/1/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
const dict = {}; |
7 changes: 7 additions & 0 deletions
7
...wc_ecma_transforms_typescript/tests/fixture/private-method-overload-and-abstract/input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class test { | ||
#test(); | ||
#test() { | ||
} | ||
|
||
abstract #test(); | ||
} |
7 changes: 7 additions & 0 deletions
7
...c_ecma_transforms_typescript/tests/fixture/private-method-overload-and-abstract/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
var _test = /*#__PURE__*/ new WeakSet(); | ||
class test { | ||
constructor(){ | ||
_classPrivateMethodInit(this, _test); | ||
} | ||
} | ||
function test1() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cddbc41
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark
es/full/bugs-1
357309
ns/iter (± 42612
)345379
ns/iter (± 19869
)1.03
es/full/minify/libraries/antd
2077536687
ns/iter (± 67923863
)2067926065
ns/iter (± 69608197
)1.00
es/full/minify/libraries/d3
473800111
ns/iter (± 22983792
)515100103
ns/iter (± 159883441
)0.92
es/full/minify/libraries/echarts
1783899413
ns/iter (± 67617315
)1727549861
ns/iter (± 35722394
)1.03
es/full/minify/libraries/jquery
119025358
ns/iter (± 5082943
)118750879
ns/iter (± 5371722
)1.00
es/full/minify/libraries/lodash
137572892
ns/iter (± 4873905
)136956724
ns/iter (± 5420934
)1.00
es/full/minify/libraries/moment
65181397
ns/iter (± 2667553
)68490361
ns/iter (± 4232130
)0.95
es/full/minify/libraries/react
21820783
ns/iter (± 854899
)22436171
ns/iter (± 499643
)0.97
es/full/minify/libraries/terser
329186904
ns/iter (± 8615949
)365293069
ns/iter (± 14711338
)0.90
es/full/minify/libraries/three
624939548
ns/iter (± 12800053
)639076054
ns/iter (± 19203904
)0.98
es/full/minify/libraries/typescript
3750427652
ns/iter (± 73500617
)3847128151
ns/iter (± 42332388
)0.97
es/full/minify/libraries/victory
918989931
ns/iter (± 21850076
)925779231
ns/iter (± 22076710
)0.99
es/full/minify/libraries/vue
167528419
ns/iter (± 3932427
)178761656
ns/iter (± 6776693
)0.94
es/full/codegen/es3
34336
ns/iter (± 4164
)33356
ns/iter (± 1373
)1.03
es/full/codegen/es5
34840
ns/iter (± 3295
)33108
ns/iter (± 1359
)1.05
es/full/codegen/es2015
34185
ns/iter (± 2814
)33108
ns/iter (± 3263
)1.03
es/full/codegen/es2016
33920
ns/iter (± 3885
)33009
ns/iter (± 990
)1.03
es/full/codegen/es2017
34273
ns/iter (± 4906
)33031
ns/iter (± 1560
)1.04
es/full/codegen/es2018
34231
ns/iter (± 4051
)33031
ns/iter (± 1007
)1.04
es/full/codegen/es2019
33763
ns/iter (± 2550
)32954
ns/iter (± 830
)1.02
es/full/codegen/es2020
33737
ns/iter (± 1466
)33063
ns/iter (± 672
)1.02
es/full/all/es3
191663114
ns/iter (± 7710674
)195779380
ns/iter (± 10953299
)0.98
es/full/all/es5
187798717
ns/iter (± 11183553
)183610269
ns/iter (± 7889693
)1.02
es/full/all/es2015
151273374
ns/iter (± 12003133
)145884702
ns/iter (± 9063866
)1.04
es/full/all/es2016
146991801
ns/iter (± 6603391
)146264699
ns/iter (± 11150302
)1.00
es/full/all/es2017
144998175
ns/iter (± 6535093
)145117573
ns/iter (± 8081251
)1.00
es/full/all/es2018
138639213
ns/iter (± 4664425
)142505110
ns/iter (± 9325968
)0.97
es/full/all/es2019
138025344
ns/iter (± 4413714
)141478102
ns/iter (± 7693168
)0.98
es/full/all/es2020
139384393
ns/iter (± 6558169
)136921200
ns/iter (± 7734753
)1.02
es/full/parser
744675
ns/iter (± 80722
)718935
ns/iter (± 39841
)1.04
es/full/base/fixer
26915
ns/iter (± 1723
)26086
ns/iter (± 1585
)1.03
es/full/base/resolver_and_hygiene
92901
ns/iter (± 5656
)92031
ns/iter (± 5672
)1.01
serialization of ast node
213
ns/iter (± 17
)205
ns/iter (± 9
)1.04
serialization of serde
229
ns/iter (± 31
)221
ns/iter (± 9
)1.04
This comment was automatically generated by workflow using github-action-benchmark.