0
ScalaCheck에서 매핑 된/flatMapped Gen
은 내부 생성자의 값이 필터링되는 즉시 실패합니다. 예 : (사용 ScalaTest)ScalaCheck 내포 된 Gen
class ScalaCheckGen extends FreeSpec with GeneratorDrivenPropertyChecks {
"Fails" in {
forAll(Gen.listOfN(100, arbitrary[Int].suchThat(_ % 2 == 0))){
_ => assert(true)}
//Gave up after 0 successful property evaluations. 51 evaluations were discarded.
}
"Passes" in {
forAll(Gen.listOfN(100, arbitrary[Int].map(_ * 2))){
_ => assert(true)}
}
}
는 suchThat
조건이 복잡하기 때문에 사소한 해결 방법은 위에서 작동하지 않았다 가정 해 봅시다. suchThat
을 사용하면서 어떻게 이것을 다시 작성할 수 있습니까?