1
import Bow
2
import SwiftCheck
3

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

6
extension Moore: Arbitrary where E: CoArbitrary & Hashable, V: Arbitrary {
7 0
    public static var arbitrary: Gen<Moore<E, V>> {
8 0
        return Gen.from(MoorePartial.generate >>> Moore.fix)
9
    }
10
}
11

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

14
extension MoorePartial: ArbitraryK where E: CoArbitrary & Hashable {
15 1
    public static func generate<A: Arbitrary>() -> Kind<MoorePartial<E>, A> {
16 1
        func handle(_ x: E) -> Moore<E, A> {
17 0
            return Moore(view: A.arbitrary.generate, handle: handle)
18
        }
19 1
        
20 1
        return Moore(view: A.arbitrary.generate, handle: handle)
21
    }
22
}

Read our documentation on viewing source code .

Loading