Gen

object Gen
Companion
class
class Object
trait Matchable
class Any

Type members

Classlikes

final class GenCharExt(g: () => Char) extends AnyVal
final case class Now(millisSinceEpoch: Long) extends AnyVal
Companion
object
object Now
Companion
class
final case class ToNonEmptySeq[S, A](toSeq: S => Seq[A]) extends AnyVal
Companion
object
Companion
class

Types

type Freq[A] = (Int, Gen[A])

Int = Probability of being chosen. ≥ 0

Int = Probability of being chosen. ≥ 0

type Run[+A] = GenCtx => A

Value members

Concrete methods

def apply2[A, B, Z](z: (A, B) => Z)(A: Gen[A], B: Gen[B]): Gen[Z]
def apply3[A, B, C, Z](z: (A, B, C) => Z)(A: Gen[A], B: Gen[B], C: Gen[C]): Gen[Z]
def apply4[A, B, C, D, Z](z: (A, B, C, D) => Z)(A: Gen[A], B: Gen[B], C: Gen[C], D: Gen[D]): Gen[Z]
def apply5[A, B, C, D, E, Z](z: (A, B, C, D, E) => Z)(A: Gen[A], B: Gen[B], C: Gen[C], D: Gen[D], E: Gen[E]): Gen[Z]
def apply6[A, B, C, D, E, F, Z](z: (A, B, C, D, E, F) => Z)(A: Gen[A], B: Gen[B], C: Gen[C], D: Gen[D], E: Gen[E], F: Gen[F]): Gen[Z]
def apply7[A, B, C, D, E, F, G, Z](z: (A, B, C, D, E, F, G) => Z)(A: Gen[A], B: Gen[B], C: Gen[C], D: Gen[D], E: Gen[E], F: Gen[F], G: Gen[G]): Gen[Z]
def apply8[A, B, C, D, E, F, G, H, Z](z: (A, B, C, D, E, F, G, H) => Z)(A: Gen[A], B: Gen[B], C: Gen[C], D: Gen[D], E: Gen[E], F: Gen[F], G: Gen[G], H: Gen[H]): Gen[Z]
def apply9[A, B, C, D, E, F, G, H, I, Z](z: (A, B, C, D, E, F, G, H, I) => Z)(A: Gen[A], B: Gen[B], C: Gen[C], D: Gen[D], E: Gen[E], F: Gen[F], G: Gen[G], H: Gen[H], I: Gen[I]): Gen[Z]
def batches[A](as: Vector[A], partitionSize: Inclusive, keepRemainder: Boolean): Gen[Vector[Vector[A]]]
def byName[A](ga: => Gen[A]): Gen[A]
def byNeed[A](ga: => Gen[A]): Gen[A]
def byte: Gen[Byte]
@inline
def char: Gen[Char]

An alias for unicode, as unicode is the default.

An alias for unicode, as unicode is the default.

def choose[A](a: A, as: A*): Gen[A]
def chooseArray_![A](as: Array[A]): Gen[A]

Randomly selects one of the given elements.

Randomly selects one of the given elements.

Value Params
as

Possible elements. MUST NOT BE EMPTY.

def chooseChar(nonEmptinessProof: Char, rs: NumericRange[Char]*): Gen[Char]
def chooseChar(nonEmptinessProof: Char, s: String, rs: NumericRange[Char]*): Gen[Char]
def chooseChar_!(s: String, rs: NumericRange[Char]*): Gen[Char]
def chooseChar_!(rs: NumericRange[Char]*): Gen[Char]
def chooseDouble(l: Double, h: Double): Gen[Double]

Args are inclusive. [l,h]

Args are inclusive. [l,h]

def chooseFloat(l: Float, h: Float): Gen[Float]

Args are inclusive. [l,h]

Args are inclusive. [l,h]

def chooseGen[A](g1: Gen[A], gn: Gen[A]*): Gen[A]
def chooseGenNE[S, G, A](s: S)(ne: ToNonEmptySeq[S, G], g: G <:< Gen[A]): Gen[A]
def chooseGen_![A](gens: IterableOnce[Gen[A]]): Gen[A]
def chooseIndexed_![A](as: IndexedSeq[A]): Gen[A]

Randomly selects one of the given elements.

Randomly selects one of the given elements.

Value Params
as

Possible elements. MUST NOT BE EMPTY.

def chooseInt(bound: Int): Gen[Int]

Generate an int ∈ [0,bound).

Generate an int ∈ [0,bound).

Value Params
bound

Upper-bound (exclusive). > 0

def chooseInt(l: Int, h: Int): Gen[Int]

Args are inclusive. [l,h]

Args are inclusive. [l,h]

def chooseLong(bound: Long): Gen[Long]

Generate a long ∈ [0,bound).

Generate a long ∈ [0,bound).

Value Params
bound

Upper-bound (exclusive). > 0

def chooseLong(l: Long, h: Long): Gen[Long]

Args are inclusive. [l,h]

Args are inclusive. [l,h]

def chooseNE[S, A](s: S)(ne: ToNonEmptySeq[S, A]): Gen[A]
def choose_![A](as: IterableOnce[A]): Gen[A]

Randomly selects one of the given elements.

Randomly selects one of the given elements.

Value Params
as

Possible elements. MUST NOT BE EMPTY.

def distribute[F[_], B](a: Gen[F[B]])(D: Distributive[F]): F[Gen[B]]
def distributeK[F[_], A, B](a: Gen[Kleisli[F, A, B]])(D: Distributive[F]): Kleisli[F, A, Gen[B]]
def distributeR[A, B](a: Gen[A => B]): A => Gen[B]
def distributeRK[A, B](a: Gen[A => B]): Kleisli[[A] =>> Gen[A], A, B]
def fairlyDistributed[A](as: Iterable[A]): Gen[Iterator[A]]

Ensures that an element is never chosen more than once per n elements.

Ensures that an element is never chosen more than once per n elements.

fairlyDistributedSeq(1, 2, 3)(6) may return [1,3,2,2,1,3] or [3,2,1,3,2,1] but never [1,1,1,1,2,3].

def fairlyDistributedSeq[A](as: Iterable[A])(ss: SizeSpec): Gen[Vector[A]]

Ensures that an element is never chosen more than once per n elements.

Ensures that an element is never chosen more than once per n elements.

fairlyDistributedSeq(1, 2, 3)(6) may return [1,3,2,2,1,3] or [3,2,1,3,2,1] but never [1,1,1,1,2,3].

def float: Gen[Float]
def frequency[A](x: (A), xs: (A)*): Gen[A]
def frequencyL_![A](xs: List[(A)]): Gen[A]
def frequencyNE[S, F, A](s: S)(ne: ToNonEmptySeq[S, F], f: Seq[F] <:< Seq[(A)]): Gen[A]
@inline
def lazily[A](ga: => Gen[A]): Gen[A]
@inline
def lift2[A, B, Z](A: Gen[A], B: Gen[B])(z: (A, B) => Z): Gen[Z]
@inline
def lift3[A, B, C, Z](A: Gen[A], B: Gen[B], C: Gen[C])(z: (A, B, C) => Z): Gen[Z]
@inline
def lift4[A, B, C, D, Z](A: Gen[A], B: Gen[B], C: Gen[C], D: Gen[D])(z: (A, B, C, D) => Z): Gen[Z]
@inline
def lift5[A, B, C, D, E, Z](A: Gen[A], B: Gen[B], C: Gen[C], D: Gen[D], E: Gen[E])(z: (A, B, C, D, E) => Z): Gen[Z]
@inline
def lift6[A, B, C, D, E, F, Z](A: Gen[A], B: Gen[B], C: Gen[C], D: Gen[D], E: Gen[E], F: Gen[F])(z: (A, B, C, D, E, F) => Z): Gen[Z]
@inline
def lift7[A, B, C, D, E, F, G, Z](A: Gen[A], B: Gen[B], C: Gen[C], D: Gen[D], E: Gen[E], F: Gen[F], G: Gen[G])(z: (A, B, C, D, E, F, G) => Z): Gen[Z]
@inline
def lift8[A, B, C, D, E, F, G, H, Z](A: Gen[A], B: Gen[B], C: Gen[C], D: Gen[D], E: Gen[E], F: Gen[F], G: Gen[G], H: Gen[H])(z: (A, B, C, D, E, F, G, H) => Z): Gen[Z]
@inline
def lift9[A, B, C, D, E, F, G, H, I, Z](A: Gen[A], B: Gen[B], C: Gen[C], D: Gen[D], E: Gen[E], F: Gen[F], G: Gen[G], H: Gen[H], I: Gen[I])(z: (A, B, C, D, E, F, G, H, I) => Z): Gen[Z]
def negativeFloat: Gen[Float]
def newOrOld[A](newGen: => Gen[A], old: => IterableOnce[A]): Gen[A]

Randomly either generates a new value, or chooses one from a known set.

Randomly either generates a new value, or chooses one from a known set.

def orderedSeq[A](orderedElems: Iterable[A], maxDups: Int, dropElems: Boolean, emptyResult: Boolean): Gen[Vector[A]]

Generates a sequence of elements in a fixed order.

Generates a sequence of elements in a fixed order.

Example: [a,b,c] can generate [a,b,c], [a,b,b,b,c,c], etc. but never [b,a,c].

Value Params
dropElems

Whether or not the generator can drop elements. (eg. drop b and return [a,c])

emptyResult

Whether or not the generator can return an empty vector as a result.

maxDups

The maximum number of consecutive, duplicate elements (can be 0).

orderedElems

Legal elements in a relevant order.

def point[A](a: => A): Gen[A]
def positiveFloat: Gen[Float]
def pure[A](a: A): Gen[A]
@inline
def sequence[T <: ([X] =>> Iterable[X]), A](gs: T[Gen[A]])(cbf: BuildFrom[T[Gen[A]], A, T[A]]): Gen[T[A]]
def sequenceZ[T[_], A](gs: T[Gen[A]])(T: Traverse[T]): Gen[T[A]]
def setConstSeed(seed: Long): Gen[Unit]
def setOptionalConstSeed(o: Option[Long]): Gen[Unit]
def setOptionalSeed(o: Option[Long]): Gen[Unit]
def setSeed(seed: Long): Gen[Unit]
def setSeedBy(f: SeedCtx => Long): Gen[Unit]
def short: Gen[Short]
@inline
def shuffle[A, C <: ([X] =>> Iterable[X])](as: C[A])(bf: BuildFrom[C[A], A, C[A]]): Gen[C[A]]
def string(ss: SizeSpec): Gen[String]
def string1(ss: SizeSpec): Gen[String]
def stringOf(cs: Gen[Char])(ss: SizeSpec): Gen[String]
def stringOf1(cs: Gen[Char])(ss: SizeSpec): Gen[String]
@inline
def subset[A, C <: ([X] =>> Iterable[X])](as: C[A])(bf: Factory[A, C[A]]): Gen[C[A]]
@inline
def subset1[A, C <: ([X] =>> IndexedSeq[X])](as: C[A])(bf: Factory[A, C[A]]): Gen[C[A]]

Generates a non-empty subset, unless the underlying seq is empty (in which case this returns an empty seq too).

Generates a non-empty subset, unless the underlying seq is empty (in which case this returns an empty seq too).

def tailrec[A, B](f: A => Gen[Either[A, B]])(a: A): Gen[B]
def traverse[T <: ([X] =>> Iterable[X]), A, B](as: T[A])(f: A => Gen[B])(cbf: BuildFrom[T[A], B, T[B]]): Gen[T[B]]
def traverseG[T <: ([X] =>> Iterable[X]), A, B](gs: T[Gen[A]])(f: A => Gen[B])(cbf: BuildFrom[T[Gen[A]], B, T[B]]): Gen[T[B]]
def traverseZ[T[_], A, B](as: T[A])(f: A => Gen[B])(T: Traverse[T]): Gen[T[B]]
def traverseZG[T[_], A, B](gs: T[Gen[A]])(f: A => Gen[B])(T: Traverse[T]): Gen[T[B]]
def tryChoose[A](as: IterableOnce[A]): Gen[Option[A]]
def tryGenChoose[A](as: IterableOnce[A]): Option[Gen[A]]
def tryGenChooseLazily[A](as: IterableOnce[A]): Option[Gen[A]]
def tuple2[A, B](A: Gen[A], B: Gen[B]): Gen[(A, B)]
def tuple3[A, B, C](A: Gen[A], B: Gen[B], C: Gen[C]): Gen[(A, B, C)]
def tuple4[A, B, C, D](A: Gen[A], B: Gen[B], C: Gen[C], D: Gen[D]): Gen[(A, B, C, D)]
def tuple5[A, B, C, D, E](A: Gen[A], B: Gen[B], C: Gen[C], D: Gen[D], E: Gen[E]): Gen[(A, B, C, D, E)]
def tuple6[A, B, C, D, E, F](A: Gen[A], B: Gen[B], C: Gen[C], D: Gen[D], E: Gen[E], F: Gen[F]): Gen[(A, B, C, D, E, F)]
def tuple7[A, B, C, D, E, F, G](A: Gen[A], B: Gen[B], C: Gen[C], D: Gen[D], E: Gen[E], F: Gen[F], G: Gen[G]): Gen[(A, B, C, D, E, F, G)]
def tuple8[A, B, C, D, E, F, G, H](A: Gen[A], B: Gen[B], C: Gen[C], D: Gen[D], E: Gen[E], F: Gen[F], G: Gen[G], H: Gen[H]): Gen[(A, B, C, D, E, F, G, H)]
def tuple9[A, B, C, D, E, F, G, H, I](A: Gen[A], B: Gen[B], C: Gen[C], D: Gen[D], E: Gen[E], F: Gen[F], G: Gen[G], H: Gen[H], I: Gen[I]): Gen[(A, B, C, D, E, F, G, H, I)]
def unit: Gen[Unit]
def uuid: Gen[UUID]

Concrete fields

val alpha: Gen[Char]
val alphaNumeric: Gen[Char]
val ascii: Gen[Char]
val boolean: Gen[Boolean]
val chooseSize: Gen[Int]

Returns a number in [0,GenSize)

Returns a number in [0,GenSize)

val chooseSizeMin1: Gen[Int]

Returns a number in [1,GenSize)

Returns a number in [1,GenSize)

val double: Gen[Double]
val int: Gen[Int]
val long: Gen[Long]
val lower: Gen[Char]
val negativeDouble: Gen[Double]
val negativeInt: Gen[Int]
val negativeLong: Gen[Long]
val numeric: Gen[Char]
val positiveDouble: Gen[Double]
val positiveInt: Gen[Int]
val positiveLong: Gen[Long]
lazy val reseed: Gen[Unit]

Apply a new, non-deterministic seed.

Apply a new, non-deterministic seed.

val unicode: Gen[Char]
val upper: Gen[Char]
lazy val zoneId: Gen[ZoneId]

Caution: non-deterministic

Caution: non-deterministic

Implicits

Implicits

@inline
implicit def _GenCharExt(g: Gen[Char]): GenCharExt
implicit val scalazInstance: Monad[[A] =>> Gen[A]] & Distributive[[A] =>> Gen[A]] & BindRec[[A] =>> Gen[A]]