fix this in async generator (#425)

swc_ecma_transforms:
 - Don't delete test file when an execution test fails
 - fix #400
This commit is contained in:
강동윤 2019-10-01 23:42:05 +09:00 committed by GitHub
parent d7d22c2d5e
commit 3a637d4229
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 175 additions and 2 deletions

View File

@ -193,4 +193,92 @@ export var getBadgeBorderRadius = function(text, color) {
"#
);
test!(
::swc_ecma_parser::Syntax::default(),
|_| es2015(),
issue_400_1,
"class A {
constructor() {
this.a_num = 10;
}
print() {
expect(this.a_num).toBe(10);
}
}
class B extends A {
constructor(num) {
super();
this.b_num = num;
}
print() {
expect(this.b_num).toBe(20);
super.print();
}
}
",
"var A = function() {
function A() {
_classCallCheck(this, A);
this.a_num = 10;
}
_createClass(A, [{
key: 'print',
value: function print() {
expect(this.a_num).toBe(10);
}
}]);
return A;
}();
var B = function(_A) {
_inherits(B, _A);
function B(num) {
var _this;
_classCallCheck(this, B);
_this = _possibleConstructorReturn(this, _getPrototypeOf(B).call(this));
_this.b_num = num;
return _this;
}
_createClass(B, [{
key: 'print',
value: function print() {
expect(this.b_num).toBe(20);
_get(_getPrototypeOf(B.prototype), 'print', this).call(this);
}
}]);
return B;
}(A);"
);
test_exec!(
::swc_ecma_parser::Syntax::default(),
|_| es2015(),
issue_400_2,
"class A {
constructor() {
this.a_num = 10;
}
print() {
expect(this.a_num).toBe(10);
}
}
class B extends A {
constructor(num) {
super();
this.b_num = num;
}
print() {
expect(this.b_num).toBe(20);
super.print();
}
}
return new B(20).print()"
);
}

View File

@ -134,7 +134,15 @@ impl Fold<Expr> for ActualFolder {
}),
)
}
_ => (undefined(callee.span()), callee),
// https://github.com/swc-project/swc/issues/400
// _ => (undefined(callee.span()), callee),
_ => (
box Expr::This(ThisExpr {
span: callee.span(),
}),
callee,
),
};
let args_array = concat_args(span, args.into_iter().map(Some), false);

View File

@ -1,6 +1,6 @@
use super::*;
use crate::{
compat::es2015::{arrow, destructuring, function_name, parameters},
compat::es2015::{arrow, destructuring, es2015, function_name, parameters},
fixer::fixer,
};
@ -715,3 +715,79 @@ test!(
});
"
);
test_exec!(
::swc_ecma_parser::Syntax::default(),
|_| chain_at!(Module, tr(), es2015()),
issue_400_1,
"class A {
constructor() {
this.a_num = 10;
}
async print() {
expect(this.a_num).toBe(10);
}
}
class B extends A {
constructor(num) {
super();
this.b_num = num;
}
async print() {
expect(this.b_num).toBe(20);
await super.print();
}
}
return (new B(20)).print().then(() => console.log('Done'));"
);
test_exec!(
::swc_ecma_parser::Syntax::default(),
|_| AsyncToGenerator,
issue_400_2,
"class A {
constructor() {
this.a_num = 10;
}
async print() {
expect(this.a_num).toBe(10);
}
}
class B extends A {
constructor(num) {
super();
this.b_num = num;
}
async print() {
expect(this.b_num).toBe(20);
await super.print();
}
}
return (new B(20)).print().then(() => console.log('Done'));"
);
test_exec!(
::swc_ecma_parser::Syntax::default(),
|_| chain_at!(Module, AsyncToGenerator, es2015()),
issue_400_3,
"class A {
constructor() {
this.a_num = 10;
}
async print() {
expect(this.a_num).toBe(10);
}
}
return (new A()).print();"
);

View File

@ -335,6 +335,7 @@ where
if status.success() {
return Ok(());
}
::std::mem::forget(tmp_dir);
panic!("Execution failed")
})
}