1
import Bow
2
import SwiftCheck
3

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

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

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

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

Read our documentation on viewing source code .

Loading