1
import Bow
2
import SwiftCheck
3

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

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

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

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

Read our documentation on viewing source code .

Loading