GenFromConfig

final class GenFromConfig[T](gen: Gen[T], config: GenConfig, typeName: String)
class Object
trait Matchable
class Any

Value members

Concrete methods

Modify the captured GenConfig using the given function.

Modify the captured GenConfig using the given function.

@throws("When the number of attempts to generate a valid sample is exhausted because ".+("the filters on this generator are too restrictive."))
def head: T

Get the first instance of this generator with the given configuration.

Get the first instance of this generator with the given configuration.

Note:

this is a stateless function and calling this method with the same config will always produce the same result.

@throws("When the number of attempts to generate a valid sample is exhausted because ".+("the filters on this generator are too restrictive."))
def iterator: Iterator[T]

An iterator made by attempting to find each next sample after the given number of retries.

An iterator made by attempting to find each next sample after the given number of retries.

Returns:

An iterator that will generate from the given starting seed

Note:

This uses the new pureApply feature only available in ScalaCheck versions >=1.14.x

@throws("When the number of attempts to generate a valid sample is exhausted because ".+("the filters on this generator are too restrictive."))
def nextRandom(rng: Random): T

Get a random element from this generator using the default seed.

Get a random element from this generator using the default seed.

Generators can run out of samples and return empty results. Typically, this will be the result of bad Gen Parameters or having too many suchThat() restrictions that make it difficult to find the next sample.

@throws("When the number of attempts to generate a valid sample is exhausted because ".+("the filters on this generator are too restrictive."))
def nextRandomIterator(rng: Random): Iterator[T]

Effectively the same as calling nextRandom with Iterator.continually, except that the given Random number generator is only used to generate the first seed and all subsequent iterations are produced from Seed.next.

Effectively the same as calling nextRandom with Iterator.continually, except that the given Random number generator is only used to generate the first seed and all subsequent iterations are produced from Seed.next.

Value parameters:
rng

the random number generator used to initialize the seed.

Note:

If you want to provide a consistent Seed, you should use configured to set GenConfig.withSeed and then call iterator.

def sampleIterator: Iterator[Option[T]]

An iterator made by Iterator.continually calling Gen.sample.

An iterator made by Iterator.continually calling Gen.sample.

Returns:

An iterator of Options which are None if the generator's filters ruled out the sample.

Note:

If the generator has filters, then this method could return None a lot. If you want a safe way to filter the Nones, see iterator

This will use a random seed for each sample. If you want to get the same iterator from the same seed, you would have to use iterator and handle the possible.

@throws("When the number of attempts to generate a valid sample is exhausted because ".+("the filters on this generator are too restrictive."))
def valueFor(seed: Seed): T

Effectively shorthand for .configured(_.withSeed(seed)).head.

Effectively shorthand for .configured(_.withSeed(seed)).head.

Deprecated methods

@deprecated("If you need a random sample on each call, use .nextRandom()\n".+("If you want a stateless function, use .head\n").+("If you want to pass a specific Seed, use .configured(_.withSeed(seed)).head"), "2.3.0") @throws("When the number of attempts to generate a valid sample is exhausted because ".+("the filters on this generator are too restrictive."))
def getOrThrow: T

Get a random element from this generator using the default seed.

Get a random element from this generator using the default seed.

Generators can run out of samples and return empty results. Typically, this will be the result of bad Gen Parameters or having too many suchThat() restrictions that make it difficult to find the next sample.

Deprecated
@deprecated("Use .head instead. This method is contradictory ".+("(throwing an exception makes the function partially undefined and thus impure) and verbose ").+("(this has very similar semantics to the familiar .head method on Scala collections)"), "2.7.0") @throws("When the number of attempts to generate a valid sample is exhausted because ".+("the filters on this generator are too restrictive."))
See also:
Deprecated
@deprecated("This is generally a bad idea and is easy enough to inline. It will be removed in the next major version.", "2.7.0")
def toUnboundedIterator: Iterator[T]

Converts this generator to an Iterator in the obvious (but potentially dangerous) way.

Converts this generator to an Iterator in the obvious (but potentially dangerous) way.

Returns:

An Iterator that returns only the defined samples.

See also:

iterator for a safer, bounded alternative.

Note:

This pulls an item from the generator one at a time, however, if the generator has too many restrictive filters, this can result in an infinite loop.

Deprecated