GenOrThrow

@deprecated("Use GenFromConfig instead. This class requires a ClassTag and is not as reusable as GenFromConfig. ".+("It will be removed in the next major version."), "2.7.0")
class GenOrThrow[T](val gen: Gen[T])(implicit evidence$1: ClassTag[T])

Provides the ability to convert a Gen into an Iterator

Type parameters:
T

the type of value produced by the generator

Value parameters:
gen

a generator of some kind

Deprecated
class Object
trait Matchable
class Any

Value members

Concrete methods

def iterator(implicit c: GenConfig): Iterator[T]
Throws:
EmptyGenSampleException

when samples cannot be generated after the given number of attempts

Deprecated methods

@deprecated("Use .getConfigured(_.withSeed(seed)) instead.", "2.7.0")
def getOrThrow(seed: Seed): T
Deprecated
@deprecated("Do not provide the number of retries. This method will be removed in the next major version.", "2.3.0")
def getOrThrow(attempts: Int): T

Get the next element from this generator using the default seed with the given number of retries.

Get the next element from this generator using the default seed with the given number of retries.

Throws:
EmptyGenSampleException

when samples cannot be generated after the given number of attempts

Deprecated
@deprecated("If you need a random sample on each call, use .nextRandom() -- ".+("otherwise, if you want a stateless function, use .head instead."), "2.3.0")
def getOrThrow: T
Throws:
EmptyGenSampleException

when samples cannot be generated after a default number of attempts

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")
def getOrThrowPure(implicit c: GenConfig): T
See also:
Deprecated
@deprecated("Use .nextRandom() instead.", "2.7.0")
def randomOrThrow()(implicit c: GenConfig): T
See also:
Deprecated
@deprecated("Use .iterator.to() instead. ".+("If you need to specify retries, you can pass the argument GenConfig.defaults.withRetries(n) to .iterator"), "2.3.0")
def toIterable(attempts: Int): Iterable[T]

Converts this generator into a lazy Iterable so that it can be converted into a collection.

Converts this generator into a lazy Iterable so that it can be converted into a collection.

Value parameters:
attempts

the number of attempts to try generating a sample before throwing an execption

Returns:

A lazy iterable that pulls from this generator or throws an exception

Throws:
EmptyGenSampleException

when a sample cannot be generated after the given number of attempts

Deprecated
@deprecated("Use .iterator.to() instead", "2.3.0")
def toIterable: Iterable[T]
Deprecated
@deprecated("Use .iterator instead. ".+("If you need to specify retries, you can pass the argument GenConfig.defaults.withRetries(n) to .iterator"), "2.3.0")
def toIterator(attempts: Int): Iterator[T]

Converts this generator into an infinite Iterator for a more flexible pull-based API.

Converts this generator into an infinite Iterator for a more flexible pull-based API.

Value parameters:
attempts

the number of attempts to try generating a sample before throwing an execption

Returns:

An iterator that pulls from this generator or throws an exception

Throws:
EmptyGenSampleException

when samples cannot be generated after the given number of attempts

Deprecated
@deprecated("Use .iterator instead", "2.3.0")
def toIterator: Iterator[T]
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]
@deprecated("Use Try(gen.getConfigured(_.withSeed(seed))) instead.", "2.7.0")
def tryGet(seed: Seed): Try[T]

Get the next element from this generator using the given seed and default size and number of retries.

Get the next element from this generator using the given seed and default size and number of retries.

Deprecated
@deprecated("Do not provide the number of retries. This method will be removed in the next major version.", "2.3.0")
def tryGet(attempts: Int): Try[T]

Try to get a non-empty sample for a given number of tries and return the resulting get attempts in a Try.

Try to get a non-empty sample for a given number of tries and return the resulting get attempts in a Try.

Value parameters:
attempts

the number of attempts to get a non-empty sample before returning a Failure.

Returns:

Either a non-empty sample or a Failure with information about what sample was tried.

Deprecated
@deprecated("This method will be removed in the next major version", "2.3.0")
def tryGet: Try[T]

Same as Try(gen.randomOrThrow())

Same as Try(gen.randomOrThrow())

Deprecated

Concrete fields

val gen: Gen[T]