Gen

object Gen extends GenTOps with ByteOps with CharacterOps with StringOps

This is purely to make consuming this library a nicer experience, mainly due to Scala's type inference problems and higher kinds.

trait StringOps
trait ByteOps
trait GenTOps
class Object
trait Matchable
class Any
Gen.type

Value members

Inherited methods

def alpha: GenT[Char]

Generates an ASCII letter: 'a' to 'z', 'A' to 'Z'

Generates an ASCII letter: 'a' to 'z', 'A' to 'Z'

Inherited from:
CharacterOps
def alphaNum: GenT[Char]

Generates an ASCII letter or digit: 'a' to 'z', 'A' to 'Z', '0' to '9'

Generates an ASCII letter or digit: 'a' to 'z', 'A' to 'Z', '0' to '9'

Inherited from:
CharacterOps
def ascii: GenT[Char]

Generates an ASCII character

Generates an ASCII character

Inherited from:
CharacterOps
def binit: GenT[Char]

Generates an ASCII binit: '0' to '1'

Generates an ASCII binit: '0' to '1'

Inherited from:
CharacterOps
def boolean: GenT[Boolean]

Generates a random boolean.

Generates a random boolean.

This generator shrinks to 'False'.

Inherited from:
GenTOps
def byte(range: Range[Byte]): GenT[Byte]
Inherited from:
GenTOps
def bytes(range: Range[Int]): GenT[Array[Byte]]

Generates a random 'Array[Byte]', using 'Range' to determine the length.

Generates a random 'Array[Byte]', using 'Range' to determine the length.

Shrinks down to the ascii characters.

Inherited from:
ByteOps
def char(lo: Char, hi: Char): GenT[Char]
Inherited from:
GenTOps
def choice[A](x: GenT[A], xs: List[GenT[A]]): GenT[A]

Randomly selects one of the generators in the list.

Randomly selects one of the generators in the list.

This generator shrinks towards the first generator in the list.

Inherited from:
GenTOps
def choice1[A](x: GenT[A], xs: GenT[A]*): GenT[A]

Randomly selects one of the generators in the list.

Randomly selects one of the generators in the list.

This generator shrinks towards the first generator in the list.

Inherited from:
GenTOps
def constant[A](x: => A): GenT[A]

Trivial generator that always produces the same element.

Trivial generator that always produces the same element.

Inherited from:
GenTOps
def digit: GenT[Char]

Generates an ASCII digit: '0' to '9'

Generates an ASCII digit: '0' to '9'

Inherited from:
CharacterOps
def discard[A](implicit G: MonadGenT[Gen]): GenT[A]

Discards the whole generator.

Discards the whole generator.

Inherited from:
MonadGenOps
def double(range: Range[Double]): GenT[Double]

Inherited from:
GenTOps
def double_(range: Range[Double]): GenT[Double]
Inherited from:
GenTOps
def element[A](x: A, xs: List[A]): GenT[A]

Randomly selects one of the elements in the list.

Randomly selects one of the elements in the list.

This generator shrinks towards the first element in the list.

Inherited from:
GenTOps
def element1[A](x: A, xs: A*): GenT[A]

Randomly selects one of the elements in the list.

Randomly selects one of the elements in the list.

This generator shrinks towards the first element in the list.

Inherited from:
GenTOps
def elementUnsafe[A](xs: List[A]): GenT[A]

Randomly selects one of the elements in the list.

Randomly selects one of the elements in the list.

This generator shrinks towards the first element in the list.

WARNING: This may throw an exception if the list is empty, please use one of the other element variants if possible

Inherited from:
GenTOps
def ensure[A](gen: GenT[A], p: A => Boolean)(implicit F: Monad[Gen], G: MonadGenT[Gen]): GenT[A]

Discards the generator if the generated value does not satisfy the predicate.

Discards the generator if the generated value does not satisfy the predicate.

Inherited from:
MonadGenOps
def filter[A](gen: GenT[A])(p: A => Boolean)(implicit F: Monad[Gen], G: MonadGenT[Gen]): GenT[A]

Generates a value that satisfies a predicate.

Generates a value that satisfies a predicate.

We keep some state to avoid looping forever. If we trigger these limits then the whole generator is discarded.

Inherited from:
MonadGenOps
def frequency[A](a: (Int, GenT[A]), l: List[(Int, GenT[A])]): GenT[A]

Uses a weighted distribution to randomly select one of the generators in the list.

Uses a weighted distribution to randomly select one of the generators in the list.

This generator shrinks towards the first generator in the list.

Inherited from:
GenTOps
def frequency1[A](a: (Int, GenT[A]), l: (Int, GenT[A])*): GenT[A]

Uses a weighted distribution to randomly select one of the generators in the list.

Uses a weighted distribution to randomly select one of the generators in the list.

This generator shrinks towards the first generator in the list.

Inherited from:
GenTOps
def frequencyUnsafe[A](xs: List[(Int, GenT[A])]): GenT[A]

Uses a weighted distribution to randomly select one of the generators in the list.

Uses a weighted distribution to randomly select one of the generators in the list.

This generator shrinks towards the first generator in the list.

WARNING: This may throw an exception if the list is empty, please use one of the other frequency variants if possible.

Inherited from:
GenTOps
def fromSome[A](gen: GenT[Option[A]])(implicit F: Monad[Gen], G: MonadGenT[Gen]): GenT[A]

Runs a Option generator until it produces a Some.

Runs a Option generator until it produces a Some.

This is implemented using filter and has the same caveats.

Inherited from:
MonadGenOps
def generate[A](f: (Size, Seed) => (Seed, A))(implicit G: MonadGenT[Gen]): GenT[A]

Construct a generator that depends on the size parameter.

Construct a generator that depends on the size parameter.

Inherited from:
MonadGenOps
def hexit: GenT[Char]

Generates an ASCII hexit: '0' to '9', 'a' to 'f', 'A' to 'F'

Generates an ASCII hexit: '0' to '9', 'a' to 'f', 'A' to 'F'

Inherited from:
CharacterOps
def int(range: Range[Int]): GenT[Int]

Inherited from:
GenTOps
def integral[A : Integral](range: Range[A], fromLong: Long => A)(implicit evidence$1: Integral[A], F: MonadGenT[Gen]): GenT[A]

Generates a random integral number in the given [inclusive,inclusive] range.

Generates a random integral number in the given [inclusive,inclusive] range.

When the generator tries to shrink, it will shrink towards the Range.origin of the specified Range.

For example, the following generator will produce a number between 1970 and 2100, but will shrink towards 2000:

Gen.integral(Range.constantFrom(2000, 1970, 2100))

Some sample outputs from this generator might look like:

=== Outcome ===
1973
=== Shrinks ===
2000
1987
1980
1976
1974

=== Outcome ===
2061
=== Shrinks ===
2000
2031
2046
2054
2058
2060
Inherited from:
MonadGenOps
def integral_[A](range: Range[A], fromLong: Long => A)(implicit G: MonadGenT[Gen], I: Integral[A]): GenT[A]

Generates a random integral number in the [inclusive,inclusive] range.

Generates a random integral number in the [inclusive,inclusive] range.

''This generator does not shrink.''

Inherited from:
MonadGenOps
def latin1: GenT[Char]

Generates an Latin-1 character

Generates an Latin-1 character

Inherited from:
CharacterOps
def list[A](gen: GenT[A], range: Range[Int])(implicit F: Monad[Gen], G: MonadGenT[Gen]): GenT[List[A]]

Generates a list using a 'Range' to determine the length.

Generates a list using a 'Range' to determine the length.

Inherited from:
MonadGenOps
def long(range: Range[Long]): GenT[Long]
Inherited from:
GenTOps
def lower: GenT[Char]

Generates an ASCII lowercase letter: 'a' to 'z'

Generates an ASCII lowercase letter: 'a' to 'z'

Inherited from:
CharacterOps
def octit: GenT[Char]

Generates an ASCII octit: '0' to '7'

Generates an ASCII octit: '0' to '7'

Inherited from:
CharacterOps
def short(range: Range[Short]): GenT[Short]
Inherited from:
GenTOps
def sized[A](f: Size => GenT[A])(implicit F: Monad[Gen], G: MonadGenT[Gen]): GenT[A]

Construct a generator that depends on the size parameter.

Construct a generator that depends on the size parameter.

Inherited from:
MonadGenOps
def string(gen: GenT[Char], range: Range[Int]): GenT[String]

Generates a string using 'Range' to determine the length.

Generates a string using 'Range' to determine the length.

Inherited from:
StringOps
def unicode: GenT[Char]

Generates a Unicode character, excluding noncharacters and invalid standalone surrogates:

Generates a Unicode character, excluding noncharacters and invalid standalone surrogates:

Inherited from:
CharacterOps
def unicodeAll: GenT[Char]

Generates a Unicode character, including noncharacters and invalid standalone surrogates

Generates a Unicode character, including noncharacters and invalid standalone surrogates

Inherited from:
CharacterOps
def upper: GenT[Char]

Generates an ASCII uppercase letter: 'A' to 'Z'

Generates an ASCII uppercase letter: 'A' to 'Z'

Inherited from:
CharacterOps