forked from ReactiveCocoa/ReactiveCocoa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestError.swift
36 lines (29 loc) · 884 Bytes
/
TestError.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import ReactiveCocoa
import ReactiveSwift
import Result
internal enum TestError: Int {
case `default` = 0
case error1 = 1
case error2 = 2
}
extension TestError: Error {
}
internal extension SignalProducerProtocol {
/// Halts if an error is emitted in the receiver signal.
/// This is useful in tests to be able to just use `startWithNext`
/// in cases where we know that an error won't be emitted.
func assumeNoErrors() -> SignalProducer<Value, NoError> {
return self.lift { $0.assumeNoErrors() }
}
}
internal extension SignalProtocol {
/// Halts if an error is emitted in the receiver signal.
/// This is useful in tests to be able to just use `startWithNext`
/// in cases where we know that an error won't be emitted.
func assumeNoErrors() -> Signal<Value, NoError> {
return self.mapError { error in
fatalError("Unexpected error: \(error)")
()
}
}
}