Update rustfmt

This commit is contained in:
강동윤 2019-10-19 12:21:56 +09:00
parent 6a7e229bbf
commit 01b1cc1a5e
10 changed files with 198 additions and 111 deletions

View File

@ -1,4 +1,4 @@
required_version = "1.4.8"
required_version = "1.4.9"
use_field_init_shorthand = true
merge_imports = true
wrap_comments = true

View File

@ -1557,7 +1557,11 @@ function () {
// regression_T6755
// get_set_memoized_update
test!(syntax(),|_| tr(), get_set_memoized_update, r#"
test!(
syntax(),
|_| tr(),
get_set_memoized_update,
r#"
class Base {}
Object.defineProperty(Base.prototype, 0, {
@ -1600,7 +1604,8 @@ expect(i).toBe(1);
expect(obj[0]).toBe(1);
expect(obj[1]).toBe(2);
"#, r#"
"#,
r#"
let Base = function Base() {
@ -1665,11 +1670,15 @@ expect(i).toBe(1);
expect(obj[0]).toBe(1);
expect(obj[1]).toBe(2);
"#);
"#
);
// spec_nested_class_super_property_in_key
test!(syntax(),|_| spec_tr(),
spec_nested_class_super_property_in_key, r#"
test!(
syntax(),
|_| spec_tr(),
spec_nested_class_super_property_in_key,
r#"
class Hello {
toString() {
@ -1692,7 +1701,8 @@ class Outer extends Hello {
expect(new Outer().hello()).toBe('hello');
"#, r#"
"#,
r#"
var Hello =
@ -1744,17 +1754,23 @@ function (_Hello) {
expect(new Outer().hello()).toBe('hello');
"#);
"#
);
// spec_super_reference_in_prop_exression
test!(syntax(),|_| spec_tr(), spec_super_reference_in_prop_exression, r#"
test!(
syntax(),
|_| spec_tr(),
spec_super_reference_in_prop_exression,
r#"
class Foo extends Bar {
constructor() {
super[super().method]();
}
}
"#, r#"
"#,
r#"
var Foo =
/*#__PURE__*/
function (_Bar) {
@ -1773,7 +1789,8 @@ function (_Bar) {
return Foo;
}(Bar);
"#);
"#
);
// spec_super_reference_before_in_lambda_exec
test_exec!(
@ -2219,7 +2236,11 @@ expect(() => {
// regression_2694
// regression_5769
test!(syntax(),|_| tr(), regression_5769, r#"
test!(
syntax(),
|_| tr(),
regression_5769,
r#"
class Point {
getX() {
expect(this.x).toBe(3); // C
@ -2243,7 +2264,8 @@ class ColorPoint extends Point {
const cp = new ColorPoint();
cp.m();
"#, r#"
"#,
r#"
let Point =
/*#__PURE__*/
function () {
@ -2295,7 +2317,8 @@ function (_Point) {
const cp = new ColorPoint();
cp.m();
"#);
"#
);
// spec_super_function_fallback
test!(
@ -3035,7 +3058,11 @@ function () {
);
// regression_T2997
test!(syntax(),|_| tr(), regression_t2997, r#"
test!(
syntax(),
|_| tr(),
regression_t2997,
r#"
class A {}
class B extends A {
@ -3044,7 +3071,8 @@ class B extends A {
}
}
"#, r#"
"#,
r#"
let A = function A() {
@ -3068,7 +3096,8 @@ function (_A) {
return B;
}(A);
"#);
"#
);
// spec_constructor_binding_collision
test!(
@ -3100,7 +3129,11 @@ var t = new Example();
);
// spec_super_class_anonymous
test!(syntax(),|_| spec_tr(), spec_super_class_anonymous, r#"
test!(
syntax(),
|_| spec_tr(),
spec_super_class_anonymous,
r#"
class TestEmpty extends (class {}) {
}
@ -3121,7 +3154,8 @@ class TestMultipleMethods extends (class {
m2() {}
}) {}
"#, r#"
"#,
r#"
var TestEmpty =
/*#__PURE__*/
function (_super) {
@ -3261,7 +3295,8 @@ function () {
return _class;
}());
"#);
"#
);
// spec_method_return_type_annotation
@ -3608,9 +3643,12 @@ function (_Bar) {
// spec_accessing_super_class
test!(
// TODO(kdy1): Unignore this.
ignore,
syntax(),|_| spec_tr(), spec_accessing_super_class, r#"
// TODO(kdy1): Unignore this.
ignore,
syntax(),
|_| spec_tr(),
spec_accessing_super_class,
r#"
class Test extends Foo {
constructor() {
woops.super.test();
@ -3637,7 +3675,8 @@ class Test extends Foo {
}
}
"#, r#"
"#,
r#"
var Test =
/*#__PURE__*/
function (_Foo) {
@ -3687,7 +3726,8 @@ function (_Foo) {
return Test;
}(Foo);
"#);
"#
);
// get_set_call_semantics_getter_defined_on_parent_exec
test_exec!(
@ -4532,7 +4572,11 @@ expect(obj.test).toBe(3);
// exec
// get_set_memoized_assign
test!(syntax(),|_| tr(), get_set_memoized_assign, r#"
test!(
syntax(),
|_| tr(),
get_set_memoized_assign,
r#"
class Base {}
Object.defineProperty(Base.prototype, 0, {
@ -4575,7 +4619,8 @@ expect(i).toBe(1);
expect(obj[0]).toBe(1);
expect(obj[1]).toBe(2);
"#, r#"
"#,
r#"
let Base = function Base() {
@ -4640,7 +4685,8 @@ expect(i).toBe(1);
expect(obj[0]).toBe(1);
expect(obj[1]).toBe(2);
"#);
"#
);
// extend_builtins_builtin_objects_throw_when_wrapped_exec
test_exec!(

View File

@ -93,7 +93,8 @@ var obj = (_obj = {}, _defineProperty(_obj, foobar, function () {
}), _obj);"#
);
test!(::swc_ecma_parser::Syntax::default(),
test!(
::swc_ecma_parser::Syntax::default(),
|_| ComputedProps,
mixed,
r#"var obj = {

View File

@ -103,7 +103,8 @@ var ref;
ref = [1, 2], x = ref[0], y = ref[1], ref;"#
);
test!(::swc_ecma_parser::Syntax::default(),
test!(
::swc_ecma_parser::Syntax::default(),
|_| tr(),
assign_expr_pat,
r#"var z = {};
@ -293,7 +294,8 @@ expect(a).toBe("a");
expect(rest).toEqual({});"#
);
test!(::swc_ecma_parser::Syntax::default(),
test!(
::swc_ecma_parser::Syntax::default(),
|_| tr(),
babel_issue_3081,
r#"let list = [1, 2, 3, 4];
@ -446,7 +448,8 @@ var ref = rect ? rect : _throw(new TypeError("Cannot destructure 'undefined' or
var ref3 = [0, 1, 2, 3, 4, 5, 6], foo = ref3[3], bar = ref3[5];"#
);
test!(::swc_ecma_parser::Syntax::default(),
test!(
::swc_ecma_parser::Syntax::default(),
|_| tr(),
object_basic,
r#"var coords = [1, 2];

View File

@ -280,15 +280,16 @@ test!(
"
);
test!(::swc_ecma_parser::Syntax::default(),
|_| tr(),
default_rest_1,
r#"const a = 1;
test!(
::swc_ecma_parser::Syntax::default(),
|_| tr(),
default_rest_1,
r#"const a = 1;
function rest(b = a, ...a) {
expect(b).toBe(1);
}
rest(undefined, 2)"#,
r#"var a = 1;
r#"var a = 1;
function rest(param) {
var b = param === void 0 ? a : param;
for(var _len = arguments.length, a1 = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
@ -299,15 +300,16 @@ function rest(param) {
rest(undefined, 2);"#
);
test!(::swc_ecma_parser::Syntax::default(),
|_| tr(),
default_rest_2,
r#"const a = 1;
test!(
::swc_ecma_parser::Syntax::default(),
|_| tr(),
default_rest_2,
r#"const a = 1;
function rest2(b = a, ...a) {
expect(a[0]).toBe(2);
}
rest2(undefined, 2);"#,
r#"var a = 1;
r#"var a = 1;
function rest2(param) {
var b = param === void 0 ? a : param;
for(var _len = arguments.length, a1 = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
@ -318,15 +320,16 @@ function rest2(param) {
rest2(undefined, 2);"#
);
test!(::swc_ecma_parser::Syntax::default(),
|_| tr(),
default_rest_3,
r#"const a = 1;
test!(
::swc_ecma_parser::Syntax::default(),
|_| tr(),
default_rest_3,
r#"const a = 1;
function rest3(b = a, ...a) {
expect(a).toHaveLength(1);
}
rest3(undefined, 2)"#,
r#"var a = 1;
r#"var a = 1;
function rest3(param) {
var b = param === void 0 ? a : param;
for(var _len = arguments.length, a1 = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
@ -486,10 +489,11 @@ let oneOf = function () {
};"#
);
test!(::swc_ecma_parser::Syntax::default(),
|_| tr(),
regression_5787,
r#"function f(a, ...rest) {
test!(
::swc_ecma_parser::Syntax::default(),
|_| tr(),
regression_5787,
r#"function f(a, ...rest) {
let b = rest[rest.length - 3];
let c = rest[rest.length - 2];
let d = rest[rest.length - 1];
@ -499,7 +503,7 @@ test!(::swc_ecma_parser::Syntax::default(),
function f(a, ...rest) {
return rest[-1];
}"#,
r#"function f(a) {
r#"function f(a) {
for(var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
rest[_key - 1] = arguments[_key];
}
@ -716,12 +720,12 @@ test!(
);
test!(
// optimiation is not implemented
ignore,
::swc_ecma_parser::Syntax::default(),
|_| tr(),
rest_deepest_common_ancestor_earliest_child,
r#"// single reference
// optimiation is not implemented
ignore,
::swc_ecma_parser::Syntax::default(),
|_| tr(),
rest_deepest_common_ancestor_earliest_child,
r#"// single reference
function r(...rest){
if (noNeedToWork) return 0;
return rest;
@ -795,7 +799,7 @@ function r(...rest){
[rest[0]] = x;
return rest;
}"#,
r#"// single reference
r#"// single reference
function r() {
if (noNeedToWork) return 0;
@ -913,10 +917,11 @@ function r() {
}"#
);
test!(::swc_ecma_parser::Syntax::default(),
|_| tr(),
rest_length,
r#"var t = function (f, ...items) {
test!(
::swc_ecma_parser::Syntax::default(),
|_| tr(),
rest_length,
r#"var t = function (f, ...items) {
items[0];
items[items.length - 1];
};
@ -926,7 +931,7 @@ function t(f, ...items) {
items[0];
items[items.length - 1];
}"#,
r#"var t = function(f) {
r#"var t = function(f) {
for(var _len = arguments.length, items = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
items[_key - 1] = arguments[_key];
}
@ -1073,10 +1078,11 @@ function t() {
}"#
);
test!(::swc_ecma_parser::Syntax::default(),
|_| tr(),
rest_multiple,
r#"var t = function (f, ...items) {
test!(
::swc_ecma_parser::Syntax::default(),
|_| tr(),
rest_multiple,
r#"var t = function (f, ...items) {
var x = f;
x = items[0];
x = items[1];
@ -1095,7 +1101,7 @@ function u(f, g, ...items) {
y.prop = items[1];
var z = items[2] | 0 || 12;
}"#,
r#"var t = function(f) {
r#"var t = function(f) {
for(var _len = arguments.length, items = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
items[_key - 1] = arguments[_key];
}

View File

@ -66,11 +66,11 @@ test!(
);
test!(
::swc_ecma_parser::Syntax::default(),
|_| TemplateLiteral::default(),
literals,
r#"var foo = `${1}${f}oo${true}${b}ar${0}${baz}`;"#,
r#"var foo = ''.concat(1).concat(f).concat('oo').concat(true).concat(b).concat('ar').concat(0).concat(baz);"#
::swc_ecma_parser::Syntax::default(),
|_| TemplateLiteral::default(),
literals,
r#"var foo = `${1}${f}oo${true}${b}ar${0}${baz}`;"#,
r#"var foo = ''.concat(1).concat(f).concat('oo').concat(true).concat(b).concat('ar').concat(0).concat(baz);"#
);
test!(

View File

@ -83,10 +83,11 @@ let TestClass = {
"#
);
test!(::swc_ecma_parser::Syntax::default(),
|_|tr(),
async_default_arguments,
r#"
test!(
::swc_ecma_parser::Syntax::default(),
|_| tr(),
async_default_arguments,
r#"
function mandatory(paramName) {
throw new Error(`Missing parameter: ${paramName}`);
}
@ -95,7 +96,7 @@ async function foo({ a, b = mandatory("b") }) {
return Promise.resolve(b);
}
"#,
r#"
r#"
function mandatory(paramName) {
throw new Error(`Missing parameter: ${paramName}`);
}
@ -174,10 +175,11 @@ class Foo {
"#
);
test!(::swc_ecma_parser::Syntax::default(),
|_|tr(),
deeply_nested_asyncs,
r#"
test!(
::swc_ecma_parser::Syntax::default(),
|_| tr(),
deeply_nested_asyncs,
r#"
async function s(x, ...args) {
let t = async (y, a) => {
let r = async (z, b, ...innerArgs) => {
@ -195,7 +197,7 @@ async function s(x, ...args) {
return this.h(t);
}
"#,
r#"
r#"
function _s() {
_s = _asyncToGenerator((function*(x) {
for(let _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
@ -282,10 +284,11 @@ var foo2 = function () {
}();"#
);
test!(::swc_ecma_parser::Syntax::default(),
|_|tr(),
function_arity,
r#"
test!(
::swc_ecma_parser::Syntax::default(),
|_| tr(),
function_arity,
r#"
async function one(a, b = 1) {}
async function two(a, b, ...c) {}
async function three(a, b = 1, c, d = 3) {}
@ -293,7 +296,7 @@ async function four(a, b = 1, c, ...d) {}
async function five(a, {b}){}
async function six(a, {b} = {}){}
"#,
r#"
r#"
function _one() {
_one = _asyncToGenerator(function*(a, param) {
let b = param === void 0 ? 1 : param;
@ -475,17 +478,18 @@ class Class{
"#
);
test!(::swc_ecma_parser::Syntax::default(),
|_|tr(),
object_method_with_super,
r#"class Foo extends class {} {
test!(
::swc_ecma_parser::Syntax::default(),
|_| tr(),
object_method_with_super,
r#"class Foo extends class {} {
async method() {
super.method();
var arrow = () => super.method();
}
}"#,
r#"
r#"
class Foo extends class{
}{
method() {

View File

@ -841,7 +841,11 @@ function () {
"#
);
test!(syntax(), |_| tr(), public_super_call, r#"
test!(
syntax(),
|_| tr(),
public_super_call,
r#"
class A {
foo() {
return "bar";
@ -852,7 +856,8 @@ class B extends A {
foo = super.foo();
}
"#, r#"
"#,
r#"
var A =
/*#__PURE__*/
function () {
@ -890,7 +895,8 @@ function (_A) {
return B;
}(A);
"#);
"#
);
test!(
syntax(),
@ -1420,7 +1426,11 @@ var _outer = new WeakMap();
"#
);
test!(syntax(), |_| tr(), private_update, r#"
test!(
syntax(),
|_| tr(),
private_update,
r#"
class Foo {
#foo = 0;
@ -1432,7 +1442,8 @@ class Foo {
}
}
"#, r#"
"#,
r#"
var Foo =
/*#__PURE__*/
function () {
@ -1463,9 +1474,14 @@ function () {
var _foo = new WeakMap();
"#);
"#
);
test!(syntax(), |_| tr(), public_super_expression, r#"
test!(
syntax(),
|_| tr(),
public_super_expression,
r#"
class Foo extends Bar {
bar = "foo";
@ -1474,7 +1490,8 @@ class Foo extends Bar {
}
}
"#, r#"
"#,
r#"
var Foo = function (_Bar) {
@ -1492,7 +1509,8 @@ var Foo = function (_Bar) {
return Foo;
}(Bar);
"#);
"#
);
test_exec!(
syntax(),
@ -1805,7 +1823,11 @@ var _four = new WeakMap();
"#
);
test!(syntax(), |_| tr(), nested_class_super_property_in_key, r#"
test!(
syntax(),
|_| tr(),
nested_class_super_property_in_key,
r#"
class Hello {
toString() {
@ -1826,7 +1848,8 @@ class Outer extends Hello {
expect(new Outer().hello).toBe('hello');
"#, r#"
"#,
r#"
var Hello = function () {
@ -1865,7 +1888,8 @@ var Outer = function (_Hello) {
expect(new Outer().hello).toBe('hello');
"#);
"#
);
test_exec!(
syntax(),

View File

@ -249,7 +249,10 @@ var Component = React.createClass({
);
test!(
::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig{jsx:true,..Default::default()}),
::swc_ecma_parser::Syntax::Es(::swc_ecma_parser::EsConfig {
jsx: true,
..Default::default()
}),
|_| tr(Default::default()),
react_dont_coerce_expression_containers,
r#"

View File

@ -450,8 +450,8 @@ to!(
);
to!(
class_nested,
r#"
class_nested,
r#"
var Outer = function(_Hello) {
_inherits(Outer, _Hello);
function Outer() {
@ -473,7 +473,7 @@ var Outer = function(_Hello) {
return Outer;
}(Hello);
"#,
r#"
r#"
var Outer = function(_Hello) {
_inherits(Outer, _Hello);
function Outer() {
@ -495,7 +495,7 @@ var Outer = function(_Hello) {
return Outer;
}(Hello);
"#
);
);
identical!(class_var_constructor_only, r#"var Foo = function Foo(){}"#);