Created
March 7, 2017 01:03
-
-
Save creswick/5c6018868033f5e6dfd289a962d111b9 to your computer and use it in GitHub Desktop.
forAll fails to generate different values
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 collection.mutable.Stack | |
import org.scalatest._ | |
import org.scalatest.prop.GeneratorDrivenPropertyChecks | |
import org.scalacheck.Gen | |
import org.scalacheck.Gen.{ listOf, Choose } | |
import org.scalacheck.Gen | |
// Built & run with: | |
// $ scalac -cp scalatest-app_2.11-3.0.1.jar:scalacheck_2.11-1.13.4.jar ExampleSpec.scala | |
// $ scala -cp scalatest-app_2.11-3.0.1.jar:scalacheck_2.11-1.13.4.jar org.scalatest.run ExampleSpec | |
class ExampleSpec extends FunSpec with Matchers with GeneratorDrivenPropertyChecks { | |
val nameGen = Gen.alphaNumStr.retryUntil(_.length > 0) | |
it("nameGen") { | |
forAll(nameGen) { str => | |
str.length should be > (0) | |
} | |
} | |
it("nameGen: sample") { | |
val str = nameGen.sample | |
str match { | |
case None => ??? // just need something here. | |
case Some(s) => s.length should be > (0) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment