Skip to content

Commit

Permalink
fix State generator
Browse files Browse the repository at this point in the history
Co-authored-by: Tomás Ruiz-López <[email protected]>
  • Loading branch information
miguelangel-dev and truizlop committed Aug 17, 2020
1 parent 06bd13d commit 562bff1
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions Tests/BowLiteCoreTests/Data/State/State+Arbitrary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,13 @@ import SwiftCheck
import BowLiteLaws
import BowLiteCore

extension State: Arbitrary where StateType: Hashable & CoArbitrary & Arbitrary, Value: Arbitrary {
extension State: Arbitrary where StateType: Hashable & Arbitrary & CoArbitrary, Value: Arbitrary {
public static var arbitrary: Gen<State<StateType, Value>> {
ArrowOf<StateType, Tuple<StateType, Value>>.arbitrary.map { arrow in
Gen.zip(ArrowOf<StateType, StateType>.arbitrary,
ArrowOf<StateType, Value>.arbitrary).map { f, g in
State { state in
let pair = arrow.getArrow(state)
return (pair.first, pair.second)
(f.getArrow(state), g.getArrow(state))
}
}
}
}

private struct Tuple<A, B> {
let first: A
let second: B
}

extension Tuple: Arbitrary where A: Arbitrary, B: Arbitrary {
static var arbitrary: Gen<Tuple<A, B>> {
Gen.zip(A.arbitrary, B.arbitrary).map(Tuple.init)
}
}

0 comments on commit 562bff1

Please sign in to comment.