1
import Bow
2
import SwiftCheck
3

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

6
extension Ior: Arbitrary where A: Arbitrary, B: Arbitrary {
7 1
    public static var arbitrary: Gen<Ior<A, B>> {
8 1
        let left = A.arbitrary.map(Ior.left)
9 1
        let right = B.arbitrary.map(Ior.right)
10 1
        let both = Gen.zip(A.arbitrary, B.arbitrary).map(Ior.both)
11 1
        return Gen.one(of: [left, right, both])
12
    }
13
}
14

15
// MARK: Instance of `ArbitraryK` for `Ior`
16

17
extension IorPartial: ArbitraryK where L: Arbitrary {
18 1
    public static func generate<A: Arbitrary>() -> Kind<IorPartial<L>, A> {
19 1
        return Ior.arbitrary.generate
20
    }
21
}

Read our documentation on viewing source code .

Loading