@@ -251,18 +251,64 @@ class WhenTests: XCTestCase {
251251 waitForExpectations ( timeout: 1 )
252252 }
253253
254- func testGuaranteeWhen ( ) {
254+ func testGuaranteesWhenVoidVarArgs ( ) {
255255 let ex1 = expectation ( description: " " )
256- when ( Guarantee ( ) , Guarantee ( ) ) . done {
256+ var someNumber = 0
257+ let g1 = Guarantee< Void> { resolver in
258+ someNumber += 1
259+ resolver ( ( ) )
260+ }
261+ let g2 = Guarantee< Void> { resolver in
262+ someNumber += 2
263+ resolver ( ( ) )
264+ }
265+ when ( g1, g2) . done {
266+ XCTAssertEqual ( someNumber, 3 )
267+ ex1. fulfill ( )
268+ }
269+ wait ( for: [ ex1] , timeout: 10 )
270+ }
271+
272+ func testGuaranteesWhenVarArgs( ) {
273+ let ex1 = expectation ( description: " " )
274+ let g1 = Guarantee< Int> . value( 1 )
275+ let g2 = Guarantee< Int> . value( 4 )
276+ let g3 = Guarantee< Int> . value( 2 )
277+ let g4 = Guarantee< Int> . value( 5 )
278+ let g5 = Guarantee< Int> . value( 3 )
279+ when ( g1, g2, g3, g4, g5) . done {
280+ XCTAssertEqual ( $0, [ 1 , 4 , 2 , 5 , 3 ] )
281+ ex1. fulfill ( )
282+ }
283+ wait ( for: [ ex1] , timeout: 10 )
284+ }
285+
286+ func testGuaranteesWhenVoidArray( ) {
287+ let ex1 = expectation ( description: " " )
288+ var someNumber = 0
289+ when ( guarantees: ( 0 ..< 100 ) . map { _ in
290+ Guarantee< Void> { resolver in
291+ someNumber += 1
292+ resolver ( ( ) )
293+ }
294+ } ) . done {
295+ XCTAssertEqual ( someNumber, 100 )
257296 ex1. fulfill ( )
258297 }
259298
260- let ex2 = expectation ( description: " " )
261- when ( guarantees: [ Guarantee ( ) , Guarantee ( ) ] ) . done {
262- ex2. fulfill ( )
299+ wait ( for: [ ex1] , timeout: 10 )
300+ }
301+
302+ func testGuaranteesWhenArray( ) {
303+ let ex1 = expectation ( description: " " )
304+ when ( guarantees: ( 0 ..< 100 ) . map {
305+ Guarantee< Int> . value( $0)
306+ } ) . done {
307+ XCTAssertEqual ( $0, Array ( 0 ..< 100 ) )
308+ ex1. fulfill ( )
263309 }
264310
265- wait ( for: [ ex1, ex2 ] , timeout: 10 )
311+ wait ( for: [ ex1] , timeout: 10 )
266312 }
267313
268314 func testDoubleTupleGuarantees( ) {
0 commit comments