@@ -222,60 +222,60 @@ final class EffectTests: XCTestCase {
222222 }
223223 . sink ( receiveValue: { result = $0 } )
224224 . store ( in: & self . cancellables)
225- self . wait ( for: [ expectation] , timeout: 0 )
225+ self . wait ( for: [ expectation] , timeout: 1 )
226226 XCTAssertNoDifference ( result, 42 )
227227 }
228228
229- func testThrowingTask( ) {
230- guard #available( iOS 15 , macOS 12 , tvOS 15 , watchOS 8 , * ) else { return }
229+ func testThrowingTask( ) {
230+ guard #available( iOS 15 , macOS 12 , tvOS 15 , watchOS 8 , * ) else { return }
231231
232- let expectation = self . expectation ( description: " Complete " )
233- struct MyError : Error { }
234- var result : Error ?
235- Effect < Int , Error > . task {
236- expectation. fulfill ( )
237- throw MyError ( )
232+ let expectation = self . expectation ( description: " Complete " )
233+ struct MyError : Error { }
234+ var result : Error ?
235+ Effect < Int , Error > . task {
236+ expectation. fulfill ( )
237+ throw MyError ( )
238+ }
239+ . sink (
240+ receiveCompletion: {
241+ switch $0 {
242+ case . finished:
243+ XCTFail ( )
244+ case let . failure( error) :
245+ result = error
246+ }
247+ } ,
248+ receiveValue: { _ in XCTFail ( ) }
249+ )
250+ . store ( in: & self . cancellables)
251+ self . wait ( for: [ expectation] , timeout: 1 )
252+ XCTAssertNotNil ( result)
238253 }
239- . sink (
240- receiveCompletion: {
241- switch $0 {
242- case . finished:
243- XCTFail ( )
244- case let . failure( error) :
245- result = error
246- }
247- } ,
248- receiveValue: { _ in XCTFail ( ) }
249- )
250- . store ( in: & self . cancellables)
251- self . wait ( for: [ expectation] , timeout: 0 )
252- XCTAssertNotNil ( result)
253- }
254254
255- func testCancellingTask( ) {
256- guard #available( iOS 15 , macOS 12 , tvOS 15 , watchOS 8 , * ) else { return }
255+ func testCancellingTask( ) {
256+ guard #available( iOS 15 , macOS 12 , tvOS 15 , watchOS 8 , * ) else { return }
257257
258- @Sendable func work( ) async throws -> Int {
259- var task : Task < Int , Error > !
260- task = Task {
261- await Task . sleep ( NSEC_PER_MSEC)
262- try Task . checkCancellation ( )
263- return 42
258+ @Sendable func work( ) async throws -> Int {
259+ var task : Task < Int , Error > !
260+ task = Task {
261+ await Task . sleep ( NSEC_PER_MSEC)
262+ try Task . checkCancellation ( )
263+ return 42
264+ }
265+ task. cancel ( )
266+ return try await task. value
264267 }
265- task. cancel ( )
266- return try await task. value
267- }
268268
269- let expectation = self . expectation ( description: " Complete " )
270- Effect < Int , Error > . task {
271- try await work ( )
269+ let expectation = self . expectation ( description: " Complete " )
270+ Effect < Int , Error > . task {
271+ try await work ( )
272+ }
273+ . sink (
274+ receiveCompletion: { _ in expectation. fulfill ( ) } ,
275+ receiveValue: { _ in XCTFail ( ) }
276+ )
277+ . store ( in: & self . cancellables)
278+ self . wait ( for: [ expectation] , timeout: 1 )
272279 }
273- . sink (
274- receiveCompletion: { _ in expectation. fulfill ( ) } ,
275- receiveValue: { _ in XCTFail ( ) }
276- )
277- . store ( in: & self . cancellables)
278- self . wait ( for: [ expectation] , timeout: 0.2 )
279- }
280280 #endif
281281}
0 commit comments