Reputation: 39018
I have an enumeration RankAndFile
with 64 values representing the squares on a chessboard.
I would like a obtain a ScalaCheck Arbitrary[(RankAndFile, RankAndFile)]
but I'm not sure how.
So far I have:
implicit val arbitraryRankAndFile =
Arbitrary(Gen.oneOf(RankAndFile.values.toSeq))
implicit val arbitraryRankAndFilePair =
Arbitrary.arbTuple2[RankAndFile, RankAndFile]
But the compiler complains on the second statement that it could not find implicit value for parameter a1: org.scalacheck.Arbitrary[RankAndFile.RankAndFile]
. Certainly this is because the type of arbitraryRankAndFile
is Arbitrary[Gen[RankAndFile]]
.
What should I have instead?
Upvotes: 1
Views: 1430
Reputation: 39018
The arbitrary single value was enough:
implicit def rankAndFile = Arbitrary { Gen.oneOf(RankAndFile.values.toSeq) }
The property to be checked took a tuple of RankAndFile
which could be satisfied by scalacheck from this single Arbitrary
value. The method Arbitrary.arbTuple2
was a red-herring.
Upvotes: 3