mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Add tests
This commit is contained in:
parent
1b9507ad06
commit
ad43020c8b
@ -817,7 +817,7 @@ function [#|f|]() {
|
||||
);
|
||||
_testConvertToAsyncFunction("convertToAsyncFunction_Scope1", `
|
||||
function [#|f|]() {
|
||||
var var1:Promise<Response>, var2;
|
||||
var var1: Response, var2;
|
||||
return fetch('https://typescriptlang.org').then( _ =>
|
||||
Promise.resolve().then( res => {
|
||||
var2 = "test";
|
||||
@ -1190,6 +1190,30 @@ function [#|f|]() {
|
||||
function res(result) {
|
||||
return Promise.resolve().then(x => console.log(result));
|
||||
}
|
||||
`);
|
||||
|
||||
_testConvertToAsyncFunction("convertToAsyncFunction_callbackReturnsPromise", `
|
||||
function [#|f|]() {
|
||||
return fetch('https://typescriptlang.org').then(s => Promise.resolve(s.statusText.length)).then(x => console.log(x + 5));
|
||||
}
|
||||
`);
|
||||
|
||||
_testConvertToAsyncFunction("convertToAsyncFunction_callbackReturnsPromiseInBlock", `
|
||||
function [#|f|]() {
|
||||
return fetch('https://typescriptlang.org').then(s => { return Promise.resolve(s.statusText.length) }).then(x => x + 5);
|
||||
}
|
||||
`);
|
||||
|
||||
_testConvertToAsyncFunction("convertToAsyncFunction_callbackReturnsFixablePromise", `
|
||||
function [#|f|]() {
|
||||
return fetch('https://typescriptlang.org').then(s => Promise.resolve(s.statusText).then(st => st.length)).then(x => console.log(x + 5));
|
||||
}
|
||||
`);
|
||||
|
||||
_testConvertToAsyncFunction("convertToAsyncFunction_callbackReturnsPromiseLastInChain", `
|
||||
function [#|f|]() {
|
||||
return fetch('https://typescriptlang.org').then(s => Promise.resolve(s.statusText.length));
|
||||
}
|
||||
`);
|
||||
|
||||
});
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
function /*[#|*/f/*|]*/() {
|
||||
var var1:Promise<Response>, var2;
|
||||
var var1: Response, var2;
|
||||
return fetch('https://typescriptlang.org').then( _ =>
|
||||
Promise.resolve().then( res => {
|
||||
var2 = "test";
|
||||
@ -18,11 +18,11 @@ function /*[#|*/f/*|]*/() {
|
||||
// ==ASYNC FUNCTION::Convert to async function==
|
||||
|
||||
async function f() {
|
||||
var var1:Promise<Response>, var2;
|
||||
var var1: Response, var2;
|
||||
await fetch('https://typescriptlang.org');
|
||||
const res = await Promise.resolve();
|
||||
var2 = "test";
|
||||
const res_1 = fetch("https://microsoft.com");
|
||||
const res_1 = await fetch("https://microsoft.com");
|
||||
const response = var1 === res_1;
|
||||
return res(response);
|
||||
}
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
function /*[#|*/f/*|]*/() {
|
||||
return fetch('https://typescriptlang.org').then(s => Promise.resolve(s.statusText).then(st => st.length)).then(x => console.log(x + 5));
|
||||
}
|
||||
|
||||
// ==ASYNC FUNCTION::Convert to async function==
|
||||
|
||||
async function f() {
|
||||
const s = await fetch('https://typescriptlang.org');
|
||||
const st = await Promise.resolve(s.statusText);
|
||||
const x = st.length;
|
||||
return console.log(x + 5);
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
function /*[#|*/f/*|]*/() {
|
||||
return fetch('https://typescriptlang.org').then(s => Promise.resolve(s.statusText).then(st => st.length)).then(x => console.log(x + 5));
|
||||
}
|
||||
|
||||
// ==ASYNC FUNCTION::Convert to async function==
|
||||
|
||||
async function f() {
|
||||
const s = await fetch('https://typescriptlang.org');
|
||||
const st = await Promise.resolve(s.statusText);
|
||||
const x = st.length;
|
||||
return console.log(x + 5);
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
function /*[#|*/f/*|]*/() {
|
||||
return fetch('https://typescriptlang.org').then(s => Promise.resolve(s.statusText.length)).then(x => console.log(x + 5));
|
||||
}
|
||||
|
||||
// ==ASYNC FUNCTION::Convert to async function==
|
||||
|
||||
async function f() {
|
||||
const s = await fetch('https://typescriptlang.org');
|
||||
const x = await Promise.resolve(s.statusText.length);
|
||||
return console.log(x + 5);
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
function /*[#|*/f/*|]*/() {
|
||||
return fetch('https://typescriptlang.org').then(s => Promise.resolve(s.statusText.length)).then(x => console.log(x + 5));
|
||||
}
|
||||
|
||||
// ==ASYNC FUNCTION::Convert to async function==
|
||||
|
||||
async function f() {
|
||||
const s = await fetch('https://typescriptlang.org');
|
||||
const x = await Promise.resolve(s.statusText.length);
|
||||
return console.log(x + 5);
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
function /*[#|*/f/*|]*/() {
|
||||
return fetch('https://typescriptlang.org').then(s => { return Promise.resolve(s.statusText.length) }).then(x => x + 5);
|
||||
}
|
||||
|
||||
// ==ASYNC FUNCTION::Convert to async function==
|
||||
|
||||
async function f() {
|
||||
const s = await fetch('https://typescriptlang.org');
|
||||
const x = await Promise.resolve(s.statusText.length);
|
||||
return x + 5;
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
function /*[#|*/f/*|]*/() {
|
||||
return fetch('https://typescriptlang.org').then(s => { return Promise.resolve(s.statusText.length) }).then(x => x + 5);
|
||||
}
|
||||
|
||||
// ==ASYNC FUNCTION::Convert to async function==
|
||||
|
||||
async function f() {
|
||||
const s = await fetch('https://typescriptlang.org');
|
||||
const x = await Promise.resolve(s.statusText.length);
|
||||
return x + 5;
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
function /*[#|*/f/*|]*/() {
|
||||
return fetch('https://typescriptlang.org').then(s => Promise.resolve(s.statusText.length));
|
||||
}
|
||||
|
||||
// ==ASYNC FUNCTION::Convert to async function==
|
||||
|
||||
async function f() {
|
||||
const s = await fetch('https://typescriptlang.org');
|
||||
return Promise.resolve(s.statusText.length);
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
function /*[#|*/f/*|]*/() {
|
||||
return fetch('https://typescriptlang.org').then(s => Promise.resolve(s.statusText.length));
|
||||
}
|
||||
|
||||
// ==ASYNC FUNCTION::Convert to async function==
|
||||
|
||||
async function f() {
|
||||
const s = await fetch('https://typescriptlang.org');
|
||||
return Promise.resolve(s.statusText.length);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user