Generator

org.scalatest.prop.Generator
See theGenerator companion trait
object Generator

Companion to the Generator trait, which contains many of the standard implicit Generators.

For the most part, you should not need to use the values and functions in here directly; the useful values in here are generally aliased in CommonGenerators (albeit with different names), which in turn is mixed into GeneratorDrivenPropertyChecks and TableDrivenPropertyChecks.

Note that this provides Generators for the common Scalactic types, as well as the common standard library ones.

Attributes

Companion
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Generator.type

Members list

Implicits

Implicits

implicit val booleanGenerator: Generator[Boolean]

A Generator that produces Boolean values.

A Generator that produces Boolean values.

Attributes

implicit val byteGenerator: Generator[Byte]

A Generator that produces Byte values.

A Generator that produces Byte values.

Attributes

implicit val charGenerator: Generator[Char]

A Generator that produces Char values.

A Generator that produces Char values.

Attributes

implicit val doubleGenerator: Generator[Double]

A Generator that produces Double values.

A Generator that produces Double values.

Attributes

implicit def eitherGenerator[L, R](implicit genOfL: Generator[L], genOfR: Generator[R]): Generator[Either[L, R]]

Given Generators for two types, L and R, this provides one for Either[L, R].

Given Generators for two types, L and R, this provides one for Either[L, R].

Type parameters

L

the "left" type for an Either

R

the "right" type for an Either

Value parameters

genOfL

a Generator that produces type L

genOfR

a Generator that produces type R

Attributes

Returns

a Generator that produces Either[L, R]

implicit val finiteDoubleGenerator: Generator[FiniteDouble]

A Generator that produces Doubles, excluding infinity.

A Generator that produces Doubles, excluding infinity.

Attributes

implicit val finiteFloatGenerator: Generator[FiniteFloat]

A Generator that produces Floats, excluding infinity.

A Generator that produces Floats, excluding infinity.

Attributes

implicit val floatGenerator: Generator[Float]

A Generator that produces Float values.

A Generator that produces Float values.

Attributes

implicit def function0Generator[T](implicit genOfT: Generator[T]): Generator[() => T]

Given a Generator that produces values of type T, this returns one that produces ''functions'' that return a T.

Given a Generator that produces values of type T, this returns one that produces ''functions'' that return a T.

The functions produced here are nullary -- they take no parameters, they just spew out values of type T.

Type parameters

T

the type to produce

Value parameters

genOfT

a Generator that produces values of T

Attributes

Returns

a Generator that produces functions that return values of type T

implicit def function10Generator[A, B, C, D, E, F, G, H, I, J, K](implicit genOfK: Generator[K], typeInfoA: TypeInfo[A], typeInfoB: TypeInfo[B], typeInfoC: TypeInfo[C], typeInfoD: TypeInfo[D], typeInfoE: TypeInfo[E], typeInfoF: TypeInfo[F], typeInfoG: TypeInfo[G], typeInfoH: TypeInfo[H], typeInfoI: TypeInfo[I], typeInfoJ: TypeInfo[J], typeInfoK: TypeInfo[K]): Generator[(A, B, C, D, E, F, G, H, I, J) => K]

Attributes

implicit def function11Generator[A, B, C, D, E, F, G, H, I, J, K, L](implicit genOfL: Generator[L], typeInfoA: TypeInfo[A], typeInfoB: TypeInfo[B], typeInfoC: TypeInfo[C], typeInfoD: TypeInfo[D], typeInfoE: TypeInfo[E], typeInfoF: TypeInfo[F], typeInfoG: TypeInfo[G], typeInfoH: TypeInfo[H], typeInfoI: TypeInfo[I], typeInfoJ: TypeInfo[J], typeInfoK: TypeInfo[K], typeInfoL: TypeInfo[L]): Generator[(A, B, C, D, E, F, G, H, I, J, K) => L]

Attributes

implicit def function12Generator[A, B, C, D, E, F, G, H, I, J, K, L, M](implicit genOfM: Generator[M], typeInfoA: TypeInfo[A], typeInfoB: TypeInfo[B], typeInfoC: TypeInfo[C], typeInfoD: TypeInfo[D], typeInfoE: TypeInfo[E], typeInfoF: TypeInfo[F], typeInfoG: TypeInfo[G], typeInfoH: TypeInfo[H], typeInfoI: TypeInfo[I], typeInfoJ: TypeInfo[J], typeInfoK: TypeInfo[K], typeInfoL: TypeInfo[L], typeInfoM: TypeInfo[M]): Generator[(A, B, C, D, E, F, G, H, I, J, K, L) => M]

Attributes

implicit def function13Generator[A, B, C, D, E, F, G, H, I, J, K, L, M, N](implicit genOfN: Generator[N], typeInfoA: TypeInfo[A], typeInfoB: TypeInfo[B], typeInfoC: TypeInfo[C], typeInfoD: TypeInfo[D], typeInfoE: TypeInfo[E], typeInfoF: TypeInfo[F], typeInfoG: TypeInfo[G], typeInfoH: TypeInfo[H], typeInfoI: TypeInfo[I], typeInfoJ: TypeInfo[J], typeInfoK: TypeInfo[K], typeInfoL: TypeInfo[L], typeInfoM: TypeInfo[M], typeInfoN: TypeInfo[N]): Generator[(A, B, C, D, E, F, G, H, I, J, K, L, M) => N]

Attributes

implicit def function14Generator[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O](implicit genOfO: Generator[O], typeInfoA: TypeInfo[A], typeInfoB: TypeInfo[B], typeInfoC: TypeInfo[C], typeInfoD: TypeInfo[D], typeInfoE: TypeInfo[E], typeInfoF: TypeInfo[F], typeInfoG: TypeInfo[G], typeInfoH: TypeInfo[H], typeInfoI: TypeInfo[I], typeInfoJ: TypeInfo[J], typeInfoK: TypeInfo[K], typeInfoL: TypeInfo[L], typeInfoM: TypeInfo[M], typeInfoN: TypeInfo[N], typeInfoO: TypeInfo[O]): Generator[(A, B, C, D, E, F, G, H, I, J, K, L, M, N) => O]

Attributes

implicit def function15Generator[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P](implicit genOfP: Generator[P], typeInfoA: TypeInfo[A], typeInfoB: TypeInfo[B], typeInfoC: TypeInfo[C], typeInfoD: TypeInfo[D], typeInfoE: TypeInfo[E], typeInfoF: TypeInfo[F], typeInfoG: TypeInfo[G], typeInfoH: TypeInfo[H], typeInfoI: TypeInfo[I], typeInfoJ: TypeInfo[J], typeInfoK: TypeInfo[K], typeInfoL: TypeInfo[L], typeInfoM: TypeInfo[M], typeInfoN: TypeInfo[N], typeInfoO: TypeInfo[O], typeInfoP: TypeInfo[P]): Generator[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O) => P]

Attributes

implicit def function16Generator[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q](implicit genOfQ: Generator[Q], typeInfoA: TypeInfo[A], typeInfoB: TypeInfo[B], typeInfoC: TypeInfo[C], typeInfoD: TypeInfo[D], typeInfoE: TypeInfo[E], typeInfoF: TypeInfo[F], typeInfoG: TypeInfo[G], typeInfoH: TypeInfo[H], typeInfoI: TypeInfo[I], typeInfoJ: TypeInfo[J], typeInfoK: TypeInfo[K], typeInfoL: TypeInfo[L], typeInfoM: TypeInfo[M], typeInfoN: TypeInfo[N], typeInfoO: TypeInfo[O], typeInfoP: TypeInfo[P], typeInfoQ: TypeInfo[Q]): Generator[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P) => Q]

Attributes

implicit def function17Generator[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R](implicit genOfR: Generator[R], typeInfoA: TypeInfo[A], typeInfoB: TypeInfo[B], typeInfoC: TypeInfo[C], typeInfoD: TypeInfo[D], typeInfoE: TypeInfo[E], typeInfoF: TypeInfo[F], typeInfoG: TypeInfo[G], typeInfoH: TypeInfo[H], typeInfoI: TypeInfo[I], typeInfoJ: TypeInfo[J], typeInfoK: TypeInfo[K], typeInfoL: TypeInfo[L], typeInfoM: TypeInfo[M], typeInfoN: TypeInfo[N], typeInfoO: TypeInfo[O], typeInfoP: TypeInfo[P], typeInfoQ: TypeInfo[Q], typeInfoR: TypeInfo[R]): Generator[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q) => R]

Attributes

implicit def function18Generator[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S](implicit genOfS: Generator[S], typeInfoA: TypeInfo[A], typeInfoB: TypeInfo[B], typeInfoC: TypeInfo[C], typeInfoD: TypeInfo[D], typeInfoE: TypeInfo[E], typeInfoF: TypeInfo[F], typeInfoG: TypeInfo[G], typeInfoH: TypeInfo[H], typeInfoI: TypeInfo[I], typeInfoJ: TypeInfo[J], typeInfoK: TypeInfo[K], typeInfoL: TypeInfo[L], typeInfoM: TypeInfo[M], typeInfoN: TypeInfo[N], typeInfoO: TypeInfo[O], typeInfoP: TypeInfo[P], typeInfoQ: TypeInfo[Q], typeInfoR: TypeInfo[R], typeInfoS: TypeInfo[S]): Generator[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R) => S]

Attributes

implicit def function19Generator[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T](implicit genOfT: Generator[T], typeInfoA: TypeInfo[A], typeInfoB: TypeInfo[B], typeInfoC: TypeInfo[C], typeInfoD: TypeInfo[D], typeInfoE: TypeInfo[E], typeInfoF: TypeInfo[F], typeInfoG: TypeInfo[G], typeInfoH: TypeInfo[H], typeInfoI: TypeInfo[I], typeInfoJ: TypeInfo[J], typeInfoK: TypeInfo[K], typeInfoL: TypeInfo[L], typeInfoM: TypeInfo[M], typeInfoN: TypeInfo[N], typeInfoO: TypeInfo[O], typeInfoP: TypeInfo[P], typeInfoQ: TypeInfo[Q], typeInfoR: TypeInfo[R], typeInfoS: TypeInfo[S], typeInfoT: TypeInfo[T]): Generator[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S) => T]

Attributes

implicit def function1Generator[A, B](implicit genOfB: Generator[B], typeInfoA: TypeInfo[A], typeInfoB: TypeInfo[B]): Generator[A => B]

Create a Generator of functions from type A to type B.

Create a Generator of functions from type A to type B.

Note that the generated functions are, necessarily, pretty random. In practice, the function you get from a function1Generator (and its variations, up through function22Generator) takes the hashes of its input values, combines those with a randomly-chosen number, and combines them in order to choose the generated value B.

That said, each of the generated functions ''is'' deterministic: given the same input parameters and the same randomly-chosen number, you will always get the same B result. And the toString function on the generated function will show the formula you need to use in order to recreate that, which will look something like:

 (a: Int, b: String, c: Float) => org.scalatest.prop.valueOf[String](a, b, c)(131)

The number and type of the a, b, c, etc, parameters, as well as the type parameter of valueOf, will on the function type you are generating, but they will always follow this pattern. valueOf is the underlying function that takes these parameters and the randomly-chosen number, and returns a value of the specified type.

So if a property evaluation fails, the display of the generated function will tell you how to call valueOf to recreate the failure.

The typeInfo parameters are automatically created via macros; you should generally not try to pass them manually.

Type parameters

A

the input type for the generated functions

B

the result type for the generated functions

Value parameters

genOfB

a Generator for the desired result type B

typeInfoA

automatically-created type information for type A

typeInfoB

automatically-created type information for type B

Attributes

Returns

a Generator that produces functions that take values of A and returns values of B

implicit val function1IntToIntGenerator: Generator[Int => Int]

Generate functions that take an Int and return a modified Int.

Generate functions that take an Int and return a modified Int.

This Generator is useful for testing edge cases of some higher-order functions. Besides obvious functions (returning the same Int, returning that Int plus 1), it tests overflow situations such as adding Int.MaxValue, negation, and other such cases.

Attributes

implicit def function20Generator[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U](implicit genOfU: Generator[U], typeInfoA: TypeInfo[A], typeInfoB: TypeInfo[B], typeInfoC: TypeInfo[C], typeInfoD: TypeInfo[D], typeInfoE: TypeInfo[E], typeInfoF: TypeInfo[F], typeInfoG: TypeInfo[G], typeInfoH: TypeInfo[H], typeInfoI: TypeInfo[I], typeInfoJ: TypeInfo[J], typeInfoK: TypeInfo[K], typeInfoL: TypeInfo[L], typeInfoM: TypeInfo[M], typeInfoN: TypeInfo[N], typeInfoO: TypeInfo[O], typeInfoP: TypeInfo[P], typeInfoQ: TypeInfo[Q], typeInfoR: TypeInfo[R], typeInfoS: TypeInfo[S], typeInfoT: TypeInfo[T], typeInfoU: TypeInfo[U]): Generator[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T) => U]

Attributes

implicit def function21Generator[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V](implicit genOfV: Generator[V], typeInfoA: TypeInfo[A], typeInfoB: TypeInfo[B], typeInfoC: TypeInfo[C], typeInfoD: TypeInfo[D], typeInfoE: TypeInfo[E], typeInfoF: TypeInfo[F], typeInfoG: TypeInfo[G], typeInfoH: TypeInfo[H], typeInfoI: TypeInfo[I], typeInfoJ: TypeInfo[J], typeInfoK: TypeInfo[K], typeInfoL: TypeInfo[L], typeInfoM: TypeInfo[M], typeInfoN: TypeInfo[N], typeInfoO: TypeInfo[O], typeInfoP: TypeInfo[P], typeInfoQ: TypeInfo[Q], typeInfoR: TypeInfo[R], typeInfoS: TypeInfo[S], typeInfoT: TypeInfo[T], typeInfoU: TypeInfo[U], typeInfoV: TypeInfo[V]): Generator[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U) => V]

Attributes

implicit def function22Generator[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W](implicit genOfW: Generator[W], typeInfoA: TypeInfo[A], typeInfoB: TypeInfo[B], typeInfoC: TypeInfo[C], typeInfoD: TypeInfo[D], typeInfoE: TypeInfo[E], typeInfoF: TypeInfo[F], typeInfoG: TypeInfo[G], typeInfoH: TypeInfo[H], typeInfoI: TypeInfo[I], typeInfoJ: TypeInfo[J], typeInfoK: TypeInfo[K], typeInfoL: TypeInfo[L], typeInfoM: TypeInfo[M], typeInfoN: TypeInfo[N], typeInfoO: TypeInfo[O], typeInfoP: TypeInfo[P], typeInfoQ: TypeInfo[Q], typeInfoR: TypeInfo[R], typeInfoS: TypeInfo[S], typeInfoT: TypeInfo[T], typeInfoU: TypeInfo[U], typeInfoV: TypeInfo[V], typeInfoW: TypeInfo[W]): Generator[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V) => W]

Attributes

implicit def function2Generator[A, B, C](implicit genOfC: Generator[C], typeInfoA: TypeInfo[A], typeInfoB: TypeInfo[B], typeInfoC: TypeInfo[C]): Generator[(A, B) => C]

Attributes

implicit def function3Generator[A, B, C, D](implicit genOfD: Generator[D], typeInfoA: TypeInfo[A], typeInfoB: TypeInfo[B], typeInfoC: TypeInfo[C], typeInfoD: TypeInfo[D]): Generator[(A, B, C) => D]

Attributes

implicit def function4Generator[A, B, C, D, E](implicit genOfE: Generator[E], typeInfoA: TypeInfo[A], typeInfoB: TypeInfo[B], typeInfoC: TypeInfo[C], typeInfoD: TypeInfo[D], typeInfoE: TypeInfo[E]): Generator[(A, B, C, D) => E]

Attributes

implicit def function5Generator[A, B, C, D, E, F](implicit genOfF: Generator[F], typeInfoA: TypeInfo[A], typeInfoB: TypeInfo[B], typeInfoC: TypeInfo[C], typeInfoD: TypeInfo[D], typeInfoE: TypeInfo[E], typeInfoF: TypeInfo[F]): Generator[(A, B, C, D, E) => F]

Attributes

implicit def function6Generator[A, B, C, D, E, F, G](implicit genOfG: Generator[G], typeInfoA: TypeInfo[A], typeInfoB: TypeInfo[B], typeInfoC: TypeInfo[C], typeInfoD: TypeInfo[D], typeInfoE: TypeInfo[E], typeInfoF: TypeInfo[F], typeInfoG: TypeInfo[G]): Generator[(A, B, C, D, E, F) => G]

Attributes

implicit def function7Generator[A, B, C, D, E, F, G, H](implicit genOfH: Generator[H], typeInfoA: TypeInfo[A], typeInfoB: TypeInfo[B], typeInfoC: TypeInfo[C], typeInfoD: TypeInfo[D], typeInfoE: TypeInfo[E], typeInfoF: TypeInfo[F], typeInfoG: TypeInfo[G], typeInfoH: TypeInfo[H]): Generator[(A, B, C, D, E, F, G) => H]

Attributes

implicit def function8Generator[A, B, C, D, E, F, G, H, I](implicit genOfI: Generator[I], typeInfoA: TypeInfo[A], typeInfoB: TypeInfo[B], typeInfoC: TypeInfo[C], typeInfoD: TypeInfo[D], typeInfoE: TypeInfo[E], typeInfoF: TypeInfo[F], typeInfoG: TypeInfo[G], typeInfoH: TypeInfo[H], typeInfoI: TypeInfo[I]): Generator[(A, B, C, D, E, F, G, H) => I]

Attributes

implicit def function9Generator[A, B, C, D, E, F, G, H, I, J](implicit genOfJ: Generator[J], typeInfoA: TypeInfo[A], typeInfoB: TypeInfo[B], typeInfoC: TypeInfo[C], typeInfoD: TypeInfo[D], typeInfoE: TypeInfo[E], typeInfoF: TypeInfo[F], typeInfoG: TypeInfo[G], typeInfoH: TypeInfo[H], typeInfoI: TypeInfo[I], typeInfoJ: TypeInfo[J]): Generator[(A, B, C, D, E, F, G, H, I) => J]

Attributes

implicit val intGenerator: Generator[Int]

A Generator that produces Int values.

A Generator that produces Int values.

Attributes

implicit def listGenerator[T](implicit genOfT: Generator[T]): Generator[List[T]] & HavingLength[List[T]]

Given an existing Generator[T], this creates a Generator[List[T]].

Given an existing Generator[T], this creates a Generator[List[T]].

Type parameters

T

the type that we are producing a List of

Value parameters

genOfT

a Generator that produces values of type T

Attributes

Returns

a List of values of type T

implicit val longGenerator: Generator[Long]

A Generator that produces Long values.

A Generator that produces Long values.

Attributes

implicit def mapGenerator[K, V](implicit genOfTuple2KV: Generator[(K, V)]): Generator[Map[K, V]] & HavingSize[Map[K, V]]

Given a Generator that produces Tuples of key/value pairs, this gives you one that produces Maps with those pairs.

Given a Generator that produces Tuples of key/value pairs, this gives you one that produces Maps with those pairs.

If you are simply looking for random pairing of the key and value types, this is pretty easy to use: if both the key and value types have Generators, then the Tuple and Map ones will be automatically and implicitly created when you need them.

The resulting Generator also has the HavingSize trait, so you can use it to generate Maps with specific sizes.

Type parameters

K

the type of the keys for the Map

V

the type of the values for the Map

Value parameters

genOfTuple2KV

a Generator that produces Tuples of K and V

Attributes

Returns

a Generator of Maps from K to V

implicit val negDoubleGenerator: Generator[NegDouble]

A Generator that produces negative Doubles, excluding zero but including infinity.

A Generator that produces negative Doubles, excluding zero but including infinity.

Attributes

implicit val negFiniteDoubleGenerator: Generator[NegFiniteDouble]

A Generator that produces negative Doubles, excluding zero and infinity.

A Generator that produces negative Doubles, excluding zero and infinity.

Attributes

implicit val negFiniteFloatGenerator: Generator[NegFiniteFloat]

A Generator that produces negative Floats, excluding zero and infinity.

A Generator that produces negative Floats, excluding zero and infinity.

Attributes

implicit val negFloatGenerator: Generator[NegFloat]

A Generator that produces negative Floats, excluding zero but including infinity.

A Generator that produces negative Floats, excluding zero but including infinity.

Attributes

implicit val negIntGenerator: Generator[NegInt]

A Generator that produces negative Ints, excluding zero.

A Generator that produces negative Ints, excluding zero.

Attributes

implicit val negLongGenerator: Generator[NegLong]

A Generator that produces negative Longs, excluding zero.

A Generator that produces negative Longs, excluding zero.

Attributes

implicit val negZDoubleGenerator: Generator[NegZDouble]

A Generator that produces negative Doubles, including zero and infinity.

A Generator that produces negative Doubles, including zero and infinity.

Attributes

implicit val negZFiniteDoubleGenerator: Generator[NegZFiniteDouble]

A Generator that produces negative Doubles, including zero but excluding infinity.

A Generator that produces negative Doubles, including zero but excluding infinity.

Attributes

implicit val negZFiniteFloatGenerator: Generator[NegZFiniteFloat]

A Generator that produces negative Floats, including zero but excluding infinity.

A Generator that produces negative Floats, including zero but excluding infinity.

Attributes

implicit val negZFloatGenerator: Generator[NegZFloat]

A Generator that produces negative Floats, including zero and infinity.

A Generator that produces negative Floats, including zero and infinity.

Attributes

implicit val negZIntGenerator: Generator[NegZInt]

A Generator that produces negative Ints, including zero.

A Generator that produces negative Ints, including zero.

Attributes

implicit val negZLongGenerator: Generator[NegZLong]

A Generator that produces negative Longs, including zero.

A Generator that produces negative Longs, including zero.

Attributes

implicit val nonZeroDoubleGenerator: Generator[NonZeroDouble]

A Generator that produces Doubles, excluding zero but including infinity.

A Generator that produces Doubles, excluding zero but including infinity.

Attributes

implicit val nonZeroFiniteDoubleGenerator: Generator[NonZeroFiniteDouble]

A Generator that produces Doubles, excluding zero and infinity.

A Generator that produces Doubles, excluding zero and infinity.

Attributes

implicit val nonZeroFiniteFloatGenerator: Generator[NonZeroFiniteFloat]

A Generator that produces Floats, excluding zero and infinity.

A Generator that produces Floats, excluding zero and infinity.

Attributes

implicit val nonZeroFloatGenerator: Generator[NonZeroFloat]

A Generator that produces Floats, excluding zero but including infinity.

A Generator that produces Floats, excluding zero but including infinity.

Attributes

implicit val nonZeroIntGenerator: Generator[NonZeroInt]

A Generator that produces integers, excluding zero.

A Generator that produces integers, excluding zero.

Attributes

implicit val nonZeroLongGenerator: Generator[NonZeroLong]

A Generator that produces Longs, excluding zero.

A Generator that produces Longs, excluding zero.

Attributes

implicit val numericCharGenerator: Generator[NumericChar]

A Generator that produces Chars, but only the ones that represent digits.

A Generator that produces Chars, but only the ones that represent digits.

Attributes

implicit def optionGenerator[T](implicit genOfT: Generator[T]): Generator[Option[T]]

Given a Generator for type T, this provides one for Option[T].

Given a Generator for type T, this provides one for Option[T].

Type parameters

T

the type to generate

Value parameters

genOfT

a Generator that produces type T

Attributes

Returns

a Generator that produces Option[T]

implicit def orGenerator[G, B](implicit genOfG: Generator[G], genOfB: Generator[B]): Generator[Or[G, B]]

Given Generators for two types, G and B, this provides one for G Or B.

Given Generators for two types, G and B, this provides one for G Or B.

Type parameters

B

the "bad" type for an Or

G

the "good" type for an Or

Value parameters

genOfB

a Generator that produces type B

genOfG

a Generator that produces type G

Attributes

Returns

a Generator that produces G Or B

implicit val posDoubleGenerator: Generator[PosDouble]

A Generator that produces positive Doubles, excluding zero but including infinity.

A Generator that produces positive Doubles, excluding zero but including infinity.

Attributes

implicit val posFiniteDoubleGenerator: Generator[PosFiniteDouble]

A Generator that produces positive Doubles, excluding zero and infinity.

A Generator that produces positive Doubles, excluding zero and infinity.

Attributes

implicit val posFiniteFloatGenerator: Generator[PosFiniteFloat]

A Generator that produces positive Floats, excluding zero and infinity.

A Generator that produces positive Floats, excluding zero and infinity.

Attributes

implicit val posFloatGenerator: Generator[PosFloat]

A Generator that produces positive Floats, excluding zero.

A Generator that produces positive Floats, excluding zero.

Attributes

implicit val posIntGenerator: Generator[PosInt]

A Generator that produces positive integers, excluding zero.

A Generator that produces positive integers, excluding zero.

Attributes

implicit val posLongGenerator: Generator[PosLong]

A Generator that produces positive Longs, excluding zero.

A Generator that produces positive Longs, excluding zero.

Attributes

implicit val posZDoubleGenerator: Generator[PosZDouble]

A Generator that produces positive Doubles, including zero and infinity.

A Generator that produces positive Doubles, including zero and infinity.

Attributes

implicit val posZFiniteDoubleGenerator: Generator[PosZFiniteDouble]

A Generator that produces positive Doubles, including zero but excluding infinity.

A Generator that produces positive Doubles, including zero but excluding infinity.

Attributes

implicit val posZFiniteFloatGenerator: Generator[PosZFiniteFloat]

A Generator that produces positive Floats, including zero but excluding infinity.

A Generator that produces positive Floats, including zero but excluding infinity.

Attributes

implicit val posZFloatGenerator: Generator[PosZFloat]

A Generator that produces positive Floats, including zero and infinity.

A Generator that produces positive Floats, including zero and infinity.

Attributes

implicit val posZIntGenerator: Generator[PosZInt]

A Generator that produces positive integers, including zero.

A Generator that produces positive integers, including zero.

Attributes

implicit val posZLongGenerator: Generator[PosZLong]

A Generator that produces positive Longs, including zero.

A Generator that produces positive Longs, including zero.

Attributes

implicit def setGenerator[T](implicit genOfT: Generator[T]): Generator[Set[T]] & HavingSize[Set[T]]

Given a Generator that produces values of type T, this creates one for a Set of T.

Given a Generator that produces values of type T, this creates one for a Set of T.

Note that the Set type is considered to have a "size", so you can use the configuration parameters Configuration.minSize and Configuration.sizeRange to constrain the sizes of the resulting Sets when you use this Generator.

The resulting Generator also has the HavingSize trait, so you can use it to generate Sets with specific sizes.

Type parameters

T

the type to produce

Value parameters

genOfT

a Generator that produces values of type T

Attributes

Returns

a Generator that produces Set[T].

implicit val shortGenerator: Generator[Short]

A Generator that produces Short values.

A Generator that produces Short values.

Attributes

implicit def sortedMapGenerator[K, V](implicit genOfTuple2KV: Generator[(K, V)], ordering: Ordering[K]): Generator[SortedMap[K, V]] & HavingSize[SortedMap[K, V]]

Given a Generator that produces Tuples of key/value pairs, this gives you one that produces SortedMaps with those pairs.

Given a Generator that produces Tuples of key/value pairs, this gives you one that produces SortedMaps with those pairs.

If you are simply looking for random pairing of the key and value types, this is pretty easy to use: if both the key and value types have Generators, then the Tuple and SortedMap ones will be automatically and implicitly created when you need them.

The resulting Generator also has the HavingSize trait, so you can use it to generate SortedMaps with specific sizes.

Type parameters

K

the type of the keys for the SortedMap

V

the type of the values for the SortedMap

Value parameters

genOfTuple2KV

a Generator that produces Tuples of K and V

Attributes

Returns

a Generator of SortedMaps from K to V

implicit def sortedSetGenerator[T](implicit genOfT: Generator[T], ordering: Ordering[T]): Generator[SortedSet[T]] & HavingSize[SortedSet[T]]

Given a Generator that produces values of type T, this creates one for a SortedSet of T.

Given a Generator that produces values of type T, this creates one for a SortedSet of T.

Note that the SortedSet type is considered to have a "size", so you can use the configuration parameters Configuration.minSize and Configuration.sizeRange to constrain the sizes of the resulting SortedSets when you use this Generator.

The resulting Generator also has the HavingSize trait, so you can use it to generate SortedSets with specific sizes.

Type parameters

T

the type to produce

Value parameters

genOfT

a Generator that produces values of type T

Attributes

Returns

a Generator that produces SortedSet[T].

implicit val stringGenerator: Generator[String]

A Generator that produces arbitrary Strings.

A Generator that produces arbitrary Strings.

Note that this does not confine itself to ASCII! While failed tests will try to shrink to readable ASCII, this will produce arbitrary Unicode Strings.

Attributes

implicit def tuple10Generator[A, B, C, D, E, F, G, H, I, J](implicit genOfA: Generator[A], genOfB: Generator[B], genOfC: Generator[C], genOfD: Generator[D], genOfE: Generator[E], genOfF: Generator[F], genOfG: Generator[G], genOfH: Generator[H], genOfI: Generator[I], genOfJ: Generator[J]): Generator[(A, B, C, D, E, F, G, H, I, J)]

Attributes

implicit def tuple11Generator[A, B, C, D, E, F, G, H, I, J, K](implicit genOfA: Generator[A], genOfB: Generator[B], genOfC: Generator[C], genOfD: Generator[D], genOfE: Generator[E], genOfF: Generator[F], genOfG: Generator[G], genOfH: Generator[H], genOfI: Generator[I], genOfJ: Generator[J], genOfK: Generator[K]): Generator[(A, B, C, D, E, F, G, H, I, J, K)]

Attributes

implicit def tuple12Generator[A, B, C, D, E, F, G, H, I, J, K, L](implicit genOfA: Generator[A], genOfB: Generator[B], genOfC: Generator[C], genOfD: Generator[D], genOfE: Generator[E], genOfF: Generator[F], genOfG: Generator[G], genOfH: Generator[H], genOfI: Generator[I], genOfJ: Generator[J], genOfK: Generator[K], genOfL: Generator[L]): Generator[(A, B, C, D, E, F, G, H, I, J, K, L)]

Attributes

implicit def tuple13Generator[A, B, C, D, E, F, G, H, I, J, K, L, M](implicit genOfA: Generator[A], genOfB: Generator[B], genOfC: Generator[C], genOfD: Generator[D], genOfE: Generator[E], genOfF: Generator[F], genOfG: Generator[G], genOfH: Generator[H], genOfI: Generator[I], genOfJ: Generator[J], genOfK: Generator[K], genOfL: Generator[L], genOfM: Generator[M]): Generator[(A, B, C, D, E, F, G, H, I, J, K, L, M)]

Attributes

implicit def tuple14Generator[A, B, C, D, E, F, G, H, I, J, K, L, M, N](implicit genOfA: Generator[A], genOfB: Generator[B], genOfC: Generator[C], genOfD: Generator[D], genOfE: Generator[E], genOfF: Generator[F], genOfG: Generator[G], genOfH: Generator[H], genOfI: Generator[I], genOfJ: Generator[J], genOfK: Generator[K], genOfL: Generator[L], genOfM: Generator[M], genOfN: Generator[N]): Generator[(A, B, C, D, E, F, G, H, I, J, K, L, M, N)]

Attributes

implicit def tuple15Generator[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O](implicit genOfA: Generator[A], genOfB: Generator[B], genOfC: Generator[C], genOfD: Generator[D], genOfE: Generator[E], genOfF: Generator[F], genOfG: Generator[G], genOfH: Generator[H], genOfI: Generator[I], genOfJ: Generator[J], genOfK: Generator[K], genOfL: Generator[L], genOfM: Generator[M], genOfN: Generator[N], genOfO: Generator[O]): Generator[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O)]

Attributes

implicit def tuple16Generator[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P](implicit genOfA: Generator[A], genOfB: Generator[B], genOfC: Generator[C], genOfD: Generator[D], genOfE: Generator[E], genOfF: Generator[F], genOfG: Generator[G], genOfH: Generator[H], genOfI: Generator[I], genOfJ: Generator[J], genOfK: Generator[K], genOfL: Generator[L], genOfM: Generator[M], genOfN: Generator[N], genOfO: Generator[O], genOfP: Generator[P]): Generator[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P)]

Attributes

implicit def tuple17Generator[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q](implicit genOfA: Generator[A], genOfB: Generator[B], genOfC: Generator[C], genOfD: Generator[D], genOfE: Generator[E], genOfF: Generator[F], genOfG: Generator[G], genOfH: Generator[H], genOfI: Generator[I], genOfJ: Generator[J], genOfK: Generator[K], genOfL: Generator[L], genOfM: Generator[M], genOfN: Generator[N], genOfO: Generator[O], genOfP: Generator[P], genOfQ: Generator[Q]): Generator[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q)]

Attributes

implicit def tuple18Generator[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R](implicit genOfA: Generator[A], genOfB: Generator[B], genOfC: Generator[C], genOfD: Generator[D], genOfE: Generator[E], genOfF: Generator[F], genOfG: Generator[G], genOfH: Generator[H], genOfI: Generator[I], genOfJ: Generator[J], genOfK: Generator[K], genOfL: Generator[L], genOfM: Generator[M], genOfN: Generator[N], genOfO: Generator[O], genOfP: Generator[P], genOfQ: Generator[Q], genOfR: Generator[R]): Generator[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R)]

Attributes

implicit def tuple19Generator[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S](implicit genOfA: Generator[A], genOfB: Generator[B], genOfC: Generator[C], genOfD: Generator[D], genOfE: Generator[E], genOfF: Generator[F], genOfG: Generator[G], genOfH: Generator[H], genOfI: Generator[I], genOfJ: Generator[J], genOfK: Generator[K], genOfL: Generator[L], genOfM: Generator[M], genOfN: Generator[N], genOfO: Generator[O], genOfP: Generator[P], genOfQ: Generator[Q], genOfR: Generator[R], genOfS: Generator[S]): Generator[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S)]

Attributes

implicit def tuple20Generator[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T](implicit genOfA: Generator[A], genOfB: Generator[B], genOfC: Generator[C], genOfD: Generator[D], genOfE: Generator[E], genOfF: Generator[F], genOfG: Generator[G], genOfH: Generator[H], genOfI: Generator[I], genOfJ: Generator[J], genOfK: Generator[K], genOfL: Generator[L], genOfM: Generator[M], genOfN: Generator[N], genOfO: Generator[O], genOfP: Generator[P], genOfQ: Generator[Q], genOfR: Generator[R], genOfS: Generator[S], genOfT: Generator[T]): Generator[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T)]

Attributes

implicit def tuple21Generator[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U](implicit genOfA: Generator[A], genOfB: Generator[B], genOfC: Generator[C], genOfD: Generator[D], genOfE: Generator[E], genOfF: Generator[F], genOfG: Generator[G], genOfH: Generator[H], genOfI: Generator[I], genOfJ: Generator[J], genOfK: Generator[K], genOfL: Generator[L], genOfM: Generator[M], genOfN: Generator[N], genOfO: Generator[O], genOfP: Generator[P], genOfQ: Generator[Q], genOfR: Generator[R], genOfS: Generator[S], genOfT: Generator[T], genOfU: Generator[U]): Generator[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U)]

Attributes

implicit def tuple22Generator[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V](implicit genOfA: Generator[A], genOfB: Generator[B], genOfC: Generator[C], genOfD: Generator[D], genOfE: Generator[E], genOfF: Generator[F], genOfG: Generator[G], genOfH: Generator[H], genOfI: Generator[I], genOfJ: Generator[J], genOfK: Generator[K], genOfL: Generator[L], genOfM: Generator[M], genOfN: Generator[N], genOfO: Generator[O], genOfP: Generator[P], genOfQ: Generator[Q], genOfR: Generator[R], genOfS: Generator[S], genOfT: Generator[T], genOfU: Generator[U], genOfV: Generator[V]): Generator[(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V)]

Attributes

implicit def tuple2Generator[A, B](implicit genOfA: Generator[A], genOfB: Generator[B]): Generator[(A, B)]

Given Generators for types A and B, get one that produces Tuples of those types.

Given Generators for types A and B, get one that produces Tuples of those types.

tuple2Generator (and its variants, up through tuple22Generator) will create Generators on demand for essentially arbitrary Tuples, so long as you have Generators in implicit scope for all of the component types.

Type parameters

A

the first type in the Tuple

B

the second type in the Tuple

Value parameters

genOfA

a Generator for type A

genOfB

a Generator for type B

Attributes

Returns

a Generator that produces the desired types, Tupled together.

implicit def tuple3Generator[A, B, C](implicit genOfA: Generator[A], genOfB: Generator[B], genOfC: Generator[C]): Generator[(A, B, C)]

Attributes

implicit def tuple4Generator[A, B, C, D](implicit genOfA: Generator[A], genOfB: Generator[B], genOfC: Generator[C], genOfD: Generator[D]): Generator[(A, B, C, D)]

Attributes

implicit def tuple5Generator[A, B, C, D, E](implicit genOfA: Generator[A], genOfB: Generator[B], genOfC: Generator[C], genOfD: Generator[D], genOfE: Generator[E]): Generator[(A, B, C, D, E)]

Attributes

implicit def tuple6Generator[A, B, C, D, E, F](implicit genOfA: Generator[A], genOfB: Generator[B], genOfC: Generator[C], genOfD: Generator[D], genOfE: Generator[E], genOfF: Generator[F]): Generator[(A, B, C, D, E, F)]

Attributes

implicit def tuple7Generator[A, B, C, D, E, F, G](implicit genOfA: Generator[A], genOfB: Generator[B], genOfC: Generator[C], genOfD: Generator[D], genOfE: Generator[E], genOfF: Generator[F], genOfG: Generator[G]): Generator[(A, B, C, D, E, F, G)]

Attributes

implicit def tuple8Generator[A, B, C, D, E, F, G, H](implicit genOfA: Generator[A], genOfB: Generator[B], genOfC: Generator[C], genOfD: Generator[D], genOfE: Generator[E], genOfF: Generator[F], genOfG: Generator[G], genOfH: Generator[H]): Generator[(A, B, C, D, E, F, G, H)]

Attributes

implicit def tuple9Generator[A, B, C, D, E, F, G, H, I](implicit genOfA: Generator[A], genOfB: Generator[B], genOfC: Generator[C], genOfD: Generator[D], genOfE: Generator[E], genOfF: Generator[F], genOfG: Generator[G], genOfH: Generator[H], genOfI: Generator[I]): Generator[(A, B, C, D, E, F, G, H, I)]

Attributes

implicit def vectorGenerator[T](implicit genOfT: Generator[T]): Generator[Vector[T]] & HavingLength[Vector[T]]

Given a Generator for type T, this creates one for a Vector of T.

Given a Generator for type T, this creates one for a Vector of T.

Note that the Vector type is considered to have a "size", so you can use the configuration parameters Configuration.minSize and Configuration.sizeRange to constrain the sizes of the resulting Vectors when you use this Generator.

The resulting Generator also has the HavingLength trait, so you can use it to generate Vectors with specific lengths.

Type parameters

T

the type to produce

Value parameters

genOfT

a Generator that produces values of type T

Attributes

Returns

a Generator that produces values of type Vector[T]

implicit def widen[T, U](genOfT: Generator[T])(implicit ev: T <:< U): Generator[U]

Allow Generators of a type to be used as Generators of a supertype.

Allow Generators of a type to be used as Generators of a supertype.

Given:

  • You have a type T
  • T has a supertype U
  • You have a Generator that produces values of T

This allows you to pass that Generator[T] as a Generator[U].

We do this instead of making Generator covariant, because then an implicit search for a Generator[U] would always be satisfied if it found just a Generator[T], and would then not generate anything except the subtype. That would be sound, but you wouldn't get a good variety of supertype values. This way, the subtype/supertype conversion is somewhat better-controlled.

Type parameters

T

the subtype that we have a Generator for

U

the supertype that we want a Generator for

Value parameters

ev

implicit evidence that T is a subtype of U

genOfT

a Generator that produces values of T

Attributes

Returns

a Generator[U] derived from the Generator[T]