Skip to content

Commit 0016fd7

Browse files
author
Benjamin Lichtman
committed
Add test
1 parent f907262 commit 0016fd7

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

src/testRunner/unittests/convertToAsyncFunction.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,15 @@ function [#|f|]() {
11811181
function [#|f|]() {
11821182
return Promise.resolve().then(f ? (x => x) : (y => y)).then(q => q);
11831183
}
1184+
`);
1185+
1186+
_testConvertToAsyncFunction("convertToAsyncFunction_runEffectfulContinuation", `
1187+
function [#|f|]() {
1188+
return fetch('https://typescriptlang.org').then(res).then(_ => console.log("done"));
1189+
}
1190+
function res(result) {
1191+
return Promise.resolve().then(x => console.log(result));
1192+
}
11841193
`);
11851194

11861195
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// ==ORIGINAL==
2+
3+
function /*[#|*/f/*|]*/() {
4+
return fetch('https://typescriptlang.org').then(res).then(_ => console.log("done"));
5+
}
6+
function res(result) {
7+
return Promise.resolve().then(x => console.log(result));
8+
}
9+
10+
// ==ASYNC FUNCTION::Convert to async function==
11+
12+
async function f() {
13+
const result = await fetch('https://typescriptlang.org');
14+
await res(result);
15+
return console.log("done");
16+
}
17+
function res(result) {
18+
return Promise.resolve().then(x => console.log(result));
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// ==ORIGINAL==
2+
3+
function /*[#|*/f/*|]*/() {
4+
return fetch('https://typescriptlang.org').then(res).then(_ => console.log("done"));
5+
}
6+
function res(result) {
7+
return Promise.resolve().then(x => console.log(result));
8+
}
9+
10+
// ==ASYNC FUNCTION::Convert to async function==
11+
12+
async function f() {
13+
const result = await fetch('https://typescriptlang.org');
14+
await res(result);
15+
return console.log("done");
16+
}
17+
function res(result) {
18+
return Promise.resolve().then(x => console.log(result));
19+
}

0 commit comments

Comments
 (0)