@@ -68,6 +68,33 @@ func test_taskGroup_noThrow_ifNotAwaitedThrowingTask() async {
68
68
print ( " Expected no error to be thrown, got: \( got) " ) // CHECK: Expected no error to be thrown, got: 1
69
69
}
70
70
71
+ func test_taskGroup_throw_rethrows_waitForAll( ) async {
72
+ print ( " ==== \( #function) ------ " ) // CHECK-LABEL: test_taskGroup_throw_rethrows_waitForAll
73
+ do {
74
+ _ = try await withThrowingTaskGroup ( of: Int . self) { group in
75
+ group. addTask {
76
+ throw CancellationError ( )
77
+ }
78
+ group. addTask {
79
+ 1
80
+ }
81
+
82
+ do {
83
+ try await group. waitForAll ( )
84
+ } catch {
85
+ print ( " waitAll rethrown: " , error)
86
+ // CHECK: waitAll rethrown: CancellationError()
87
+ print ( " isEmpty: " , group. isEmpty)
88
+ // CHECK: isEmpty: true
89
+ throw error
90
+ }
91
+ }
92
+ } catch {
93
+ print ( " rethrown: " , error)
94
+ // CHECK: rethrown: CancellationError()
95
+ }
96
+ }
97
+
71
98
func test_discardingTaskGroup_automaticallyRethrows( ) async {
72
99
print ( " ==== \( #function) ------ " ) // CHECK-LABEL: test_discardingTaskGroup_automaticallyRethrows
73
100
do {
@@ -182,6 +209,7 @@ func test_discardingTaskGroup_automaticallyRethrows_first_withThrowingBodySecond
182
209
static func main( ) async {
183
210
await test_taskGroup_throws_rethrows ( )
184
211
await test_taskGroup_noThrow_ifNotAwaitedThrowingTask ( )
212
+ await test_taskGroup_throw_rethrows_waitForAll ( )
185
213
await test_discardingTaskGroup_automaticallyRethrows ( )
186
214
await test_discardingTaskGroup_automaticallyRethrowsOnlyFirst ( )
187
215
await test_discardingTaskGroup_automaticallyRethrows_first_withThrowingBodyFirst ( )
0 commit comments