André Martins
04/21/2022, 9:37 AMdata class Student(val id: Int, val name: String)
and I’m trying to build a Arb of Student like
fun Arb.Companion.student(
id: Arb<Int> = positiveInt(),
name: Arb<String> = string()
): Arb<Student> = arbitrary { rs ->
Student(
id.next(rs),
name.next(rs) // or name.bind() and ignore rs?
)
}
Should I call bind
or next
with the current randomSource?Emil Kantis
04/21/2022, 11:43 AMArb.bind(id, name, ::Student)
André Martins
04/21/2022, 11:45 AMmitch
04/21/2022, 11:48 AMAndré Martins
04/21/2022, 11:49 AMArb.student().next(myRandomSource)
will it pass the random source to all arbs?mitch
04/21/2022, 11:49 AMAndré Martins
04/21/2022, 11:50 AMmitch
04/21/2022, 11:50 AMfun Arb.Companion.student(
id: Arb<Int> = positiveInt(),
name: Arb<String> = string()
): Arb<Student> = arbitrary {
Student(
id.bind(),
name.bind()
)
}
André Martins
04/21/2022, 11:53 AMEmil Kantis
04/21/2022, 11:54 AMArb.bind(id, name, ::Student)
takes the id and name arb and binds them using the Student constructor. 🙂mitch
04/21/2022, 11:54 AMarbitrary { }
scope, that’s about the only thing possible. within the builder you can compose a lot more complex arbitrariesAndré Martins
04/21/2022, 11:55 AM