Add simple baseline tests for insertion positions

This commit is contained in:
Andrew Casey 2017-09-08 16:45:47 -07:00
parent e77425f984
commit 62899d10cd
7 changed files with 267 additions and 2 deletions

View file

@ -224,7 +224,7 @@ namespace ts {
testExtractRange(`
function f() {
while (true) {
[#|
[#|
if (x) {
return;
} |]
@ -234,7 +234,7 @@ namespace ts {
testExtractRange(`
function f() {
while (true) {
[#|
[#|
[$|if (x) {
}
return;|]
@ -655,6 +655,60 @@ function test(x: number) {
finally {
[#|return 1;|]
}
}`);
// Extraction position - namespace
testExtractMethod("extractMethod23",
`namespace NS {
function M1() { }
function M2() {
[#|return 1;|]
}
function M3() { }
}`);
// Extraction position - function
testExtractMethod("extractMethod24",
`function Outer() {
function M1() { }
function M2() {
[#|return 1;|]
}
function M3() { }
}`);
// Extraction position - file
testExtractMethod("extractMethod25",
`function M1() { }
function M2() {
[#|return 1;|]
}
function M3() { }`);
// Extraction position - class without ctor
testExtractMethod("extractMethod26",
`class C {
M1() { }
M2() {
[#|return 1;|]
}
M3() { }
}`);
// Extraction position - class with ctor in middle
testExtractMethod("extractMethod27",
`class C {
M1() { }
M2() {
[#|return 1;|]
}
constructor() { }
M3() { }
}`);
// Extraction position - class with ctor at end
testExtractMethod("extractMethod28",
`class C {
M1() { }
M2() {
[#|return 1;|]
}
M3() { }
constructor() { }
}`);
});

View file

@ -0,0 +1,43 @@
// ==ORIGINAL==
namespace NS {
function M1() { }
function M2() {
return 1;
}
function M3() { }
}
// ==SCOPE::function 'M2'==
namespace NS {
function M1() { }
function M2() {
return newFunction();
function newFunction() {
return 1;
}
}
function M3() { }
}
// ==SCOPE::namespace 'NS'==
namespace NS {
function M1() { }
function M2() {
return newFunction();
}
function newFunction() {
return 1;
}
function M3() { }
}
// ==SCOPE::global scope==
namespace NS {
function M1() { }
function M2() {
return newFunction();
}
function M3() { }
}
function newFunction() {
return 1;
}

View file

@ -0,0 +1,43 @@
// ==ORIGINAL==
function Outer() {
function M1() { }
function M2() {
return 1;
}
function M3() { }
}
// ==SCOPE::function 'M2'==
function Outer() {
function M1() { }
function M2() {
return newFunction();
function newFunction() {
return 1;
}
}
function M3() { }
}
// ==SCOPE::function 'Outer'==
function Outer() {
function M1() { }
function M2() {
return newFunction();
}
function newFunction() {
return 1;
}
function M3() { }
}
// ==SCOPE::global scope==
function Outer() {
function M1() { }
function M2() {
return newFunction();
}
function M3() { }
}
function newFunction() {
return 1;
}

View file

@ -0,0 +1,26 @@
// ==ORIGINAL==
function M1() { }
function M2() {
return 1;
}
function M3() { }
// ==SCOPE::function 'M2'==
function M1() { }
function M2() {
return newFunction();
function newFunction() {
return 1;
}
}
function M3() { }
// ==SCOPE::global scope==
function M1() { }
function M2() {
return newFunction();
}
function newFunction() {
return 1;
}
function M3() { }

View file

@ -0,0 +1,31 @@
// ==ORIGINAL==
class C {
M1() { }
M2() {
return 1;
}
M3() { }
}
// ==SCOPE::class 'C'==
class C {
M1() { }
M2() {
return this.newFunction();
}
private newFunction() {
return 1;
}
M3() { }
}
// ==SCOPE::global scope==
class C {
M1() { }
M2() {
return newFunction();
}
M3() { }
}
function newFunction() {
return 1;
}

View file

@ -0,0 +1,34 @@
// ==ORIGINAL==
class C {
M1() { }
M2() {
return 1;
}
constructor() { }
M3() { }
}
// ==SCOPE::class 'C'==
class C {
M1() { }
M2() {
return this.newFunction();
}
constructor() { }
private newFunction() {
return 1;
}
M3() { }
}
// ==SCOPE::global scope==
class C {
M1() { }
M2() {
return newFunction();
}
constructor() { }
M3() { }
}
function newFunction() {
return 1;
}

View file

@ -0,0 +1,34 @@
// ==ORIGINAL==
class C {
M1() { }
M2() {
return 1;
}
M3() { }
constructor() { }
}
// ==SCOPE::class 'C'==
class C {
M1() { }
M2() {
return this.newFunction();
}
private newFunction() {
return 1;
}
M3() { }
constructor() { }
}
// ==SCOPE::global scope==
class C {
M1() { }
M2() {
return newFunction();
}
M3() { }
constructor() { }
}
function newFunction() {
return 1;
}