tieskedh
11/11/2020, 1:15 PMdata class Person(
val name : String,
val age : Int
)
fun Arb.persons() = bind(
string(), int()
) { name, age -> Person(name, age) }
@Test
fun test() = forAll(
config = PropTestConfig(
shrinkingMode = ShrinkingMode.Bounded(10)
),
Arb.persons()
){ it.age > 18 }
How can I use//create a shrinker for Person?sam
11/11/2020, 1:19 PMdata class Person(
val name: String,
val age: Int
)
val persons = Arb.bind(
Arb.string(), <http://Arb.int|Arb.int>()
) { name, age -> Person(name, age) }
suspend fun test() {
forAll(
config = PropTestConfig(
shrinkingMode = ShrinkingMode.Bounded(10)
),
persons
) { it.age > 18 }
}
Bear in mind, the shrinking won't work for a binded type.tieskedh
11/11/2020, 1:31 PMsam
11/11/2020, 3:44 PMtieskedh
11/11/2020, 8:49 PMforAll(
config = PropTestConfig(shrinkingMode = ShrinkingMode.Unbounded),
iterations = 1000,
genA = Arb.string()
){
println(it)
"#" !in it
}
And it doesn't shrink either...
I think I'm still understanding the framework wrong, but if it should work, maybe it's because I'm using multiplatform?