Skip to content

Instantly share code, notes, and snippets.

View kpb's full-sized avatar
💭
I'm mostly water

Kenneth Bowen kpb

💭
I'm mostly water
View GitHub Profile
@kpb
kpb / forAll-customGen
Created April 14, 2015 17:04
Using ScalaCheck forAll with a custom Generator that creates a tuple
// Instead of nesting forAll calls, we could have defined a custom generator in the following way:
import org.scalacheck.Arbitrary.arbitrary
import org.scalacheck.Gen.choose
val genStringWithN = for {
s <- arbitrary[String]
n <- choose(0, s.length)
} yield (s,n)