Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set correct async/generator in IIFE for params (#11346)
* Set correct async/generator in IIFE for params * Reject in async params * Skip async test on node 6 (it doesn't support async fns)
- Loading branch information
1 parent
71e7a7b
commit c8a8be7
Showing
6 changed files
with
71 additions
and
0 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
13 changes: 13 additions & 0 deletions
13
...lugin-transform-parameters/test/fixtures/regression/scope-async-param-error-async/exec.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,13 @@ | ||
const err = new Error(); | ||
|
||
async function f(a = (() => { throw err })()) { | ||
throw 1; | ||
var a = await a; | ||
return a; | ||
} | ||
|
||
return (async () => { | ||
let p; | ||
expect(() => { p = f() }).not.toThrow(); | ||
await expect(p).rejects.toThrow(err); | ||
})(); |
9 changes: 9 additions & 0 deletions
9
...-transform-parameters/test/fixtures/regression/scope-async-param-error-async/options.json
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,9 @@ | ||
{ | ||
"plugins": [ | ||
"transform-parameters" | ||
], | ||
"parserOpts": { | ||
"allowReturnOutsideFunction": true | ||
}, | ||
"minNodeVersion": "8.0.0" | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/babel-plugin-transform-parameters/test/fixtures/regression/scope-gen-async/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,14 @@ | ||
function* f(a = 1) { | ||
var a = yield a; | ||
return a; | ||
} | ||
|
||
async function g(a = 1) { | ||
var a = await a; | ||
return a; | ||
} | ||
|
||
async function* h(a = 1) { | ||
var a = await (yield a); | ||
return a; | ||
} |
5 changes: 5 additions & 0 deletions
5
...s/babel-plugin-transform-parameters/test/fixtures/regression/scope-gen-async/options.json
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 @@ | ||
{ | ||
"plugins": [ | ||
"transform-parameters" | ||
] | ||
} |
23 changes: 23 additions & 0 deletions
23
...ages/babel-plugin-transform-parameters/test/fixtures/regression/scope-gen-async/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,23 @@ | ||
function f() { | ||
let a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; | ||
return function* (a) { | ||
var a = yield a; | ||
return a; | ||
}(a); | ||
} | ||
|
||
async function g() { | ||
let a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; | ||
return async function (a) { | ||
var a = await a; | ||
return a; | ||
}(a); | ||
} | ||
|
||
async function h() { | ||
let a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1; | ||
return async function* (a) { | ||
var a = await (yield a); | ||
return a; | ||
}(a); | ||
} |