Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wait the correct number of ticks on nested
await
(#13961)
- Loading branch information
1 parent
54c539e
commit d16f811
Showing
5 changed files
with
38 additions
and
5 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
20 changes: 20 additions & 0 deletions
20
...plugin-transform-async-to-generator/test/fixtures/async-to-generator/double-await/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,20 @@ | ||
const log = []; | ||
|
||
const p1 = (async function () { | ||
log.push(1); | ||
await await null; | ||
log.push(2); | ||
})(); | ||
|
||
const p2 = (async function () { | ||
log.push(3); | ||
await null; | ||
log.push(4); | ||
})(); | ||
|
||
log.push(5); | ||
const p3 = Promise.resolve().then(() => log.push(6)).then(() => log.push(7)); | ||
|
||
return Promise.all([p1, p2, p3]).then(() => { | ||
expect(log).toEqual([1, 3, 5, 4, 6, 2, 7]); | ||
}); |
3 changes: 3 additions & 0 deletions
3
...lugin-transform-async-to-generator/test/fixtures/async-to-generator/double-await/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,3 @@ | ||
async function fn() { | ||
await await 1; | ||
} |
5 changes: 5 additions & 0 deletions
5
...n-transform-async-to-generator/test/fixtures/async-to-generator/double-await/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 @@ | ||
{ | ||
"parserOpts": { | ||
"allowReturnOutsideFunction": true | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...ugin-transform-async-to-generator/test/fixtures/async-to-generator/double-await/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,10 @@ | ||
function fn() { | ||
return _fn.apply(this, arguments); | ||
} | ||
|
||
function _fn() { | ||
_fn = babelHelpers.asyncToGenerator(function* () { | ||
yield yield 1; | ||
}); | ||
return _fn.apply(this, arguments); | ||
} |