Given:
import org.scalatest._
import org.scalatest.prop.Checkers
import org.scalacheck.Gen
import org.scalacheck.Gen._
object Test {
def fooOrBar: Gen[String] = oneOf("foo", "bar")
}
class Test extends FunSuite with Checkers {
import Test._
test("generated String should equal 'foo' or 'bar'") {
check( org.scalacheck.Prop.forAll(fooOrBar) { x: String =>
x == "foo" || x == "bar"
})
}
}
Running sbt test
returns that all tests have succeeded.
Given the above code, is it possible for x: String
, i.e. the String
of fooOrBar
, of type Gen[String]
, to equal a value other than foo
or bar
?
In my real-world code, I'm seeing values for my x: String
that appear to differ from the Gen[String]
argument to org.scalacheck.Prop.forAll
.
So, that's why I'm asking if it's possible, for the above example, whether x: String
can not equal foo
or bar
.