Skip to content

Commit d117fb1

Browse files
committed
Fix unit tests
1 parent 6c129d7 commit d117fb1

5 files changed

Lines changed: 61 additions & 52 deletions

File tree

Pro

Submodule Pro updated from d1282a4 to eb67d4b

TestPlan.xctestplan

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,13 @@
126126
"identifier" : "GitHubCopilotServiceTests",
127127
"name" : "GitHubCopilotServiceTests"
128128
}
129+
},
130+
{
131+
"target" : {
132+
"containerPath" : "container:Tool",
133+
"identifier" : "FocusedCodeFinderTests",
134+
"name" : "FocusedCodeFinderTests"
135+
}
129136
}
130137
],
131138
"version" : 1

Tool/Tests/FocusedCodeFinderTests/ObjectiveCFocusedCodeFinderTests.swift

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ final class ObjectiveCFocusedCodeFinder_Selection_Tests: XCTestCase {
1919
start: CursorPosition(line: 2, character: 0),
2020
end: CursorPosition(line: 2, character: 4)
2121
)
22-
let context = ObjectiveCFocusedCodeFinder().findFocusedCode(
22+
let context = ObjectiveCFocusedCodeFinder(maxFocusedCodeLineCount: .max).findFocusedCode(
2323
in: document(code: code),
2424
containingRange: range
2525
)
@@ -36,7 +36,7 @@ final class ObjectiveCFocusedCodeFinder_Selection_Tests: XCTestCase {
3636
range: .init(startPair: (1, 0), endPair: (5, 1))
3737
),
3838
]),
39-
contextRange: .init(startPair: (0, 0), endPair: (6, 4)),
39+
contextRange: .init(startPair: (0, 0), endPair: (6, 4)),
4040
smallestContextRange: range,
4141
focusedRange: range,
4242
focusedCode: """
@@ -57,7 +57,7 @@ final class ObjectiveCFocusedCodeFinder_Selection_Tests: XCTestCase {
5757
}
5858
"""
5959
let range = CursorRange(startPair: (2, 0), endPair: (2, 4))
60-
let context = ObjectiveCFocusedCodeFinder().findFocusedCode(
60+
let context = ObjectiveCFocusedCodeFinder(maxFocusedCodeLineCount: .max).findFocusedCode(
6161
in: document(code: code),
6262
containingRange: range
6363
)
@@ -80,7 +80,7 @@ final class ObjectiveCFocusedCodeFinder_Selection_Tests: XCTestCase {
8080
includes: []
8181
))
8282
}
83-
83+
8484
func test_selecting_a_method_inside_an_implementation_the_scope_should_be_the_implementation() {
8585
let code = """
8686
__attribute__((objc_nonlazy_class))
@@ -96,7 +96,7 @@ final class ObjectiveCFocusedCodeFinder_Selection_Tests: XCTestCase {
9696
start: CursorPosition(line: 2, character: 0),
9797
end: CursorPosition(line: 6, character: 1)
9898
)
99-
let context = ObjectiveCFocusedCodeFinder().findFocusedCode(
99+
let context = ObjectiveCFocusedCodeFinder(maxFocusedCodeLineCount: .max).findFocusedCode(
100100
in: document(code: code),
101101
containingRange: range
102102
)
@@ -117,13 +117,13 @@ final class ObjectiveCFocusedCodeFinder_Selection_Tests: XCTestCase {
117117
NSLog(@"Hello");
118118
NSLog(@"World");
119119
}
120-
120+
121121
""",
122122
imports: [],
123123
includes: []
124124
))
125125
}
126-
126+
127127
func test_selecting_a_line_inside_an_interface_the_scope_should_be_the_interface() {
128128
let code = """
129129
@interface ViewController <ObjectType: id<UITableViewDelegate, UITableViewDataSource>>: NSObject <ProtocolName>
@@ -136,7 +136,7 @@ final class ObjectiveCFocusedCodeFinder_Selection_Tests: XCTestCase {
136136
start: CursorPosition(line: 1, character: 0),
137137
end: CursorPosition(line: 3, character: 31)
138138
)
139-
let context = ObjectiveCFocusedCodeFinder().findFocusedCode(
139+
let context = ObjectiveCFocusedCodeFinder(maxFocusedCodeLineCount: .max).findFocusedCode(
140140
in: document(code: code),
141141
containingRange: range
142142
)
@@ -155,13 +155,13 @@ final class ObjectiveCFocusedCodeFinder_Selection_Tests: XCTestCase {
155155
- (void)fooWith:(NSInteger)foo;
156156
- (void)fooWith:(NSInteger)foo;
157157
- (void)fooWith:(NSInteger)foo;
158-
158+
159159
""",
160160
imports: [],
161161
includes: []
162162
))
163163
}
164-
164+
165165
func test_selecting_a_line_inside_an_interface_category_the_scope_should_be_the_interface() {
166166
let code = """
167167
@interface __GENERICS(NSArray, ObjectType) (BlocksKit)
@@ -174,7 +174,7 @@ final class ObjectiveCFocusedCodeFinder_Selection_Tests: XCTestCase {
174174
start: CursorPosition(line: 1, character: 0),
175175
end: CursorPosition(line: 3, character: 31)
176176
)
177-
let context = ObjectiveCFocusedCodeFinder().findFocusedCode(
177+
let context = ObjectiveCFocusedCodeFinder(maxFocusedCodeLineCount: .max).findFocusedCode(
178178
in: document(code: code),
179179
containingRange: range
180180
)
@@ -193,13 +193,13 @@ final class ObjectiveCFocusedCodeFinder_Selection_Tests: XCTestCase {
193193
- (void)fooWith:(NSInteger)foo;
194194
- (void)fooWith:(NSInteger)foo;
195195
- (void)fooWith:(NSInteger)foo;
196-
196+
197197
""",
198198
imports: [],
199199
includes: []
200200
))
201201
}
202-
202+
203203
func test_selecting_a_line_inside_a_protocol_the_scope_should_be_the_protocol() {
204204
let code = """
205205
@protocol Foo<A, B>
@@ -212,7 +212,7 @@ final class ObjectiveCFocusedCodeFinder_Selection_Tests: XCTestCase {
212212
start: CursorPosition(line: 1, character: 0),
213213
end: CursorPosition(line: 3, character: 31)
214214
)
215-
let context = ObjectiveCFocusedCodeFinder().findFocusedCode(
215+
let context = ObjectiveCFocusedCodeFinder(maxFocusedCodeLineCount: .max).findFocusedCode(
216216
in: document(code: code),
217217
containingRange: range
218218
)
@@ -231,13 +231,13 @@ final class ObjectiveCFocusedCodeFinder_Selection_Tests: XCTestCase {
231231
- (void)fooWith:(NSInteger)foo;
232232
- (void)fooWith:(NSInteger)foo;
233233
- (void)fooWith:(NSInteger)foo;
234-
234+
235235
""",
236236
imports: [],
237237
includes: []
238238
))
239239
}
240-
240+
241241
func test_selecting_a_line_inside_a_struct_the_scope_should_be_the_struct() {
242242
let code = """
243243
struct Foo {
@@ -250,7 +250,7 @@ final class ObjectiveCFocusedCodeFinder_Selection_Tests: XCTestCase {
250250
start: CursorPosition(line: 1, character: 0),
251251
end: CursorPosition(line: 3, character: 31)
252252
)
253-
let context = ObjectiveCFocusedCodeFinder().findFocusedCode(
253+
let context = ObjectiveCFocusedCodeFinder(maxFocusedCodeLineCount: .max).findFocusedCode(
254254
in: document(code: code),
255255
containingRange: range
256256
)
@@ -269,13 +269,13 @@ final class ObjectiveCFocusedCodeFinder_Selection_Tests: XCTestCase {
269269
NSInteger foo;
270270
NSInteger bar;
271271
NSInteger baz;
272-
272+
273273
""",
274274
imports: [],
275275
includes: []
276276
))
277277
}
278-
278+
279279
func test_selecting_a_line_inside_a_enum_the_scope_should_be_the_enum() {
280280
let code = """
281281
enum Foo {
@@ -288,7 +288,7 @@ final class ObjectiveCFocusedCodeFinder_Selection_Tests: XCTestCase {
288288
start: CursorPosition(line: 1, character: 0),
289289
end: CursorPosition(line: 3, character: 31)
290290
)
291-
let context = ObjectiveCFocusedCodeFinder().findFocusedCode(
291+
let context = ObjectiveCFocusedCodeFinder(maxFocusedCodeLineCount: .max).findFocusedCode(
292292
in: document(code: code),
293293
containingRange: range
294294
)
@@ -307,13 +307,13 @@ final class ObjectiveCFocusedCodeFinder_Selection_Tests: XCTestCase {
307307
foo,
308308
bar,
309309
baz
310-
310+
311311
""",
312312
imports: [],
313313
includes: []
314314
))
315315
}
316-
316+
317317
func test_selecting_a_line_inside_an_NSEnum_the_scope_should_be_the_enum() {
318318
let code = """
319319
typedef NS_ENUM(NSInteger, Foo) {
@@ -326,7 +326,7 @@ final class ObjectiveCFocusedCodeFinder_Selection_Tests: XCTestCase {
326326
start: CursorPosition(line: 1, character: 0),
327327
end: CursorPosition(line: 3, character: 31)
328328
)
329-
let context = ObjectiveCFocusedCodeFinder().findFocusedCode(
329+
let context = ObjectiveCFocusedCodeFinder(maxFocusedCodeLineCount: .max).findFocusedCode(
330330
in: document(code: code),
331331
containingRange: range
332332
)
@@ -345,7 +345,7 @@ final class ObjectiveCFocusedCodeFinder_Selection_Tests: XCTestCase {
345345
foo,
346346
bar,
347347
baz
348-
348+
349349
""",
350350
imports: [],
351351
includes: []
@@ -368,7 +368,7 @@ final class ObjectiveCFocusedCodeFinder_Focus_Tests: XCTestCase {
368368
start: CursorPosition(line: 2, character: 0),
369369
end: CursorPosition(line: 2, character: 0)
370370
)
371-
let context = ObjectiveCFocusedCodeFinder().findFocusedCode(
371+
let context = ObjectiveCFocusedCodeFinder(maxFocusedCodeLineCount: .max).findFocusedCode(
372372
in: document(code: code),
373373
containingRange: range
374374
)
@@ -381,52 +381,53 @@ final class ObjectiveCFocusedCodeFinder_Focus_Tests: XCTestCase {
381381
),
382382
]),
383383
contextRange: .init(startPair: (0, 0), endPair: (6, 4)),
384-
smallestContextRange: range,
384+
smallestContextRange: .init(startPair: (1, 0), endPair: (5, 1)),
385385
focusedRange: .init(startPair: (1, 0), endPair: (5, 1)),
386386
focusedCode: """
387387
- (void)fooWith:(NSInteger)foo {
388388
NSInteger foo = 0;
389389
NSLog(@"Hello");
390390
NSLog(@"World");
391391
}
392-
392+
393393
""",
394394
imports: [],
395395
includes: []
396396
))
397397
}
398-
399-
func test_get_focused_code_inside_an_interface_category_the_focused_code_should_be_the_interface() {
398+
399+
func test_get_focused_code_inside_an_interface_category_the_focused_code_should_be_the_interface(
400+
) {
400401
let code = """
401402
@interface __GENERICS(NSArray, ObjectType) (BlocksKit)
402403
- (void)fooWith:(NSInteger)foo;
403404
- (void)fooWith:(NSInteger)foo;
404405
- (void)fooWith:(NSInteger)foo;
405406
@end
406-
407+
407408
@implementation Foo
408409
@end
409410
"""
410411
let range = CursorRange(
411412
start: CursorPosition(line: 1, character: 0),
412413
end: CursorPosition(line: 1, character: 0)
413414
)
414-
let context = ObjectiveCFocusedCodeFinder().findFocusedCode(
415+
let context = ObjectiveCFocusedCodeFinder(maxFocusedCodeLineCount: .max).findFocusedCode(
415416
in: document(code: code),
416417
containingRange: range
417418
)
418419
XCTAssertEqual(context, .init(
419420
scope: .file,
420421
contextRange: .init(startPair: (0, 0), endPair: (0, 0)),
421-
smallestContextRange: range,
422+
smallestContextRange: .init(startPair: (0, 0), endPair: (4, 4)),
422423
focusedRange: .init(startPair: (0, 0), endPair: (4, 4)),
423424
focusedCode: """
424425
@interface __GENERICS(NSArray, ObjectType) (BlocksKit)
425426
- (void)fooWith:(NSInteger)foo;
426427
- (void)fooWith:(NSInteger)foo;
427428
- (void)fooWith:(NSInteger)foo;
428429
@end
429-
430+
430431
""",
431432
imports: [],
432433
includes: []
@@ -442,19 +443,20 @@ final class ObjectiveCFocusedCodeFinder_Imports_Tests: XCTestCase {
442443
#import "Foo.h"
443444
#include "Bar.h"
444445
"""
445-
446-
let context = ObjectiveCFocusedCodeFinder().findFocusedCode(
446+
447+
let context = ObjectiveCFocusedCodeFinder(maxFocusedCodeLineCount: .max).findFocusedCode(
447448
in: document(code: code),
448449
containingRange: .zero
449450
)
450-
451+
451452
XCTAssertEqual(context.imports, [
452453
"<Foundation/Foundation.h>",
453454
"UIKit",
454-
"\"Foo.h\""
455+
"\"Foo.h\"",
455456
])
456457
XCTAssertEqual(context.includes, [
457-
"\"Bar.h\""
458+
"\"Bar.h\"",
458459
])
459460
}
460461
}
462+

Tool/Tests/FocusedCodeFinderTests/SwiftFocusedCodeFinderTests.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ final class SwiftFocusedCodeFinder_Selection_Tests: XCTestCase {
2929
start: CursorPosition(line: 4, character: 0),
3030
end: CursorPosition(line: 4, character: 13)
3131
)
32-
let context = SwiftFocusedCodeFinder().findFocusedCode(
32+
let context = SwiftFocusedCodeFinder(maxFocusedCodeLineCount: .max).findFocusedCode(
3333
in: document(code: code),
3434
containingRange: range
3535
)
@@ -75,7 +75,7 @@ final class SwiftFocusedCodeFinder_Selection_Tests: XCTestCase {
7575
start: CursorPosition(line: 2, character: 0),
7676
end: CursorPosition(line: 7, character: 5)
7777
)
78-
let context = SwiftFocusedCodeFinder().findFocusedCode(
78+
let context = SwiftFocusedCodeFinder(maxFocusedCodeLineCount: .max).findFocusedCode(
7979
in: document(code: code),
8080
containingRange: range
8181
)
@@ -118,7 +118,7 @@ final class SwiftFocusedCodeFinder_Selection_Tests: XCTestCase {
118118
start: CursorPosition(line: 1, character: 0),
119119
end: CursorPosition(line: 1, character: 9)
120120
)
121-
let context = SwiftFocusedCodeFinder().findFocusedCode(
121+
let context = SwiftFocusedCodeFinder(maxFocusedCodeLineCount: .max).findFocusedCode(
122122
in: document(code: code),
123123
containingRange: range
124124
)
@@ -156,7 +156,7 @@ final class SwiftFocusedCodeFinder_Selection_Tests: XCTestCase {
156156
start: CursorPosition(line: 1, character: 0),
157157
end: CursorPosition(line: 1, character: 9)
158158
)
159-
let context = SwiftFocusedCodeFinder().findFocusedCode(
159+
let context = SwiftFocusedCodeFinder(maxFocusedCodeLineCount: .max).findFocusedCode(
160160
in: document(code: code),
161161
containingRange: range
162162
)
@@ -194,7 +194,7 @@ final class SwiftFocusedCodeFinder_Selection_Tests: XCTestCase {
194194
start: CursorPosition(line: 1, character: 0),
195195
end: CursorPosition(line: 1, character: 9)
196196
)
197-
let context = SwiftFocusedCodeFinder().findFocusedCode(
197+
let context = SwiftFocusedCodeFinder(maxFocusedCodeLineCount: .max).findFocusedCode(
198198
in: document(code: code),
199199
containingRange: range
200200
)
@@ -233,7 +233,7 @@ final class SwiftFocusedCodeFinder_Selection_Tests: XCTestCase {
233233
start: CursorPosition(line: 2, character: 0),
234234
end: CursorPosition(line: 2, character: 9)
235235
)
236-
let context = SwiftFocusedCodeFinder().findFocusedCode(
236+
let context = SwiftFocusedCodeFinder(maxFocusedCodeLineCount: .max).findFocusedCode(
237237
in: document(code: code),
238238
containingRange: range
239239
)
@@ -273,7 +273,7 @@ final class SwiftFocusedCodeFinder_Selection_Tests: XCTestCase {
273273
start: CursorPosition(line: 3, character: 0),
274274
end: CursorPosition(line: 3, character: 9)
275275
)
276-
let context = SwiftFocusedCodeFinder().findFocusedCode(
276+
let context = SwiftFocusedCodeFinder(maxFocusedCodeLineCount: .max).findFocusedCode(
277277
in: document(code: code),
278278
containingRange: range
279279
)
@@ -313,7 +313,7 @@ final class SwiftFocusedCodeFinder_Selection_Tests: XCTestCase {
313313
start: CursorPosition(line: 2, character: 0),
314314
end: CursorPosition(line: 2, character: 9)
315315
)
316-
let context = SwiftFocusedCodeFinder().findFocusedCode(
316+
let context = SwiftFocusedCodeFinder(maxFocusedCodeLineCount: .max).findFocusedCode(
317317
in: document(code: code),
318318
containingRange: range
319319
)
@@ -456,7 +456,7 @@ final class SwiftFocusedCodeFinder_FocusedCode_Tests: XCTestCase {
456456
XCTAssertEqual(context, .init(
457457
scope: .file,
458458
contextRange: .init(startPair: (0, 0), endPair: (0, 0)),
459-
smallestContextRange: .init(startPair: (2, 0), endPair: (4, 11)),
459+
smallestContextRange: .init(startPair: (0, 0), endPair: (8, 1)),
460460
focusedRange: .init(startPair: (2, 0), endPair: (4, 11)),
461461
focusedCode: """
462462
indirect enum A {

0 commit comments

Comments
 (0)