File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -109,5 +109,37 @@ class MultipleErrorTypesTests: _TestCase
109109
110110 self . wait ( )
111111 }
112-
112+
113+ func testMultipleErrorTypes_failure( )
114+ {
115+ var expect = self . expectationWithDescription ( __FUNCTION__)
116+
117+ self . _task1 ( success: false )
118+ . failure { errorInfo -> Task < Dummy , String /* must be task1's value type to recover */, Dummy > in
119+
120+ println ( " task1.failure " )
121+ self . flow += [ 3 ]
122+
123+ //
124+ // NOTE:
125+ // Returning `Task2` won't work since same Value type as `task1` is required inside `task1.failure()`,
126+ // so use `then()` to promote `Task2` to `Task<..., Task1.Value, ...>`.
127+ //
128+ return self . _task2 ( success: false ) . then { value, errorInfo in
129+ return Task < Dummy , String , Dummy > ( error: Dummy ( ) ) // error task
130+ }
131+ }
132+ . failure { errorInfo -> String /* must be task1's value type to recover */ in
133+
134+ println ( " task1.failure.failure (task2 should end at this point) " )
135+ self . flow += [ 6 ]
136+
137+ XCTAssertEqual ( self . flow, Array ( 1 ... 6 ) , " Tasks should flow in order from 1 to 6. " )
138+ expect. fulfill ( )
139+
140+ return " DUMMY "
141+ }
142+
143+ self . wait ( )
144+ }
113145}
You can’t perform that action at this time.
0 commit comments