@@ -551,7 +551,37 @@ class ExpectationsTestCase: XCTestCase {
551
551
RunLoop . main. run ( until: Date ( ) + 1 )
552
552
}
553
553
554
- static var allTests = {
554
+ // CHECK: Test Case 'ExpectationsTestCase.test_waitForExpectationsFromMainActor' started at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
555
+ // CHECK: Test Case 'ExpectationsTestCase.test_waitForExpectationsFromMainActor' failed \(\d+\.\d+ seconds\)
556
+ func test_waitForExpectationsAsync( ) async {
557
+ // Basic check that waitForExpectations() is functional when used with the
558
+ // await keyword in an async function.
559
+ let expectation = self . expectation ( description: " foo " )
560
+ expectation. fulfill ( )
561
+ await self . waitForExpectations ( timeout: 0.0 )
562
+ }
563
+
564
+ // CHECK: Test Case 'ExpectationsTestCase.test_waitForExpectationsFromMainActor' started at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
565
+ // CHECK: Test Case 'ExpectationsTestCase.test_waitForExpectationsFromMainActor' failed \(\d+\.\d+ seconds\)
566
+ @MainActor func test_waitForExpectationsFromMainActor( ) {
567
+ // Basic check that waitForExpectations() is functional and does not need
568
+ // the await keyword when used from a main-actor-isolated test function.
569
+ let expectation = self . expectation ( description: " foo " )
570
+ expectation. fulfill ( )
571
+ self . waitForExpectations ( timeout: 0.0 )
572
+ }
573
+
574
+ // CHECK: Test Case 'ExpectationsTestCase.test_waitForExpectationsFromMainActor_async' started at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
575
+ // CHECK: Test Case 'ExpectationsTestCase.test_waitForExpectationsFromMainActor_async' failed \(\d+\.\d+ seconds\)
576
+ @MainActor func test_waitForExpectationsFromMainActor_async( ) async {
577
+ // Basic check that waitForExpectations() is functional and does not need
578
+ // the await keyword when used from a main-actor-isolated test function.
579
+ let expectation = self . expectation ( description: " foo " )
580
+ expectation. fulfill ( )
581
+ self . waitForExpectations ( timeout: 0.0 )
582
+ }
583
+
584
+ static var allTests : [ ( String , ( ExpectationsTestCase ) -> ( ) throws -> Void ) ] = {
555
585
return [
556
586
( " test_waitingForAnUnfulfilledExpectation_fails " , test_waitingForAnUnfulfilledExpectation_fails) ,
557
587
( " test_waitingForUnfulfilledExpectations_outputsAllExpectations_andFails " , test_waitingForUnfulfilledExpectations_outputsAllExpectations_andFails) ,
@@ -603,15 +633,20 @@ class ExpectationsTestCase: XCTestCase {
603
633
( " test_expectationCreationOnSecondaryThread " , test_expectationCreationOnSecondaryThread) ,
604
634
( " test_expectationCreationWhileWaiting " , test_expectationCreationWhileWaiting) ,
605
635
( " test_runLoopInsideDispatch " , test_runLoopInsideDispatch) ,
636
+
637
+ // waitForExpectations() + @MainActor
638
+ ( " test_waitForExpectationsAsync " , asyncTest ( test_waitForExpectationsAsync) ) ,
639
+ ( " test_waitForExpectationsFromMainActor " , asyncTest { test_waitForExpectationsFromMainActor ( $0) } ) ,
640
+ ( " test_waitForExpectationsFromMainActor_async " , asyncTest { test_waitForExpectationsFromMainActor_async ( $0) } ) ,
606
641
]
607
642
} ( )
608
643
}
609
644
// CHECK: Test Suite 'ExpectationsTestCase' failed at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
610
- // CHECK: \t Executed 35 tests, with 16 failures \(2 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
645
+ // CHECK: \t Executed 38 tests, with 16 failures \(2 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
611
646
612
647
XCTMain ( [ testCase ( ExpectationsTestCase . allTests) ] )
613
648
614
649
// CHECK: Test Suite '.*\.xctest' failed at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
615
- // CHECK: \t Executed 35 tests, with 16 failures \(2 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
650
+ // CHECK: \t Executed 38 tests, with 16 failures \(2 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
616
651
// CHECK: Test Suite 'All tests' failed at \d+-\d+-\d+ \d+:\d+:\d+\.\d+
617
- // CHECK: \t Executed 35 tests, with 16 failures \(2 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
652
+ // CHECK: \t Executed 38 tests, with 16 failures \(2 unexpected\) in \d+\.\d+ \(\d+\.\d+\) seconds
0 commit comments