Skip to content
This repository has been archived by the owner on Sep 20, 2018. It is now read-only.

Arbitrary[Map[Int, List[Int]]]: Gave up after only 62 passed tests. #33

Open
OlivierBlanvillain opened this issue Jan 22, 2016 · 3 comments

Comments

@OlivierBlanvillain
Copy link

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))
@milessabin
Copy link
Member

I would strongly recommend switching to scalacheck-shapeless if that's not too disruptive.

@OlivierBlanvillain
Copy link
Author

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).

@milessabin
Copy link
Member

I suggest continuing this discussion on a scalacheck-shapeless issue ... @alexarchambault should be able to help out.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants