Skip to content

Commit

Permalink
Make messages used in Rule generator be generated
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacoby6000 committed Dec 18, 2017
1 parent ec26600 commit f0341f5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions checklist/src/test/scala/checklist/laws/package.scala
Expand Up @@ -13,11 +13,14 @@ trait ScalacheckInstances {
implicit def arbRule[A: Arbitrary, B: Arbitrary](implicit arbF: Arbitrary[A => Ior[A, B]]): Arbitrary[Rule[A, B]] = Arbitrary(
for {
f <- arbF.arbitrary
} yield Rule.pure(f.map {
case Ior.Both(_, b) => Ior.both(NonEmptyList.of(ErrorMessage("both")), b)
case Ior.Left(_) => Ior.left(NonEmptyList.of(ErrorMessage("left")))
case Ior.Right(a) => Ior.right(a)
})
messages <- Arbitrary.arbitrary[Messages]
} yield {
Rule.pure(f(_).fold(
_ => Ior.left(messages),
Ior.right(_),
(_, b) => Ior.both(messages, b)
))
}
)

implicit val arbPath: Arbitrary[Path] = Arbitrary(
Expand Down

0 comments on commit f0341f5

Please sign in to comment.