Add tests for #169.

This commit is contained in:
강동윤 2019-02-12 22:18:14 +09:00
parent 17d87e3ce5
commit cc36bbe3ad
2 changed files with 57 additions and 0 deletions

View File

@ -58,3 +58,38 @@ pub fn es2015() -> impl Pass + Clone {
block_scoping(),
)
}
#[cfg(test)]
mod tests {
use super::es2015;
test!(
::swc_ecma_parser::Syntax::default(),
|_| es2015(),
issue_169,
r#"
class Foo {
func(a, b = Date.now()) {
return {a};
}
}
"#,
r#"
var Foo = function() {
var Foo = function Foo() {
_classCallCheck(this, Foo);
};
_createClass(Foo, [{
key: 'func',
value: function func(a, param) {
var tmp = param, b = tmp === void 0 ? Date.now() : tmp;
return {
a: a
};
}
}]);
return Foo;
}();
"#
);
}

View File

@ -10,6 +10,28 @@ fn tr() -> impl Fold<Module> {
)
}
test!(
::swc_ecma_parser::Syntax::default(),
|_| tr(),
issue_169,
r#"
class Foo {
func(a, b = Date.now()) {
return {a};
}
}
"#,
r#"
class Foo{
func(a, param) {
var tmp = param, b = tmp === void 0 ? Date.now() : tmp;
return {
a
};
}
}"#
);
test!(
::swc_ecma_parser::Syntax::default(),
|_| tr(),