@@ -24,7 +24,7 @@ final class DoccDocumentationTests: XCTestCase {
24
24
try await renderDocumentation (
25
25
swiftFile: " 0️⃣ " ,
26
26
expectedResponses: [
27
- . error( . noDocumentation)
27
+ " 0️⃣ " : . error( . noDocumentation)
28
28
]
29
29
)
30
30
}
@@ -38,10 +38,10 @@ final class DoccDocumentationTests: XCTestCase {
38
38
}3️⃣
39
39
""" ,
40
40
expectedResponses: [
41
- . renderNode( kind: . symbol, path: " test/function() " ) ,
42
- . renderNode( kind: . symbol, path: " test/function() " ) ,
43
- . renderNode( kind: . symbol, path: " test/function() " ) ,
44
- . error( . noDocumentation) ,
41
+ " 0️⃣ " : . renderNode( kind: . symbol, path: " test/function() " ) ,
42
+ " 1️⃣ " : . renderNode( kind: . symbol, path: " test/function() " ) ,
43
+ " 2️⃣ " : . renderNode( kind: . symbol, path: " test/function() " ) ,
44
+ " 3️⃣ " : . error( . noDocumentation) ,
45
45
]
46
46
)
47
47
}
@@ -65,15 +65,15 @@ final class DoccDocumentationTests: XCTestCase {
65
65
}8️⃣
66
66
""" ,
67
67
expectedResponses: [
68
- . renderNode( kind: . symbol, path: " test/Structure " ) ,
69
- . renderNode( kind: . symbol, path: " test/Structure " ) ,
70
- . renderNode( kind: . symbol, path: " test/Structure/foo " ) ,
71
- . renderNode( kind: . symbol, path: " test/Structure/foo " ) ,
72
- . renderNode( kind: . symbol, path: " test/Structure/bar " ) ,
73
- . renderNode( kind: . symbol, path: " test/Structure/bar " ) ,
74
- . renderNode( kind: . symbol, path: " test/Structure/init(_:bar:) " ) ,
75
- . renderNode( kind: . symbol, path: " test/Structure/init(_:bar:) " ) ,
76
- . error( . noDocumentation) ,
68
+ " 0️⃣ " : . renderNode( kind: . symbol, path: " test/Structure " ) ,
69
+ " 1️⃣ " : . renderNode( kind: . symbol, path: " test/Structure " ) ,
70
+ " 2️⃣ " : . renderNode( kind: . symbol, path: " test/Structure/foo " ) ,
71
+ " 3️⃣ " : . renderNode( kind: . symbol, path: " test/Structure/foo " ) ,
72
+ " 4️⃣ " : . renderNode( kind: . symbol, path: " test/Structure/bar " ) ,
73
+ " 5️⃣ " : . renderNode( kind: . symbol, path: " test/Structure/bar " ) ,
74
+ " 6️⃣ " : . renderNode( kind: . symbol, path: " test/Structure/init(_:bar:) " ) ,
75
+ " 7️⃣ " : . renderNode( kind: . symbol, path: " test/Structure/init(_:bar:) " ) ,
76
+ " 8️⃣ " : . error( . noDocumentation) ,
77
77
]
78
78
)
79
79
}
@@ -86,10 +86,10 @@ final class DoccDocumentationTests: XCTestCase {
86
86
}3️⃣
87
87
""" ,
88
88
expectedResponses: [
89
- . renderNode( kind: . symbol, path: " test/Structure " ) ,
90
- . renderNode( kind: . symbol, path: " test/Structure " ) ,
91
- . renderNode( kind: . symbol, path: " test/Structure " ) ,
92
- . error( . noDocumentation) ,
89
+ " 0️⃣ " : . renderNode( kind: . symbol, path: " test/Structure " ) ,
90
+ " 1️⃣ " : . renderNode( kind: . symbol, path: " test/Structure " ) ,
91
+ " 2️⃣ " : . renderNode( kind: . symbol, path: " test/Structure " ) ,
92
+ " 3️⃣ " : . error( . noDocumentation) ,
93
93
]
94
94
)
95
95
}
@@ -113,16 +113,16 @@ final class DoccDocumentationTests: XCTestCase {
113
113
}9️⃣
114
114
""" ,
115
115
expectedResponses: [
116
- . renderNode( kind: . symbol, path: " test/Class " ) ,
117
- . renderNode( kind: . symbol, path: " test/Class " ) ,
118
- . renderNode( kind: . symbol, path: " test/Class/foo " ) ,
119
- . renderNode( kind: . symbol, path: " test/Class/foo " ) ,
120
- . renderNode( kind: . symbol, path: " test/Class/bar " ) ,
121
- . renderNode( kind: . symbol, path: " test/Class/bar " ) ,
122
- . renderNode( kind: . symbol, path: " test/Class/init(_:bar:) " ) ,
123
- . renderNode( kind: . symbol, path: " test/Class/init(_:bar:) " ) ,
124
- . renderNode( kind: . symbol, path: " test/Class " ) ,
125
- . error( . noDocumentation) ,
116
+ " 0️⃣ " : . renderNode( kind: . symbol, path: " test/Class " ) ,
117
+ " 1️⃣ " : . renderNode( kind: . symbol, path: " test/Class " ) ,
118
+ " 2️⃣ " : . renderNode( kind: . symbol, path: " test/Class/foo " ) ,
119
+ " 3️⃣ " : . renderNode( kind: . symbol, path: " test/Class/foo " ) ,
120
+ " 4️⃣ " : . renderNode( kind: . symbol, path: " test/Class/bar " ) ,
121
+ " 5️⃣ " : . renderNode( kind: . symbol, path: " test/Class/bar " ) ,
122
+ " 6️⃣ " : . renderNode( kind: . symbol, path: " test/Class/init(_:bar:) " ) ,
123
+ " 7️⃣ " : . renderNode( kind: . symbol, path: " test/Class/init(_:bar:) " ) ,
124
+ " 8️⃣ " : . renderNode( kind: . symbol, path: " test/Class " ) ,
125
+ " 9️⃣ " : . error( . noDocumentation) ,
126
126
]
127
127
)
128
128
}
@@ -135,10 +135,10 @@ final class DoccDocumentationTests: XCTestCase {
135
135
}3️⃣
136
136
""" ,
137
137
expectedResponses: [
138
- . renderNode( kind: . symbol, path: " test/Class " ) ,
139
- . renderNode( kind: . symbol, path: " test/Class " ) ,
140
- . renderNode( kind: . symbol, path: " test/Class " ) ,
141
- . error( . noDocumentation) ,
138
+ " 0️⃣ " : . renderNode( kind: . symbol, path: " test/Class " ) ,
139
+ " 1️⃣ " : . renderNode( kind: . symbol, path: " test/Class " ) ,
140
+ " 2️⃣ " : . renderNode( kind: . symbol, path: " test/Class " ) ,
141
+ " 3️⃣ " : . error( . noDocumentation) ,
142
142
]
143
143
)
144
144
}
@@ -162,15 +162,15 @@ final class DoccDocumentationTests: XCTestCase {
162
162
}8️⃣
163
163
""" ,
164
164
expectedResponses: [
165
- . renderNode( kind: . symbol, path: " test/Actor " ) ,
166
- . renderNode( kind: . symbol, path: " test/Actor " ) ,
167
- . renderNode( kind: . symbol, path: " test/Actor/foo " ) ,
168
- . renderNode( kind: . symbol, path: " test/Actor/foo " ) ,
169
- . renderNode( kind: . symbol, path: " test/Actor/bar " ) ,
170
- . renderNode( kind: . symbol, path: " test/Actor/bar " ) ,
171
- . renderNode( kind: . symbol, path: " test/Actor/init(_:bar:) " ) ,
172
- . renderNode( kind: . symbol, path: " test/Actor/init(_:bar:) " ) ,
173
- . error( . noDocumentation) ,
165
+ " 0️⃣ " : . renderNode( kind: . symbol, path: " test/Actor " ) ,
166
+ " 1️⃣ " : . renderNode( kind: . symbol, path: " test/Actor " ) ,
167
+ " 2️⃣ " : . renderNode( kind: . symbol, path: " test/Actor/foo " ) ,
168
+ " 3️⃣ " : . renderNode( kind: . symbol, path: " test/Actor/foo " ) ,
169
+ " 4️⃣ " : . renderNode( kind: . symbol, path: " test/Actor/bar " ) ,
170
+ " 5️⃣ " : . renderNode( kind: . symbol, path: " test/Actor/bar " ) ,
171
+ " 6️⃣ " : . renderNode( kind: . symbol, path: " test/Actor/init(_:bar:) " ) ,
172
+ " 7️⃣ " : . renderNode( kind: . symbol, path: " test/Actor/init(_:bar:) " ) ,
173
+ " 8️⃣ " : . error( . noDocumentation) ,
174
174
]
175
175
)
176
176
}
@@ -183,10 +183,10 @@ final class DoccDocumentationTests: XCTestCase {
183
183
}3️⃣
184
184
""" ,
185
185
expectedResponses: [
186
- . renderNode( kind: . symbol, path: " test/Actor " ) ,
187
- . renderNode( kind: . symbol, path: " test/Actor " ) ,
188
- . renderNode( kind: . symbol, path: " test/Actor " ) ,
189
- . error( . noDocumentation) ,
186
+ " 0️⃣ " : . renderNode( kind: . symbol, path: " test/Actor " ) ,
187
+ " 1️⃣ " : . renderNode( kind: . symbol, path: " test/Actor " ) ,
188
+ " 2️⃣ " : . renderNode( kind: . symbol, path: " test/Actor " ) ,
189
+ " 3️⃣ " : . error( . noDocumentation) ,
190
190
]
191
191
)
192
192
}
@@ -207,15 +207,15 @@ final class DoccDocumentationTests: XCTestCase {
207
207
}8️⃣
208
208
""" ,
209
209
expectedResponses: [
210
- . renderNode( kind: . symbol, path: " test/Enum " ) ,
211
- . renderNode( kind: . symbol, path: " test/Enum " ) ,
212
- . renderNode( kind: . symbol, path: " test/Enum/first " ) ,
213
- . renderNode( kind: . symbol, path: " test/Enum/first " ) ,
214
- . renderNode( kind: . symbol, path: " test/Enum/second " ) ,
215
- . renderNode( kind: . symbol, path: " test/Enum/second " ) ,
216
- . renderNode( kind: . symbol, path: " test/Enum/third(_:) " ) ,
217
- . renderNode( kind: . symbol, path: " test/Enum/third(_:) " ) ,
218
- . error( . noDocumentation) ,
210
+ " 0️⃣ " : . renderNode( kind: . symbol, path: " test/Enum " ) ,
211
+ " 1️⃣ " : . renderNode( kind: . symbol, path: " test/Enum " ) ,
212
+ " 2️⃣ " : . renderNode( kind: . symbol, path: " test/Enum/first " ) ,
213
+ " 3️⃣ " : . renderNode( kind: . symbol, path: " test/Enum/first " ) ,
214
+ " 4️⃣ " : . renderNode( kind: . symbol, path: " test/Enum/second " ) ,
215
+ " 5️⃣ " : . renderNode( kind: . symbol, path: " test/Enum/second " ) ,
216
+ " 6️⃣ " : . renderNode( kind: . symbol, path: " test/Enum/third(_:) " ) ,
217
+ " 7️⃣ " : . renderNode( kind: . symbol, path: " test/Enum/third(_:) " ) ,
218
+ " 8️⃣ " : . error( . noDocumentation) ,
219
219
]
220
220
)
221
221
}
@@ -245,7 +245,7 @@ final class DoccDocumentationTests: XCTestCase {
245
245
testClient: testClient,
246
246
uri: uri,
247
247
positions: positions,
248
- expectedResponses: [ . renderNode( kind: . symbol, containing: " The second case " ) ]
248
+ expectedResponses: [ " 0️⃣ " : . renderNode( kind: . symbol, containing: " The second case " ) ]
249
249
)
250
250
251
251
// Change the content of the documentation comment
@@ -263,7 +263,7 @@ final class DoccDocumentationTests: XCTestCase {
263
263
testClient: testClient,
264
264
uri: uri,
265
265
positions: positions,
266
- expectedResponses: [ . renderNode( kind: . symbol, containing: " The very second case " ) ]
266
+ expectedResponses: [ " 0️⃣ " : . renderNode( kind: . symbol, containing: " The very second case " ) ]
267
267
)
268
268
}
269
269
@@ -280,13 +280,13 @@ final class DoccDocumentationTests: XCTestCase {
280
280
}6️⃣
281
281
""" ,
282
282
expectedResponses: [
283
- . renderNode( kind: . symbol, path: " test/Protocol " ) ,
284
- . renderNode( kind: . symbol, path: " test/Protocol " ) ,
285
- . renderNode( kind: . symbol, path: " test/Protocol/foo " ) ,
286
- . renderNode( kind: . symbol, path: " test/Protocol/foo " ) ,
287
- . renderNode( kind: . symbol, path: " test/Protocol/bar " ) ,
288
- . renderNode( kind: . symbol, path: " test/Protocol/bar " ) ,
289
- . error( . noDocumentation) ,
283
+ " 0️⃣ " : . renderNode( kind: . symbol, path: " test/Protocol " ) ,
284
+ " 1️⃣ " : . renderNode( kind: . symbol, path: " test/Protocol " ) ,
285
+ " 2️⃣ " : . renderNode( kind: . symbol, path: " test/Protocol/foo " ) ,
286
+ " 3️⃣ " : . renderNode( kind: . symbol, path: " test/Protocol/foo " ) ,
287
+ " 4️⃣ " : . renderNode( kind: . symbol, path: " test/Protocol/bar " ) ,
288
+ " 5️⃣ " : . renderNode( kind: . symbol, path: " test/Protocol/bar " ) ,
289
+ " 6️⃣ " : . error( . noDocumentation) ,
290
290
]
291
291
)
292
292
}
@@ -300,10 +300,10 @@ final class DoccDocumentationTests: XCTestCase {
300
300
}3️⃣
301
301
""" ,
302
302
expectedResponses: [
303
- . renderNode( kind: . symbol, path: " test/Protocol " ) ,
304
- . renderNode( kind: . symbol, path: " test/Protocol " ) ,
305
- . renderNode( kind: . symbol, path: " test/Protocol " ) ,
306
- . error( . noDocumentation) ,
303
+ " 0️⃣ " : . renderNode( kind: . symbol, path: " test/Protocol " ) ,
304
+ " 1️⃣ " : . renderNode( kind: . symbol, path: " test/Protocol " ) ,
305
+ " 2️⃣ " : . renderNode( kind: . symbol, path: " test/Protocol " ) ,
306
+ " 3️⃣ " : . error( . noDocumentation) ,
307
307
]
308
308
)
309
309
}
@@ -330,12 +330,12 @@ final class DoccDocumentationTests: XCTestCase {
330
330
}5️⃣
331
331
""" ,
332
332
expectedResponses: [
333
- . error( . noDocumentation) ,
334
- . renderNode( kind: . symbol, path: " test/Structure/numberPlusOne " ) ,
335
- . renderNode( kind: . symbol, path: " test/Structure/Kind " ) ,
336
- . renderNode( kind: . symbol, path: " test/Structure/Kind/first " ) ,
337
- . renderNode( kind: . symbol, path: " test/Structure/Kind/second " ) ,
338
- . error( . noDocumentation) ,
333
+ " 0️⃣ " : . error( . noDocumentation) ,
334
+ " 1️⃣ " : . renderNode( kind: . symbol, path: " test/Structure/numberPlusOne " ) ,
335
+ " 2️⃣ " : . renderNode( kind: . symbol, path: " test/Structure/Kind " ) ,
336
+ " 3️⃣ " : . renderNode( kind: . symbol, path: " test/Structure/Kind/first " ) ,
337
+ " 4️⃣ " : . renderNode( kind: . symbol, path: " test/Structure/Kind/second " ) ,
338
+ " 5️⃣ " : . error( . noDocumentation) ,
339
339
]
340
340
)
341
341
}
@@ -358,7 +358,7 @@ final class DoccDocumentationTests: XCTestCase {
358
358
testClient: testClient,
359
359
uri: uri,
360
360
positions: positions,
361
- expectedResponses: [ . renderNode( kind: . symbol, containing: " A structure containing important information " ) ]
361
+ expectedResponses: [ " 0️⃣ " : . renderNode( kind: . symbol, containing: " A structure containing important information " ) ]
362
362
)
363
363
364
364
// Change the content of the documentation comment
@@ -376,7 +376,9 @@ final class DoccDocumentationTests: XCTestCase {
376
376
testClient: testClient,
377
377
uri: uri,
378
378
positions: positions,
379
- expectedResponses: [ . renderNode( kind: . symbol, containing: " A structure containing very important information " ) ]
379
+ expectedResponses: [
380
+ " 0️⃣ " : . renderNode( kind: . symbol, containing: " A structure containing very important information " )
381
+ ]
380
382
)
381
383
}
382
384
@@ -400,7 +402,7 @@ final class DoccDocumentationTests: XCTestCase {
400
402
testClient: testClient,
401
403
uri: uri,
402
404
positions: positions,
403
- expectedResponses: [ . renderNode( kind: . symbol, containing: " This is a description " ) ]
405
+ expectedResponses: [ " 0️⃣ " : . renderNode( kind: . symbol, containing: " This is a description " ) ]
404
406
)
405
407
406
408
// Change the content of the documentation comment
@@ -418,7 +420,7 @@ final class DoccDocumentationTests: XCTestCase {
418
420
testClient: testClient,
419
421
uri: uri,
420
422
positions: positions,
421
- expectedResponses: [ . renderNode( kind: . symbol, containing: " This is an amazing description " ) ]
423
+ expectedResponses: [ " 0️⃣ " : . renderNode( kind: . symbol, containing: " This is an amazing description " ) ]
422
424
)
423
425
}
424
426
@@ -444,7 +446,7 @@ final class DoccDocumentationTests: XCTestCase {
444
446
testClient: testClient,
445
447
uri: uri,
446
448
positions: positions,
447
- expectedResponses: [ . renderNode( kind: . symbol, containing: " This is a description " ) ]
449
+ expectedResponses: [ " 0️⃣ " : . renderNode( kind: . symbol, containing: " This is a description " ) ]
448
450
)
449
451
450
452
// Change the content of the documentation comment
@@ -462,7 +464,7 @@ final class DoccDocumentationTests: XCTestCase {
462
464
testClient: testClient,
463
465
uri: uri,
464
466
positions: positions,
465
- expectedResponses: [ . renderNode( kind: . symbol, containing: " This is an amazing description " ) ]
467
+ expectedResponses: [ " 0️⃣ " : . renderNode( kind: . symbol, containing: " This is an amazing description " ) ]
466
468
)
467
469
}
468
470
}
@@ -474,7 +476,7 @@ fileprivate enum PartialConvertResponse {
474
476
475
477
fileprivate func renderDocumentation(
476
478
swiftFile markedText: String ,
477
- expectedResponses: [ PartialConvertResponse ] ,
479
+ expectedResponses: [ String : PartialConvertResponse ] ,
478
480
file: StaticString = #filePath,
479
481
line: UInt = #line
480
482
) async throws {
@@ -496,27 +498,22 @@ fileprivate func renderDocumentation(
496
498
testClient: TestSourceKitLSPClient ,
497
499
uri: DocumentURI ,
498
500
positions: DocumentPositions ,
499
- expectedResponses: [ PartialConvertResponse ] ,
501
+ expectedResponses: [ String : PartialConvertResponse ] ,
500
502
file: StaticString = #filePath,
501
503
line: UInt = #line
502
504
) async {
503
- guard expectedResponses. count == positions. allMarkers. count else {
504
- XCTFail (
505
- " the number of expected responses did not match the number of positions in the text document " ,
506
- file: file,
507
- line: line
508
- )
509
- return
510
- }
511
-
512
- for (index, marker) in positions. allMarkers. enumerated ( ) {
513
- let response = await testClient. sendWithRawResponse (
505
+ for marker in positions. allMarkers {
506
+ guard let expectedResponse = expectedResponses [ marker] else {
507
+ XCTFail ( " No expected response was given for marker \( marker) " , file: file, line: line)
508
+ return
509
+ }
510
+ let actualResponse = await testClient. sendWithRawResponse (
514
511
DoccDocumentationRequest (
515
512
textDocument: TextDocumentIdentifier ( uri) ,
516
513
position: positions [ marker]
517
514
)
518
515
)
519
- switch response {
516
+ switch actualResponse {
520
517
case . success( let response) :
521
518
let renderNodeString = response. renderNode
522
519
guard let renderNodeData = renderNodeString. data ( using: . utf8) ,
@@ -525,7 +522,7 @@ fileprivate func renderDocumentation(
525
522
XCTFail ( " failed to decode response from textDocument/doccDocumentation at position \( marker) " )
526
523
return
527
524
}
528
- switch expectedResponses [ index ] {
525
+ switch expectedResponse {
529
526
case . renderNode( let expectedKind, let expectedPath, let expectedContents) :
530
527
XCTAssertEqual (
531
528
renderNode. kind,
@@ -559,7 +556,7 @@ fileprivate func renderDocumentation(
559
556
)
560
557
}
561
558
case . failure( let error) :
562
- switch expectedResponses [ index ] {
559
+ switch expectedResponse {
563
560
case . renderNode:
564
561
XCTFail (
565
562
" textDocument/doccDocumentation failed at position \( marker) : \( error. localizedDescription) " ,
0 commit comments