Context

public class Context

The context will be passed through all generators

It’s main purpose is to hold onto the Random Number Generator rng, so that as generations occur the RNG’s state changes are propogated to each generator

Note

The context can be held onto by a user to keep track of rng‘s state between generations

Randomness

  • The original seed used to begin random number generation, if available

    To be used for debugging purposes and to “replay” a generation event

    Declaration

    Swift

    public let originalSeed: UInt64?

Mutate

  • The maximum depth that a generator which rejects values can reach before failing

    See also

    Gen.filter(isIncluded:)

    See also

    Gen.unique()

    Declaration

    Swift

    public var maxDepth: Int

Produce

  • The maximum iterations that producers should run for

    See also

    Gen.forEach(iterations:context:)

    See also

    Gen.allSatisfy(iterations:context:)

    Declaration

    Swift

    public var maxIterations: Int

Init

  • Creates a Context

    Declaration

    Swift

    public init(using rng: RandomNumberGenerator, originalSeed: UInt64? = nil)

    Parameters

    rng

    The Random Number Generator to be used to produce values

    originalSeed

    The original seed (start position) of rng, if possible

  • Initializes a Context with a Determinism

    Declaration

    Swift

    convenience init(determinism: Determinism)

Convenience Context creators

  • Creates a Context initialized to default values, with random Determinism

    Declaration

    Swift

    static var random: Context { get }
  • Creates a defaultContext

    Declaration

    Swift

    static var `default`: Context { get }