Arbitrary[Map[Int, List[Int]]]: Gave up after only 62 passed tests.
I'm getting a weird behavior in scalacheck while generating Map[Int, List[Int]] with an automatically derived Arbitrary. The issue can be reproduced with the following test, to be added to scalacheck/test/scala/ShrinkSpec.scala:
property("map") = {
forAll(implicitly[Arbitrary[Map[Int, List[Int]]]].arbitrary)(ok)
}
Which leads to a:
[info] ! Map.map: Gave up after only 62 passed tests. 312 tests were discarded.
Any idea of what's going on here? My quick work around is to generate a Map[A, B] from a List[(A, B)] (I also have a generalized version to build anything with a CanBuildFrom from a List):
implicit def arbitraryMap[A, B]
(implicit a: Arbitrary[List[(A, B)]]): Arbitrary[Map[A, B]] =
Arbitrary(a.arbitrary.map(_.toMap))
I would strongly recommend switching to scalacheck-shapeless if that's not too disruptive.
I've just tried with scalacheck-shapeless and it seams to be affected by the same problem (I get the exact same error in my test).
I suggest continuing this discussion on a scalacheck-shapeless issue ... @alexarchambault should be able to help out.