Skip to content

Commit 8e7a5ba

Browse files
authored
Merge pull request #18824 from amcasey/ExtractFunctionRename
Rename extractMethod tests to extractFunction for consistency
2 parents 5f30106 + 49d24fd commit 8e7a5ba

34 files changed

+38
-38
lines changed

src/harness/unittests/extractFunctions.ts

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/// <reference path="extractTestHelpers.ts" />
22

33
namespace ts {
4-
describe("extractMethods", () => {
5-
testExtractMethod("extractMethod1",
4+
describe("extractFunctions", () => {
5+
testExtractFunction("extractFunction1",
66
`namespace A {
77
let x = 1;
88
function foo() {
@@ -18,7 +18,7 @@ namespace ts {
1818
}
1919
}
2020
}`);
21-
testExtractMethod("extractMethod2",
21+
testExtractFunction("extractFunction2",
2222
`namespace A {
2323
let x = 1;
2424
function foo() {
@@ -32,7 +32,7 @@ namespace ts {
3232
}
3333
}
3434
}`);
35-
testExtractMethod("extractMethod3",
35+
testExtractFunction("extractFunction3",
3636
`namespace A {
3737
function foo() {
3838
}
@@ -45,7 +45,7 @@ namespace ts {
4545
}
4646
}
4747
}`);
48-
testExtractMethod("extractMethod4",
48+
testExtractFunction("extractFunction4",
4949
`namespace A {
5050
function foo() {
5151
}
@@ -60,7 +60,7 @@ namespace ts {
6060
}
6161
}
6262
}`);
63-
testExtractMethod("extractMethod5",
63+
testExtractFunction("extractFunction5",
6464
`namespace A {
6565
let x = 1;
6666
export function foo() {
@@ -76,7 +76,7 @@ namespace ts {
7676
}
7777
}
7878
}`);
79-
testExtractMethod("extractMethod6",
79+
testExtractFunction("extractFunction6",
8080
`namespace A {
8181
let x = 1;
8282
export function foo() {
@@ -92,7 +92,7 @@ namespace ts {
9292
}
9393
}
9494
}`);
95-
testExtractMethod("extractMethod7",
95+
testExtractFunction("extractFunction7",
9696
`namespace A {
9797
let x = 1;
9898
export namespace C {
@@ -110,7 +110,7 @@ namespace ts {
110110
}
111111
}
112112
}`);
113-
testExtractMethod("extractMethod8",
113+
testExtractFunction("extractFunction8",
114114
`namespace A {
115115
let x = 1;
116116
namespace B {
@@ -120,7 +120,7 @@ namespace ts {
120120
}
121121
}
122122
}`);
123-
testExtractMethod("extractMethod9",
123+
testExtractFunction("extractFunction9",
124124
`namespace A {
125125
export interface I { x: number };
126126
namespace B {
@@ -130,7 +130,7 @@ namespace ts {
130130
}
131131
}
132132
}`);
133-
testExtractMethod("extractMethod10",
133+
testExtractFunction("extractFunction10",
134134
`namespace A {
135135
export interface I { x: number };
136136
class C {
@@ -141,7 +141,7 @@ namespace ts {
141141
}
142142
}
143143
}`);
144-
testExtractMethod("extractMethod11",
144+
testExtractFunction("extractFunction11",
145145
`namespace A {
146146
let y = 1;
147147
class C {
@@ -154,7 +154,7 @@ namespace ts {
154154
}
155155
}
156156
}`);
157-
testExtractMethod("extractMethod12",
157+
testExtractFunction("extractFunction12",
158158
`namespace A {
159159
let y = 1;
160160
class C {
@@ -174,7 +174,7 @@ namespace ts {
174174
// In all cases, we could use type inference, rather than passing explicit type arguments.
175175
// Note the inclusion of arrow functions to ensure that some type parameters are not from
176176
// targetable scopes.
177-
testExtractMethod("extractMethod13",
177+
testExtractFunction("extractFunction13",
178178
`<U1a, U1b>(u1a: U1a, u1b: U1b) => {
179179
function F1<T1a, T1b>(t1a: T1a, t1b: T1b) {
180180
<U2a, U2b>(u2a: U2a, u2b: U2b) => {
@@ -192,61 +192,61 @@ namespace ts {
192192
}`);
193193
// This test is descriptive, rather than normative. The current implementation
194194
// doesn't handle type parameter shadowing.
195-
testExtractMethod("extractMethod14",
195+
testExtractFunction("extractFunction14",
196196
`function F<T>(t1: T) {
197197
function G<T>(t2: T) {
198198
[#|t1.toString();
199199
t2.toString();|]
200200
}
201201
}`);
202202
// Confirm that the constraint is preserved.
203-
testExtractMethod("extractMethod15",
203+
testExtractFunction("extractFunction15",
204204
`function F<T>(t1: T) {
205205
function G<U extends T[]>(t2: U) {
206206
[#|t2.toString();|]
207207
}
208208
}`);
209209
// Confirm that the contextual type of an extracted expression counts as a use.
210-
testExtractMethod("extractMethod16",
210+
testExtractFunction("extractFunction16",
211211
`function F<T>() {
212212
const array: T[] = [#|[]|];
213213
}`);
214214
// Class type parameter
215-
testExtractMethod("extractMethod17",
215+
testExtractFunction("extractFunction17",
216216
`class C<T1, T2> {
217217
M(t1: T1, t2: T2) {
218218
[#|t1.toString()|];
219219
}
220220
}`);
221-
// Method type parameter
222-
testExtractMethod("extractMethod18",
221+
// Function type parameter
222+
testExtractFunction("extractFunction18",
223223
`class C {
224224
M<T1, T2>(t1: T1, t2: T2) {
225225
[#|t1.toString()|];
226226
}
227227
}`);
228228
// Coupled constraints
229-
testExtractMethod("extractMethod19",
229+
testExtractFunction("extractFunction19",
230230
`function F<T, U extends T[], V extends U[]>(v: V) {
231231
[#|v.toString()|];
232232
}`);
233233

234-
testExtractMethod("extractMethod20",
234+
testExtractFunction("extractFunction20",
235235
`const _ = class {
236236
a() {
237237
[#|let a1 = { x: 1 };
238238
return a1.x + 10;|]
239239
}
240240
}`);
241241
// Write + void return
242-
testExtractMethod("extractMethod21",
242+
testExtractFunction("extractFunction21",
243243
`function foo() {
244244
let x = 10;
245245
[#|x++;
246246
return;|]
247247
}`);
248248
// Return in finally block
249-
testExtractMethod("extractMethod22",
249+
testExtractFunction("extractFunction22",
250250
`function test() {
251251
try {
252252
}
@@ -255,7 +255,7 @@ namespace ts {
255255
}
256256
}`);
257257
// Extraction position - namespace
258-
testExtractMethod("extractMethod23",
258+
testExtractFunction("extractFunction23",
259259
`namespace NS {
260260
function M1() { }
261261
function M2() {
@@ -264,7 +264,7 @@ namespace ts {
264264
function M3() { }
265265
}`);
266266
// Extraction position - function
267-
testExtractMethod("extractMethod24",
267+
testExtractFunction("extractFunction24",
268268
`function Outer() {
269269
function M1() { }
270270
function M2() {
@@ -273,14 +273,14 @@ namespace ts {
273273
function M3() { }
274274
}`);
275275
// Extraction position - file
276-
testExtractMethod("extractMethod25",
276+
testExtractFunction("extractFunction25",
277277
`function M1() { }
278278
function M2() {
279279
[#|return 1;|]
280280
}
281281
function M3() { }`);
282282
// Extraction position - class without ctor
283-
testExtractMethod("extractMethod26",
283+
testExtractFunction("extractFunction26",
284284
`class C {
285285
M1() { }
286286
M2() {
@@ -289,7 +289,7 @@ function M3() { }`);
289289
M3() { }
290290
}`);
291291
// Extraction position - class with ctor in middle
292-
testExtractMethod("extractMethod27",
292+
testExtractFunction("extractFunction27",
293293
`class C {
294294
M1() { }
295295
M2() {
@@ -299,7 +299,7 @@ function M3() { }`);
299299
M3() { }
300300
}`);
301301
// Extraction position - class with ctor at end
302-
testExtractMethod("extractMethod28",
302+
testExtractFunction("extractFunction28",
303303
`class C {
304304
M1() { }
305305
M2() {
@@ -309,7 +309,7 @@ function M3() { }`);
309309
constructor() { }
310310
}`);
311311
// Shorthand property names
312-
testExtractMethod("extractMethod29",
312+
testExtractFunction("extractFunction29",
313313
`interface UnaryExpression {
314314
kind: "Unary";
315315
operator: string;
@@ -328,12 +328,12 @@ function parsePrimaryExpression(): any {
328328
throw "Not implemented";
329329
}`);
330330
// Type parameter as declared type
331-
testExtractMethod("extractMethod30",
331+
testExtractFunction("extractFunction30",
332332
`function F<T>() {
333333
[#|let t: T;|]
334334
}`);
335335
// Return in nested function
336-
testExtractMethod("extractMethod31",
336+
testExtractFunction("extractFunction31",
337337
`namespace N {
338338
339339
export const value = 1;
@@ -346,7 +346,7 @@ function parsePrimaryExpression(): any {
346346
}
347347
}`);
348348
// Return in nested class
349-
testExtractMethod("extractMethod32",
349+
testExtractFunction("extractFunction32",
350350
`namespace N {
351351
352352
export const value = 1;
@@ -360,20 +360,20 @@ function parsePrimaryExpression(): any {
360360
}
361361
}`);
362362
// Selection excludes leading trivia of declaration
363-
testExtractMethod("extractMethod33",
363+
testExtractFunction("extractFunction33",
364364
`function F() {
365365
[#|function G() { }|]
366366
}`);
367367

368368
// TODO (acasey): handle repeated substitution
369-
// testExtractMethod("extractMethod_RepeatedSubstitution",
369+
// testExtractFunction("extractFunction_RepeatedSubstitution",
370370
// `namespace X {
371371
// export const j = 10;
372372
// export const y = [#|j * j|];
373373
// }`);
374374
});
375375

376-
function testExtractMethod(caption: string, text: string) {
377-
testExtractSymbol(caption, text, "extractMethod", Diagnostics.Extract_function);
376+
function testExtractFunction(caption: string, text: string) {
377+
testExtractSymbol(caption, text, "extractFunction", Diagnostics.Extract_function);
378378
}
379379
}

0 commit comments

Comments
 (0)