Skip to main content

clojure.test.check.generators

-

  • ->Generator

    Positional factory function for class clojure.test.check.generators.Generator.

A

  • any

    A recursive generator that will generate many different, often nested, values

  • any-equatable

    Like any, but only generates objects that can be equal to other objects (e.g., do not contain a NaN)

  • any-printable

    Like any, but avoids characters that the shell will interpret as actions, like 7 and 14 (bell and alternate character ...

  • any-printable-equatable

    Like any, but avoids characters that the shell will interpret as actions, like 7 and 14 (bell and alternate character ...

B

  • big-ratio

    Generates a ratio (or integer) using gen/size-bounded-bigint. Shrinks toward simpler ratios, which may be larger or sm...

  • bind

    Creates a new generator that passes the result of `gen` into function `f`. `f` should return a new generator. This all...

  • boolean

    Generates one of `true` or `false`. Shrinks to `false`.

  • byte

    Generates `java.lang.Byte`s, using the full byte-range.

  • bytes

    Generates byte-arrays.

C

  • call-gen

    Internal function.

  • char

    Generates character from 0-255.

  • char-alpha

    Generates alpha characters.

  • char-alpha-numeric

    Deprecated - use char-alphanumeric instead. Generates alphanumeric characters.

  • char-alphanumeric

    Generates alphanumeric characters.

  • char-ascii

    Generates only ascii characters.

  • choose

    Creates a generator that generates integers uniformly in the range `lower` to `upper`, inclusive. (gen/sa...

D

  • double

    Generates 64-bit floating point numbers from the entire range, including +/- infinity and NaN. Use double* for more co...

  • double*

    Generates a 64-bit floating point number. Options: :infinite? - whether +/- infinity can be generated (default true...

E

  • elements

    Creates a generator that randomly chooses an element from `coll`. (gen/sample (gen/elements [:foo :bar :baz])) ...

F

  • fmap

    Returns a generator like `gen` but with values transformed by `f`. E.g.: (gen/sample (gen/fmap str gen/nat)) ...

  • frequency

    Creates a generator that chooses a generator from `pairs` based on the provided likelihoods. The likelihood of a given...

G

  • gen-bind

    Internal function.

  • gen-fmap

    Internal function.

  • gen-pure

    Internal function.

  • generate

    Returns a single sample value from the generator. Note that this function is a dev helper and is not meant to be used...

  • generator?

    Test if `x` is a generator. Generators should be treated as opaque values.

H

  • hash-map

    Like clojure.core/hash-map, except the values are generators. Returns a generator that makes maps with the supplied k...

I

  • int

    Deprecated - use gen/small-integer instead. Generates a positive or negative integer bounded by the generator's `si...

K

  • keyword

    Generates keywords without namespaces.

  • keyword-ns

    Generates keywords with namespaces.

L

  • large-integer

    Generates a platform-native integer from the full available range (in clj, 64-bit Longs, and in cljs, numbers between ...

  • large-integer*

    Like large-integer, but accepts options: :min the minimum integer (inclusive) :max the maximum integer (inclu...

  • lazy-random-states

    Internal function. Given a random number generator, returns an infinite lazy sequence of random number generators.

  • let

    Macro for building generators using values from other generators. Uses a binding vector with the same syntax as clojur...

  • list

    Like `vector`, but generates lists.

  • list-distinct

    Generates a list of elements from the given generator, with the guarantee that the elements will be distinct. If th...

  • list-distinct-by

    Generates a list of elements from the given generator, with the guarantee that (map key-fn the-list) will be distinct....

M

  • make-size-range-seq

    Internal function.

  • map

    Creates a generator that generates maps, with keys chosen from `key-gen` and values chosen from `val-gen`. If the k...

  • map->Generator

    Factory function for class clojure.test.check.generators.Generator, taking a map of keywords to field values.

N

  • nat

    Generates non-negative integers bounded by the generator's `size` parameter. Shrinks to zero.

  • neg-int

    Deprecated - use (gen/fmap - gen/nat) instead (see also gen/large-integer). (this generator, despite its name, can ge...

  • no-shrink

    Creates a new generator that is just like `gen`, except does not shrink at all. This can be useful when shrinking is t...

  • not-empty

    Modifies a generator so that it doesn't generate empty collections. Examples: ;; generate a vector of booleans...

O

  • one-of

    Creates a generator that randomly chooses a value from the list of provided generators. Shrinks toward choosing an ear...

P

  • pos-int

    Deprecated - use gen/nat instead (see also gen/large-integer). (this generator, despite its name, can generate 0) ...

R

  • ratio

    Generates a small ratio (or integer) using gen/small-integer. Shrinks toward simpler ratios, which may be larger or sm...

  • recursive-gen

    This is a helper for writing recursive (tree-shaped) generators. The first argument should be a function that takes a ...

  • resize

    Creates a new generator with `size` always bound to `n`. (gen/sample (gen/set (gen/resize 200 gen/double))) ...

  • return

    Creates a generator that always returns `value`, and never shrinks. You can think of this as the `constantly` of gen...

S

  • s-neg-int

    Deprecated - use (gen/fmap (comp dec -) gen/nat) instead (see also gen/large-integer). Generates negative integers bo...

  • s-pos-int

    Deprecated - use (gen/fmap inc gen/nat) instead (see also gen/large-integer). Generates positive integers bounded by ...

  • sample

    Return a sequence of `num-samples` (default 10) realized values from `generator`. The sequence starts with small va...

  • sample-seq

    Returns an infinite sequence of realized values from `generator`. Note that this function is a dev helper and is not ...

  • scale

    Creates a new generator that modifies the size parameter by the given function. Intended to support generators with si...

  • set

    Generates a set of elements from the given generator. If the generator cannot or is unlikely to produce enough distin...

  • shrink-2

    Creates a new generator like `gen`, but will consider nodes for shrinking even if their parent passes the test (up to ...

  • shuffle

    Creates a generator that generates random permutations of `coll`. Shrinks toward the original collection: `coll`. `col...

  • simple-type

    Generates a variety of scalar types.

  • simple-type-equatable

    Like gen/simple-type, but only generates objects that can be equal to other objects (e.g., not a NaN).

  • simple-type-printable

    Generates a variety of scalar types, with printable strings.

  • simple-type-printable-equatable

    Like gen/simple-type-printable, but only generates objects that can be equal to other objects (e.g., not a NaN).

  • size-bounded-bigint

    Generates an integer (long or bigint) bounded exclusively by ±2^(6*size).

  • sized

    Creates a generator that depends on the size parameter. `sized-gen` is a function that takes an integer and returns ...

  • small-integer

    Generates a positive or negative integer bounded by the generator's `size` parameter. Shrinks to zero.

  • sorted-set

    Generates a sorted set of elements from the given generator. If the generator cannot or is unlikely to produce enough...

  • string

    Generates strings. May generate unprintable characters.

  • string-alpha-numeric

    Deprecated - use string-alphanumeric instead. Generates alphanumeric strings.

  • string-alphanumeric

    Generates alphanumeric strings.

  • string-ascii

    Generates ascii strings.

  • such-that

    Creates a generator that generates values from `gen` that satisfy predicate `pred`. Care is needed to ensure there is ...

  • symbol

    Generates symbols without namespaces.

  • symbol-ns

    Generates symbols with namespaces.

T

  • tuple

    Creates a generator that returns a vector, whose elements are chosen from the generators in the same position. The ind...

U

  • uuid

    Generates a random type-4 UUID. Does not shrink.

V

  • vector

    Creates a generator of vectors whose elements are chosen from `generator`. The count of the vector will be bounded by ...

  • vector-distinct

    Generates a vector of elements from the given generator, with the guarantee that the elements will be distinct. If ...

  • vector-distinct-by

    Generates a vector of elements from the given generator, with the guarantee that (map key-fn the-vector) will be disti...