1
import Bow
2
import SwiftCheck
3

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

6
extension NonEmptyArray: Arbitrary where A: Arbitrary {
7 1
    public static var arbitrary: Gen<NonEmptyArray<A>> {
8 1
        return Array.arbitrary
9 1
            .suchThat { array in array.count > 0 }
10 1
            .map(NonEmptyArray.fromArrayUnsafe)
11
    }
12
}
13

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

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

Read our documentation on viewing source code .

Loading