1
import Bow
2
import SwiftCheck
3

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

6
extension Sum: Arbitrary where F: ArbitraryK, G: ArbitraryK, V: Arbitrary {
7 0
    public static var arbitrary: Gen<Sum<F, G, V>> {
8 0
        return Gen.from(SumPartial.generate >>> Sum.fix)
9
    }
10
}
11

12
// MARK: Instance of `ArbitraryK` for `Sum`
13

14
extension SumPartial: ArbitraryK where F: ArbitraryK, G: ArbitraryK {
15 1
    public static func generate<A: Arbitrary>() -> Kind<SumPartial<F, G>, A> {
16 1
        let fa: Kind<F, A> = F.generate()
17 1
        let ga: Kind<G, A> = G.generate()
18 1
        let left = Sum.left(fa, ga)
19 1
        let right = Sum.right(fa, ga)
20 1
        return Gen.one(of: [Gen.pure(left), Gen.pure(right)]).generate
21
    }
22
}

Read our documentation on viewing source code .

Loading