1
import Bow
2
import SwiftCheck
3

4
// MARK: Generator for Property-based Testing
5

6
extension Try: Arbitrary where A: Arbitrary {
7 1
    public static var arbitrary: Gen<Try<A>> {
8 1
        let failure = Gen.pure(Try<A>.failure(TryError.illegalState))
9 1
        let success = A.arbitrary.map(Try.success)
10 1
        return Gen.one(of: [failure, success])
11
    }
12
}
13

14
// MARK: Instance of `ArbitraryK` for `Try`
15

16
extension ForTry: ArbitraryK {
17 1
    public static func generate<A: Arbitrary>() -> Kind<ForTry, A> {
18 1
        return Try.arbitrary.generate
19
    }
20
}

Read our documentation on viewing source code .

Loading