Skip to content

Commit

Permalink
Added tests and baselines
Browse files Browse the repository at this point in the history
  • Loading branch information
elizabethdinella committed Aug 9, 2018
1 parent 8777657 commit e6c676e
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/testRunner/unittests/convertToAsyncFunction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1039,12 +1039,28 @@ function res(result){
return 5;
}
function rej(reject): Response{
return reject;
}
`
);

_testConvertToAsyncFunction("convertToAsyncFunction_CatchFollowedByThenMismatchTypes02NoAnnotations", `
function [#|f|](){
return fetch("https://typescriptlang.org").then(res).catch(rej).then(res);
}
function res(result){
return 5;
}
function rej(reject){
return reject;
}
`
);


_testConvertToAsyncFunction("convertToAsyncFunction_CatchFollowedByThenMismatchTypes03", `
function [#|f|](){
return fetch("https://typescriptlang.org").then(res).catch(rej).then(res);
Expand Down Expand Up @@ -1075,11 +1091,11 @@ function [#|f|](){
return fetch("https://typescriptlang.org").then(res).catch(rej).then(res);
}
function res(result){
function res(result): b{
return {name: "myName", age: 22, color: "red"};
}
function rej(reject){
function rej(reject): a{
return {name: "myName", age: 27};
}
`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// ==ORIGINAL==

function /*[#|*/f/*|]*/(){
return fetch("https://typescriptlang.org").then(res).catch(rej).then(res);
}

function res(result){
return 5;
}

function rej(reject): Response{
return reject;
}

// ==ASYNC FUNCTION::Convert to async function==

async function f(){
let result: number | Response;
try {
const result_1 = await fetch("https://typescriptlang.org");
result = await res(result_1);
}
catch (reject) {
result = await rej(reject);
}
return res(result);
}

function res(result){
return 5;
}

function rej(reject): Response{
return reject;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// ==ORIGINAL==

function /*[#|*/f/*|]*/(){
return fetch("https://typescriptlang.org").then(res).catch(rej).then(res);
}

function res(result){
return 5;
}

function rej(reject){
return reject;
}

// ==ASYNC FUNCTION::Convert to async function==

async function f(){
let result;
try {
const result_1 = await fetch("https://typescriptlang.org");
result = await res(result_1);
}
catch (reject) {
result = await rej(reject);
}
return res(result);
}

function res(result){
return 5;
}

function rej(reject){
return reject;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// ==ORIGINAL==

function /*[#|*/f/*|]*/(){
return fetch("https://typescriptlang.org").then(res).catch(rej).then(res);
}

function res(result){
return 5;
}

function rej(reject){
return reject;
}

// ==ASYNC FUNCTION::Convert to async function==

async function f(){
let result: any;
try {
const result_1 = await fetch("https://typescriptlang.org");
result = await res(result_1);
}
catch (reject) {
result = await rej(reject);
}
return res(result);
}

function res(result){
return 5;
}

function rej(reject){
return reject;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// ==ORIGINAL==

interface a {
name: string;
age: number;
}

interface b extends a {
color: string;
}


function /*[#|*/f/*|]*/(){
return fetch("https://typescriptlang.org").then(res).catch(rej).then(res);
}

function res(result): b{
return {name: "myName", age: 22, color: "red"};
}

function rej(reject): a{
return {name: "myName", age: 27};
}

// ==ASYNC FUNCTION::Convert to async function==

interface a {
name: string;
age: number;
}

interface b extends a {
color: string;
}


async function f(){
let result: a;
try {
const result_1 = await fetch("https://typescriptlang.org");
result = await res(result_1);
}
catch (reject) {
result = await rej(reject);
}
return res(result);
}

function res(result): b{
return {name: "myName", age: 22, color: "red"};
}

function rej(reject): a{
return {name: "myName", age: 27};
}

0 comments on commit e6c676e

Please sign in to comment.