A Generator that produces Boolean values.
A Generator that produces Byte values.
A Generator that produces Char values.
A Generator that produces Double values.
Given Generators for two types, L and R, this provides one for Either[L, R].
A Generator that produces Doubles, excluding infinity.
A Generator that produces Floats, excluding infinity.
A Generator that produces Float values.
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.
See function1Generator.
See function1Generator.
See function1Generator.
See function1Generator.
See function1Generator.
See function1Generator.
See function1Generator.
See function1Generator.
See function1Generator.
See function1Generator.
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.
the input type for the generated functions
the result type for the generated functions
a Generator for the desired result type B
automatically-created type information for type A
automatically-created type information for type B
a Generator that produces functions that take values of A and returns values of B
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.
See function1Generator.
See function1Generator.
See function1Generator.
See function1Generator.
See function1Generator.
See function1Generator.
See function1Generator.
See function1Generator.
See function1Generator.
See function1Generator.
See function1Generator.
A Generator that produces Int values.
Given an existing Generator[T], this creates a Generator[List[T]].
Given an existing Generator[T], this creates a Generator[List[T]].
the type that we are producing a List of
a Generator that produces values of type T
a List of values of type T
A Generator that produces Long values.
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.
A Generator that produces negative Doubles, excluding zero but including infinity.
A Generator that produces negative Doubles, excluding zero and infinity.
A Generator that produces negative Floats, excluding zero and infinity.
A Generator that produces negative Floats, excluding zero but including infinity.
A Generator that produces negative Ints, excluding zero.
A Generator that produces negative Longs, excluding zero.
A Generator that produces negative Doubles, including zero and infinity.
A Generator that produces negative Doubles, including zero but excluding infinity.
A Generator that produces negative Floats, including zero but excluding infinity.
A Generator that produces negative Floats, including zero and infinity.
A Generator that produces negative Ints, including zero.
A Generator that produces negative Longs, including zero.
A Generator that produces Doubles, excluding zero but including infinity.
A Generator that produces Doubles, excluding zero and infinity.
A Generator that produces Floats, excluding zero and infinity.
A Generator that produces Floats, excluding zero but including infinity.
A Generator that produces integers, excluding zero.
A Generator that produces Longs, excluding zero.
A Generator that produces Chars, but only the ones that represent digits.
Given a Generator for type T, this provides one for Option[T].
Given Generators for two types, G and B, this provides one for G Or B.
A Generator that produces positive Doubles, excluding zero but including infinity.
A Generator that produces positive Doubles, excluding zero and infinity.
A Generator that produces positive Floats, excluding zero and infinity.
A Generator that produces positive Floats, excluding zero.
A Generator that produces positive integers, excluding zero.
A Generator that produces positive Longs, excluding zero.
A Generator that produces positive Doubles, including zero and infinity.
A Generator that produces positive Doubles, including zero but excluding infinity.
A Generator that produces positive Floats, including zero but excluding infinity.
A Generator that produces positive Floats, including zero and infinity.
A Generator that produces positive integers, including zero.
A Generator that produces positive Longs, including zero.
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.
A Generator that produces Short values.
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.
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.
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.
See tuple2Generator.
See tuple2Generator.
See tuple2Generator.
See tuple2Generator.
See tuple2Generator.
See tuple2Generator.
See tuple2Generator.
See tuple2Generator.
See tuple2Generator.
See tuple2Generator.
See tuple2Generator.
See tuple2Generator.
See tuple2Generator.
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.
See tuple2Generator.
See tuple2Generator.
See tuple2Generator.
See tuple2Generator.
See tuple2Generator.
See tuple2Generator.
See tuple2Generator.
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.
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:
TT has a supertype UTThis 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.
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.