Skip to content

Commit f809956

Browse files
committed
Tidy up Extract Method fourslash tests
Partial port of ea4fdc5
1 parent 4a63ed7 commit f809956

25 files changed

+59
-1036
lines changed

src/harness/unittests/extractMethods.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ namespace A {
552552

553553
function testExtractMethod(caption: string, text: string) {
554554
it(caption, () => {
555-
Harness.Baseline.runBaseline(`extractMethod/${caption}.js`, () => {
555+
Harness.Baseline.runBaseline(`extractMethod/${caption}.ts`, () => {
556556
const t = extractTest(text);
557557
const selectionRange = t.ranges.get("selection");
558558
if (!selectionRange) {
@@ -562,7 +562,7 @@ namespace A {
562562
path: "/a.ts",
563563
content: t.source
564564
};
565-
const host = projectSystem.createServerHost([f]);
565+
const host = projectSystem.createServerHost([f, projectSystem.libFile]);
566566
const projectService = projectSystem.createProjectService(host);
567567
projectService.openClientFile(f.path);
568568
const program = projectService.inferredProjects[0].getLanguageService().getProgram();
@@ -579,12 +579,12 @@ namespace A {
579579
assert.equal(result.errors, undefined, "expect no errors");
580580
const results = refactor.extractMethod.getPossibleExtractions(result.targetRange, context);
581581
const data: string[] = [];
582-
data.push(`==ORIGINAL==`);
582+
data.push(`// ==ORIGINAL==`);
583583
data.push(sourceFile.text);
584584
for (const r of results) {
585585
const { renameLocation, edits } = refactor.extractMethod.getExtractionAtIndex(result.targetRange, context, results.indexOf(r));
586586
assert.lengthOf(edits, 1);
587-
data.push(`==SCOPE::${r.scopeDescription}==`);
587+
data.push(`// ==SCOPE::${r.scopeDescription}==`);
588588
const newText = textChanges.applyChanges(sourceFile.text, edits[0].textChanges);
589589
const newTextWithRename = newText.slice(0, renameLocation) + "/*RENAME*/" + newText.slice(renameLocation);
590590
data.push(newTextWithRename);

tests/baselines/reference/extractMethod/extractMethod1.js renamed to tests/baselines/reference/extractMethod/extractMethod1.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
==ORIGINAL==
1+
// ==ORIGINAL==
22
namespace A {
33
let x = 1;
44
function foo() {
@@ -14,7 +14,7 @@ namespace A {
1414
}
1515
}
1616
}
17-
==SCOPE::function 'a'==
17+
// ==SCOPE::function 'a'==
1818
namespace A {
1919
let x = 1;
2020
function foo() {
@@ -34,7 +34,7 @@ namespace A {
3434
}
3535
}
3636
}
37-
==SCOPE::namespace 'B'==
37+
// ==SCOPE::namespace 'B'==
3838
namespace A {
3939
let x = 1;
4040
function foo() {
@@ -55,7 +55,7 @@ namespace A {
5555
}
5656
}
5757
}
58-
==SCOPE::namespace 'A'==
58+
// ==SCOPE::namespace 'A'==
5959
namespace A {
6060
let x = 1;
6161
function foo() {
@@ -76,7 +76,7 @@ namespace A {
7676
return a;
7777
}
7878
}
79-
==SCOPE::global scope==
79+
// ==SCOPE::global scope==
8080
namespace A {
8181
let x = 1;
8282
function foo() {

tests/baselines/reference/extractMethod/extractMethod10.js renamed to tests/baselines/reference/extractMethod/extractMethod10.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
==ORIGINAL==
1+
// ==ORIGINAL==
22
namespace A {
33
export interface I { x: number };
44
class C {
@@ -9,7 +9,7 @@ namespace A {
99
}
1010
}
1111
}
12-
==SCOPE::class 'C'==
12+
// ==SCOPE::class 'C'==
1313
namespace A {
1414
export interface I { x: number };
1515
class C {
@@ -24,7 +24,7 @@ namespace A {
2424
}
2525
}
2626
}
27-
==SCOPE::namespace 'A'==
27+
// ==SCOPE::namespace 'A'==
2828
namespace A {
2929
export interface I { x: number };
3030
class C {
@@ -39,7 +39,7 @@ namespace A {
3939
return a1.x + 10;
4040
}
4141
}
42-
==SCOPE::global scope==
42+
// ==SCOPE::global scope==
4343
namespace A {
4444
export interface I { x: number };
4545
class C {

tests/baselines/reference/extractMethod/extractMethod11.js renamed to tests/baselines/reference/extractMethod/extractMethod11.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
==ORIGINAL==
1+
// ==ORIGINAL==
22
namespace A {
33
let y = 1;
44
class C {
@@ -11,7 +11,7 @@ namespace A {
1111
}
1212
}
1313
}
14-
==SCOPE::class 'C'==
14+
// ==SCOPE::class 'C'==
1515
namespace A {
1616
let y = 1;
1717
class C {
@@ -30,7 +30,7 @@ namespace A {
3030
}
3131
}
3232
}
33-
==SCOPE::namespace 'A'==
33+
// ==SCOPE::namespace 'A'==
3434
namespace A {
3535
let y = 1;
3636
class C {
@@ -49,7 +49,7 @@ namespace A {
4949
return { __return: a1.x + 10, z };
5050
}
5151
}
52-
==SCOPE::global scope==
52+
// ==SCOPE::global scope==
5353
namespace A {
5454
let y = 1;
5555
class C {

tests/baselines/reference/extractMethod/extractMethod12.js renamed to tests/baselines/reference/extractMethod/extractMethod12.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
==ORIGINAL==
1+
// ==ORIGINAL==
22
namespace A {
33
let y = 1;
44
class C {
@@ -13,7 +13,7 @@ namespace A {
1313
}
1414
}
1515
}
16-
==SCOPE::class 'C'==
16+
// ==SCOPE::class 'C'==
1717
namespace A {
1818
let y = 1;
1919
class C {

tests/baselines/reference/extractMethod/extractMethod2.js renamed to tests/baselines/reference/extractMethod/extractMethod2.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
==ORIGINAL==
1+
// ==ORIGINAL==
22
namespace A {
33
let x = 1;
44
function foo() {
@@ -12,7 +12,7 @@ namespace A {
1212
}
1313
}
1414
}
15-
==SCOPE::function 'a'==
15+
// ==SCOPE::function 'a'==
1616
namespace A {
1717
let x = 1;
1818
function foo() {
@@ -30,7 +30,7 @@ namespace A {
3030
}
3131
}
3232
}
33-
==SCOPE::namespace 'B'==
33+
// ==SCOPE::namespace 'B'==
3434
namespace A {
3535
let x = 1;
3636
function foo() {
@@ -48,7 +48,7 @@ namespace A {
4848
}
4949
}
5050
}
51-
==SCOPE::namespace 'A'==
51+
// ==SCOPE::namespace 'A'==
5252
namespace A {
5353
let x = 1;
5454
function foo() {
@@ -66,7 +66,7 @@ namespace A {
6666
return foo();
6767
}
6868
}
69-
==SCOPE::global scope==
69+
// ==SCOPE::global scope==
7070
namespace A {
7171
let x = 1;
7272
function foo() {

tests/baselines/reference/extractMethod/extractMethod3.js renamed to tests/baselines/reference/extractMethod/extractMethod3.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
==ORIGINAL==
1+
// ==ORIGINAL==
22
namespace A {
33
function foo() {
44
}
@@ -11,7 +11,7 @@ namespace A {
1111
}
1212
}
1313
}
14-
==SCOPE::function 'a'==
14+
// ==SCOPE::function 'a'==
1515
namespace A {
1616
function foo() {
1717
}
@@ -28,7 +28,7 @@ namespace A {
2828
}
2929
}
3030
}
31-
==SCOPE::namespace 'B'==
31+
// ==SCOPE::namespace 'B'==
3232
namespace A {
3333
function foo() {
3434
}
@@ -45,7 +45,7 @@ namespace A {
4545
}
4646
}
4747
}
48-
==SCOPE::namespace 'A'==
48+
// ==SCOPE::namespace 'A'==
4949
namespace A {
5050
function foo() {
5151
}
@@ -62,7 +62,7 @@ namespace A {
6262
return foo();
6363
}
6464
}
65-
==SCOPE::global scope==
65+
// ==SCOPE::global scope==
6666
namespace A {
6767
function foo() {
6868
}

tests/baselines/reference/extractMethod/extractMethod4.js renamed to tests/baselines/reference/extractMethod/extractMethod4.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
==ORIGINAL==
1+
// ==ORIGINAL==
22
namespace A {
33
function foo() {
44
}
@@ -13,7 +13,7 @@ namespace A {
1313
}
1414
}
1515
}
16-
==SCOPE::function 'a'==
16+
// ==SCOPE::function 'a'==
1717
namespace A {
1818
function foo() {
1919
}
@@ -32,7 +32,7 @@ namespace A {
3232
}
3333
}
3434
}
35-
==SCOPE::namespace 'B'==
35+
// ==SCOPE::namespace 'B'==
3636
namespace A {
3737
function foo() {
3838
}
@@ -51,7 +51,7 @@ namespace A {
5151
}
5252
}
5353
}
54-
==SCOPE::namespace 'A'==
54+
// ==SCOPE::namespace 'A'==
5555
namespace A {
5656
function foo() {
5757
}
@@ -70,7 +70,7 @@ namespace A {
7070
return foo();
7171
}
7272
}
73-
==SCOPE::global scope==
73+
// ==SCOPE::global scope==
7474
namespace A {
7575
function foo() {
7676
}

tests/baselines/reference/extractMethod/extractMethod5.js renamed to tests/baselines/reference/extractMethod/extractMethod5.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
==ORIGINAL==
1+
// ==ORIGINAL==
22
namespace A {
33
let x = 1;
44
export function foo() {
@@ -14,7 +14,7 @@ namespace A {
1414
}
1515
}
1616
}
17-
==SCOPE::function 'a'==
17+
// ==SCOPE::function 'a'==
1818
namespace A {
1919
let x = 1;
2020
export function foo() {
@@ -34,7 +34,7 @@ namespace A {
3434
}
3535
}
3636
}
37-
==SCOPE::namespace 'B'==
37+
// ==SCOPE::namespace 'B'==
3838
namespace A {
3939
let x = 1;
4040
export function foo() {
@@ -55,7 +55,7 @@ namespace A {
5555
}
5656
}
5757
}
58-
==SCOPE::namespace 'A'==
58+
// ==SCOPE::namespace 'A'==
5959
namespace A {
6060
let x = 1;
6161
export function foo() {
@@ -76,7 +76,7 @@ namespace A {
7676
return a;
7777
}
7878
}
79-
==SCOPE::global scope==
79+
// ==SCOPE::global scope==
8080
namespace A {
8181
let x = 1;
8282
export function foo() {

tests/baselines/reference/extractMethod/extractMethod6.js renamed to tests/baselines/reference/extractMethod/extractMethod6.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
==ORIGINAL==
1+
// ==ORIGINAL==
22
namespace A {
33
let x = 1;
44
export function foo() {
@@ -14,7 +14,7 @@ namespace A {
1414
}
1515
}
1616
}
17-
==SCOPE::function 'a'==
17+
// ==SCOPE::function 'a'==
1818
namespace A {
1919
let x = 1;
2020
export function foo() {
@@ -34,7 +34,7 @@ namespace A {
3434
}
3535
}
3636
}
37-
==SCOPE::namespace 'B'==
37+
// ==SCOPE::namespace 'B'==
3838
namespace A {
3939
let x = 1;
4040
export function foo() {
@@ -56,7 +56,7 @@ namespace A {
5656
}
5757
}
5858
}
59-
==SCOPE::namespace 'A'==
59+
// ==SCOPE::namespace 'A'==
6060
namespace A {
6161
let x = 1;
6262
export function foo() {
@@ -78,7 +78,7 @@ namespace A {
7878
return { __return: foo(), a };
7979
}
8080
}
81-
==SCOPE::global scope==
81+
// ==SCOPE::global scope==
8282
namespace A {
8383
let x = 1;
8484
export function foo() {

0 commit comments

Comments
 (0)