-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**Related issue:** - babel/babel#12664
- Loading branch information
1 parent
ed64833
commit a912937
Showing
16 changed files
with
110 additions
and
76 deletions.
There are no files selected for viewing
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
22 changes: 22 additions & 0 deletions
22
crates/swc_ecma_transforms_compat/tests/es2015_shorthand_propertie.rs
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,22 @@ | ||
use std::path::PathBuf; | ||
|
||
use swc_common::{chain, Mark}; | ||
use swc_ecma_transforms_base::resolver; | ||
use swc_ecma_transforms_compat::es2015::shorthand; | ||
use swc_ecma_transforms_testing::test_fixture; | ||
|
||
#[testing::fixture("tests/shorthand_properties/**/input.js")] | ||
fn fixture(input: PathBuf) { | ||
let output = input.with_file_name("output.js"); | ||
|
||
test_fixture( | ||
Default::default(), | ||
&|_| { | ||
let unresolved_mark = Mark::new(); | ||
chain!(resolver(unresolved_mark, Mark::new(), false), shorthand()) | ||
}, | ||
&input, | ||
&output, | ||
Default::default(), | ||
); | ||
} |
6 changes: 6 additions & 0 deletions
6
...s/swc_ecma_transforms_compat/tests/shorthand_properties/.method-type-annotations/input.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 @@ | ||
// @flow | ||
var obj = { | ||
method(a: string): number { | ||
return 5 + 5; | ||
} | ||
}; |
6 changes: 6 additions & 0 deletions
6
.../swc_ecma_transforms_compat/tests/shorthand_properties/.method-type-annotations/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 @@ | ||
// @flow | ||
var obj = { | ||
method: function (a: string): number { | ||
return 5 + 5; | ||
} | ||
}; |
5 changes: 5 additions & 0 deletions
5
crates/swc_ecma_transforms_compat/tests/shorthand_properties/method-plain/input.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 @@ | ||
var obj = { | ||
method() { | ||
return 5 + 5; | ||
} | ||
}; |
5 changes: 5 additions & 0 deletions
5
crates/swc_ecma_transforms_compat/tests/shorthand_properties/method-plain/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 @@ | ||
var obj = { | ||
method: function () { | ||
return 5 + 5; | ||
} | ||
}; |
7 changes: 7 additions & 0 deletions
7
crates/swc_ecma_transforms_compat/tests/shorthand_properties/proto/input.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 shorthand = { | ||
__proto__, | ||
} | ||
|
||
var method = { | ||
__proto__() {} | ||
} |
6 changes: 6 additions & 0 deletions
6
crates/swc_ecma_transforms_compat/tests/shorthand_properties/proto/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 @@ | ||
var shorthand = { | ||
["__proto__"]: __proto__ | ||
}; | ||
var method = { | ||
["__proto__"]: function () {} | ||
}; |
4 changes: 4 additions & 0 deletions
4
crates/swc_ecma_transforms_compat/tests/shorthand_properties/shorthand-comments/input.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,4 @@ | ||
var A = "a"; | ||
var o = { | ||
A // comment | ||
}; |
4 changes: 4 additions & 0 deletions
4
crates/swc_ecma_transforms_compat/tests/shorthand_properties/shorthand-comments/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,4 @@ | ||
var A = "a"; | ||
var o = { | ||
A: A // comment | ||
}; |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_transforms_compat/tests/shorthand_properties/shorthand-mixed/input.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 @@ | ||
var coords = { x, y, foo: "bar" }; |
5 changes: 5 additions & 0 deletions
5
crates/swc_ecma_transforms_compat/tests/shorthand_properties/shorthand-mixed/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 @@ | ||
var coords = { | ||
x: x, | ||
y: y, | ||
foo: "bar" | ||
}; |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_transforms_compat/tests/shorthand_properties/shorthand-multiple/input.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 @@ | ||
var coords = { x, y }; |
4 changes: 4 additions & 0 deletions
4
crates/swc_ecma_transforms_compat/tests/shorthand_properties/shorthand-multiple/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,4 @@ | ||
var coords = { | ||
x: x, | ||
y: y | ||
}; |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_transforms_compat/tests/shorthand_properties/shorthand-single/input.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 @@ | ||
var coords = { x }; |
3 changes: 3 additions & 0 deletions
3
crates/swc_ecma_transforms_compat/tests/shorthand_properties/shorthand-single/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,3 @@ | ||
var coords = { | ||
x: x | ||
}; |
a912937
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
288912
ns/iter (± 6903
)283859
ns/iter (± 5198
)1.02
es/full/minify/libraries/antd
1418839549
ns/iter (± 16816020
)1336899744
ns/iter (± 8418434
)1.06
es/full/minify/libraries/d3
298145181
ns/iter (± 3182837
)291136349
ns/iter (± 2826509
)1.02
es/full/minify/libraries/echarts
1140048154
ns/iter (± 16732217
)1082305373
ns/iter (± 4216008
)1.05
es/full/minify/libraries/jquery
89077699
ns/iter (± 874779
)87832596
ns/iter (± 170685
)1.01
es/full/minify/libraries/lodash
103596015
ns/iter (± 858063
)102286359
ns/iter (± 753320
)1.01
es/full/minify/libraries/moment
52421188
ns/iter (± 229780
)51871807
ns/iter (± 207893
)1.01
es/full/minify/libraries/react
18792450
ns/iter (± 56670
)18695417
ns/iter (± 92713
)1.01
es/full/minify/libraries/terser
231040948
ns/iter (± 1804258
)227396645
ns/iter (± 2358048
)1.02
es/full/minify/libraries/three
413091017
ns/iter (± 3028383
)399928348
ns/iter (± 2920127
)1.03
es/full/minify/libraries/typescript
2852726572
ns/iter (± 21325554
)2716173899
ns/iter (± 11057911
)1.05
es/full/minify/libraries/victory
616232395
ns/iter (± 5986436
)581697770
ns/iter (± 5536501
)1.06
es/full/minify/libraries/vue
127638514
ns/iter (± 1833582
)124649384
ns/iter (± 358184
)1.02
es/full/codegen/es3
34187
ns/iter (± 80
)33751
ns/iter (± 98
)1.01
es/full/codegen/es5
34181
ns/iter (± 74
)33776
ns/iter (± 123
)1.01
es/full/codegen/es2015
34288
ns/iter (± 61
)33855
ns/iter (± 112
)1.01
es/full/codegen/es2016
34253
ns/iter (± 161
)33862
ns/iter (± 122
)1.01
es/full/codegen/es2017
34209
ns/iter (± 123
)33904
ns/iter (± 95
)1.01
es/full/codegen/es2018
34223
ns/iter (± 58
)33810
ns/iter (± 109
)1.01
es/full/codegen/es2019
34207
ns/iter (± 283
)33723
ns/iter (± 104
)1.01
es/full/codegen/es2020
34176
ns/iter (± 94
)33693
ns/iter (± 94
)1.01
es/full/all/es3
176962505
ns/iter (± 839106
)176662543
ns/iter (± 1166046
)1.00
es/full/all/es5
169354009
ns/iter (± 1373011
)169575561
ns/iter (± 1173449
)1.00
es/full/all/es2015
128041413
ns/iter (± 1333296
)128765636
ns/iter (± 989201
)0.99
es/full/all/es2016
128136684
ns/iter (± 1048898
)128022097
ns/iter (± 818210
)1.00
es/full/all/es2017
127659000
ns/iter (± 1031554
)127640494
ns/iter (± 2910808
)1.00
es/full/all/es2018
125583867
ns/iter (± 1362918
)125620409
ns/iter (± 1131352
)1.00
es/full/all/es2019
124405072
ns/iter (± 705511
)124259384
ns/iter (± 710201
)1.00
es/full/all/es2020
120956954
ns/iter (± 720919
)120242153
ns/iter (± 1278410
)1.01
es/full/parser
566851
ns/iter (± 3523
)557701
ns/iter (± 3738
)1.02
es/full/base/fixer
18242
ns/iter (± 112
)19386
ns/iter (± 219
)0.94
es/full/base/resolver_and_hygiene
84320
ns/iter (± 213
)84184
ns/iter (± 232
)1.00
This comment was automatically generated by workflow using github-action-benchmark.