simon.vergauwen
06/06/2020, 2:19 PMArb.frequency function?
And would there be any interest for this operator? You could easily derive choice from this operator.
It was inspired by frequency from ScalaTest, in contrast to choice it takes a weight per Arb.sam
06/06/2020, 5:36 PMsam
06/06/2020, 5:36 PM/**
* Returns a stream of values based on weights:
*
* Arb.choose(1 to 'A', 2 to 'B') will generate 'A' 33% of the time
* and 'B' 66% of the time.
*
* @throws IllegalArgumentException If any negative weight is given or only
* weights of zero are given.
*/
fun <A : Any> Arb.Companion.choose(a: Pair<Int, A>, b: Pair<Int, A>, vararg cs: Pair<Int, A>)simon.vergauwen
06/07/2020, 8:08 AMArb from a sealed class but I want the create an Arb for every case, and I don’t want them to occur in the same frequency.
Example:
fun <A> pureIO(arb: Arb<A>): Arb<IO<A>> = arb.map { IO.just(it) }
fun failingIO(): Arb<IO<Nothing>> = Arb.throwable().map { IO.raiseError(it) }
fun <A> <http://Arb.Companion.io|Arb.Companion.io>(arb: Arb<A>): Arb<IO<A>> =
Arb.frequency(5 to pureIO(arb), 1 to failingIO())sam
06/07/2020, 9:32 AMsimon.vergauwen
06/07/2020, 9:33 AMA not on Arb<A>simon.vergauwen
06/07/2020, 9:34 AMPair<Int, A> vs Pair<Int, Arb<A>>sam
06/07/2020, 11:22 AMsam
06/07/2020, 3:17 PMsimon.vergauwen
06/07/2020, 6:27 PM