TypeScript/tests/baselines/reference/extractFunction/extractFunction1.ts
Andrew Casey 2ea4cfe23b Insert a line break before a function at EOF if needed
This is a pre-existing issue that became more obvious after refining
trivia handling.
2017-10-12 14:19:36 -07:00

99 lines
1.8 KiB
TypeScript

// ==ORIGINAL==
namespace A {
let x = 1;
function foo() {
}
namespace B {
function a() {
let a = 1;
/*[#|*/
let y = 5;
let z = x;
a = y;
foo();/*|]*/
}
}
}
// ==SCOPE::Extract to inner function in function 'a'==
namespace A {
let x = 1;
function foo() {
}
namespace B {
function a() {
let a = 1;
/*RENAME*/newFunction();
function newFunction() {
let y = 5;
let z = x;
a = y;
foo();
}
}
}
}
// ==SCOPE::Extract to function in namespace 'B'==
namespace A {
let x = 1;
function foo() {
}
namespace B {
function a() {
let a = 1;
a = /*RENAME*/newFunction(a);
}
function newFunction(a: number) {
let y = 5;
let z = x;
a = y;
foo();
return a;
}
}
}
// ==SCOPE::Extract to function in namespace 'A'==
namespace A {
let x = 1;
function foo() {
}
namespace B {
function a() {
let a = 1;
a = /*RENAME*/newFunction(a);
}
}
function newFunction(a: number) {
let y = 5;
let z = x;
a = y;
foo();
return a;
}
}
// ==SCOPE::Extract to function in global scope==
namespace A {
let x = 1;
function foo() {
}
namespace B {
function a() {
let a = 1;
a = /*RENAME*/newFunction(x, a, foo);
}
}
}
function newFunction(x: number, a: number, foo: () => void) {
let y = 5;
let z = x;
a = y;
foo();
return a;
}