kotest-property / io.kotest.property.arbitrary / BasicArb

BasicArb

interface BasicArb<A> : Arb<A>

Functions

sample

abstract fun sample(rs: RandomSource): Sample<A>

samples

open fun samples(rs: RandomSource): Sequence<Sample<A>>

Extension Functions

distinct

Returns a new Arb which ensures only unique values are generated by keeping track of previously generated values.

fun <A> Arb<A>.distinct(): Arb<A>

filter

Returns a new Arb which takes its elements from the receiver and filters them using the supplied predicate. This gen will continue to request elements from the underlying gen until one satisfies the predicate.

fun <A> Arb<A>.filter(predicate: (A) -> Boolean): Arb<A>

filterIsInstance

Create a new Arb by keeping only instances of B generated by this gen. This is useful if you have a type hierarchy and only want to retain a particular subtype.

fun <A, B : A> Arb<A>.filterIsInstance(): Arb<B>

filterNot

fun <A> Arb<A>.filterNot(f: (A) -> Boolean): Arb<A>

flatMap

Returns a new Arb which takes its elements from the receiver and flat maps them using the supplied function.

fun <A, B> Arb<A>.flatMap(f: (A) -> Arb<B>): Arb<B>

map

Returns a new Arb which takes its elements from the receiver and maps them using the supplied function.

fun <A, B> Arb<A>.map(f: (A) -> B): Arb<B>

merge

Returns a new Gen which will merge the values from this gen and the values of the supplied gen together, taking one from each in turn.

fun <A, B : A> Gen<A>.merge(other: Gen<B>): Gen<A>

next

fun <A> Arb<A>.next(rs: RandomSource = RandomSource.Default): A

Draws a random value from this generator

fun <A> Arb<A>.next(predicate: (A) -> Boolean = { true }, random: RandomSource?): A

single

Returns a single value generated from this arb ignoring edgecases.

fun <A> Arb<A>.single(rs: RandomSource = RandomSource.Default): A

take

Returns a sequence of size count from values generated from this arb.

fun <A> Arb<A>.take(count: Int, rs: RandomSource = RandomSource.Default): Sequence<A>