@@ -575,37 +575,35 @@ final class SwiftCompletionTests: XCTestCase {
575
575
textDocument: TextDocumentIdentifier ( url) ,
576
576
position: Position ( line: 8 , utf16index: 12 ) , // prin^
577
577
context: CompletionContext ( triggerKind: . invoked) )
578
- let coordinationGroup = DispatchGroup ( )
579
578
580
579
// Code completion for "self.forSome"
581
- coordinationGroup . enter ( )
580
+ let forSomeExpectation = XCTestExpectation ( description : " self.forSome code completion " )
582
581
_ = sk. send ( forSomeComplete) { result in
583
- defer { coordinationGroup . leave ( ) }
582
+ defer { forSomeExpectation . fulfill ( ) }
584
583
guard let list = result. success else {
585
584
XCTFail ( " Request failed: \( String ( describing: result. failure) ) " )
586
585
return
587
586
}
588
- XCTAssert ( countFs ( list) == 2 )
587
+ XCTAssertEqual ( 2 , countFs ( list) )
589
588
}
590
589
591
590
// Code completion for "self.prin", previously could immediately invalidate
592
591
// the previous request.
593
- coordinationGroup . enter ( )
592
+ let printExpectation = XCTestExpectation ( description : " self.prin code completion " )
594
593
_ = sk. send ( printComplete) { result in
595
- defer { coordinationGroup . leave ( ) }
594
+ defer { printExpectation . fulfill ( ) }
596
595
guard let list = result. success else {
597
596
XCTFail ( " Request failed: \( String ( describing: result. failure) ) " )
598
597
return
599
598
}
600
- XCTAssertEqual ( list. items. count, 1 )
599
+ XCTAssertEqual ( 1 , list. items. count)
601
600
}
602
601
603
- // Wait for the previous 2 completions to finish.
604
- coordinationGroup. wait ( )
602
+ wait ( for: [ forSomeExpectation, printExpectation] , timeout: 10 )
605
603
606
604
// Try code completion for "self.forSome" again to verify that it still works.
607
605
let result = try sk. sendSync ( forSomeComplete)
608
- XCTAssert ( countFs ( result) == 2 )
606
+ XCTAssertEqual ( 2 , countFs ( result) )
609
607
}
610
608
}
611
609
0 commit comments