Created
March 24, 2016 14:24
-
-
Save dabd/cf9ed4f92cadf76da550 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.scalacheck.Arbitrary | |
import org.scalacheck.Arbitrary._ | |
import org.scalacheck.Gen | |
def arbitraryCaseClass[A,C](f: A => C)(implicit t: Arbitrary[A]): Arbitrary[C] = Arbitrary(for(v <- arbitrary[A]) yield f(v)) | |
type MyIdType = String | |
implicit val arbMyIdType: Arbitrary[MyIdType] = Arbitrary(Gen.identifier) | |
case class A(s: String, t: Int) | |
implicit def arbA = arbitraryCaseClass((A.apply _).tupled) | |
val a = arbitrary[A].sample |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment