@@ -154,9 +154,8 @@ func BenchmarkParallel(b *testing.B) {
154154func TestParallelCompleted (t * testing.T ) {
155155 a := assert .New (t )
156156
157- out , errs , hasError := ParallelCompleted (0 )
158- a .NotTrueNow (hasError )
159- a .EqualNow (errs , []error {})
157+ out , err := ParallelCompleted (0 )
158+ a .NilNow (err )
160159 a .EqualNow (out , [][]any {})
161160
162161 a .PanicNow (func () {
@@ -177,10 +176,9 @@ func TestParallelCompletedWithoutConcurrencyLimit(t *testing.T) {
177176 }
178177
179178 start := time .Now ()
180- out , errs , hasError := ParallelCompleted (0 , funcs ... )
179+ out , err := ParallelCompleted (0 , funcs ... )
181180 dur := time .Since (start )
182- a .NotTrueNow (hasError )
183- a .EqualNow (errs , []error {nil , nil , nil , nil , nil })
181+ a .NilNow (err )
184182 a .TrueNow (dur - 100 * time .Millisecond < 30 * time .Millisecond ) // allow 30ms deviation
185183 a .EqualNow (out , [][]any {{0 , nil }, {1 , nil }, {2 , nil }, {3 , nil }, {4 , nil }})
186184}
@@ -198,10 +196,9 @@ func TestParallelCompletedWithConcurrencyLimit(t *testing.T) {
198196 }
199197
200198 start := time .Now ()
201- out , errs , hasError := ParallelCompleted (2 , funcs ... )
199+ out , err := ParallelCompleted (2 , funcs ... )
202200 dur := time .Since (start )
203- a .NotTrueNow (hasError )
204- a .EqualNow (errs , []error {nil , nil , nil , nil , nil })
201+ a .NilNow (err )
205202 a .EqualNow (out , [][]any {{0 , nil }, {1 , nil }, {2 , nil }, {3 , nil }, {4 , nil }})
206203 a .TrueNow (dur - 300 * time .Millisecond < 30 * time .Millisecond ) // allow 30ms deviation
207204}
@@ -225,9 +222,9 @@ func TestParallelCompletedWithFailedTask(t *testing.T) {
225222 })
226223 }
227224
228- out , errs , hasError := ParallelCompleted (0 , funcs ... )
229- a .TrueNow ( hasError )
230- a .EqualNow (errs , [] error { nil , nil , expectedErr , nil , nil } )
225+ out , err := ParallelCompleted (0 , funcs ... )
226+ a .NotNilNow ( err )
227+ a .EqualNow (err . Error (), "function 2 error: expected error" )
231228 a .EqualNow (out , [][]any {{0 , nil }, {1 , nil }, {2 , expectedErr }, {3 , nil }, {4 , nil }})
232229}
233230
@@ -245,9 +242,8 @@ func TestParallelCompletedWithContext(t *testing.T) {
245242 })
246243 }
247244
248- out , errs , hasError := ParallelCompletedWithContext (context .Background (), 2 , funcs ... )
249- a .NotTrueNow (hasError )
250- a .EqualNow (errs , []error {nil , nil , nil , nil , nil })
245+ out , err := ParallelCompletedWithContext (context .Background (), 2 , funcs ... )
246+ a .NilNow (err )
251247 a .EqualNow (out , [][]any {{0 , nil }, {1 , nil }, {2 , nil }, {3 , nil }, {4 , nil }})
252248
253249 finishedNum := 0
@@ -284,9 +280,11 @@ func TestParallelCompletedWithTimedOutContext(t *testing.T) {
284280 ctx , canFunc := context .WithTimeout (context .Background (), 150 * time .Millisecond )
285281 defer canFunc ()
286282
287- out , errs , hasError := ParallelCompletedWithContext (ctx , 2 , funcs ... )
288- a .TrueNow (hasError )
289- a .EqualNow (errs , []error {nil , nil , timeoutErr , timeoutErr , timeoutErr })
283+ out , err := ParallelCompletedWithContext (ctx , 2 , funcs ... )
284+ a .NotNilNow (err )
285+ a .EqualNow (err .Error (), `function 2 error: timed out
286+ function 3 error: timed out
287+ function 4 error: timed out` )
290288 a .EqualNow (out , [][]any {{0 , nil }, {1 , nil }, {2 , timeoutErr }, {3 , timeoutErr }, {4 , timeoutErr }})
291289
292290 finishedNum := 0
0 commit comments