1
import Bow
2
import SwiftCheck
3

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

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

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

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

Read our documentation on viewing source code .

Loading