So far this only documents functions in the generators namespace.
(gen/sample g) — returns 10 smallish samples from g(gen/sample g n) — generates n samples from g(gen/generate g) — generates a single moderately sized value from g(gen/generate g size) — generates a value from g with the given
size (normally sizes range from 0 to 200)(gen/generator? g) — checks if g is a generator(gen/return x) — A constant generator that always generates xgen/boolean — generates booleans (true and false)gen/uuid — generates uniformly random UUIDs, does not shrink(gen/elements coll) — generates elements from coll (which must be non-empty)(gen/shuffle coll) — generates vectors with the elements of coll
in random ordersgen/any — generates any clojure valuegen/any-printable — generates any printable clojure valuegen/any-equatable — generates any clojure value that can be equal to anothergen/any-printable-equatable — generates any printable clojure value that can be equal to anothergen/simple-type — like gen/any but does not generate collectionsgen/simple-type-printable — like gen/any-printable but does notgen/simple-type-equatable — like gen/any-equatable but does not generate collectionsgen/simple-type-printable-equatable — like gen/any-printable-equatable but does not
generate collectionsgen/nat — generates small non-negative integers (useful for generating sizes of things)gen/small-integer — generates small integers, like gen/nat but also negativegen/large-integer — generates a large range of integers
(gen/large-integer* {:min x, :max y})gen/size-bounded-bigint — generates bigints, up to 2^(6*size)gen/double — generates a large range of doubles (w/ infinities & NaN)
(gen/double* {:min x, :max y, :infinite? true, :NaN? true})gen/ratio — generates ratios (sometimes integers) using gen/small-integergen/big-ratio — generates ratios (sometimes integers) using gen/size-bounded-bigintgen/byte — generates a Bytegen/choose — generates uniformly distributed integers between two (inclusive) valuesgen/char — generates charactersgen/char-ascii — generates printable ASCII charactersgen/char-alphanumeric — generates alphanumeric ASCII charactersgen/char-alpha — generates alphabetic ASCII charactersgen/string — generates a stringgen/string-ascii — generates a string using gen/char-asciigen/string-alphanumeric — generates a string using gen/char-alphanumericgen/keyword — generates keywordsgen/keyword-ns — generates namespaced keywordsgen/symbol — generates symbolsgen/symbol-ns — generates namespaced symbols(gen/tuple g1 g2 ...) — generates vectors [x1 x2 ...] where x1
is drawn from g1, x2 from g2, etc.(gen/hash-map k1 g1, k2 g2, ...) — generates maps {k1 v1, k2 v2, ...}
where v1 is drawn from g1, v2 from g2, etc.(gen/vector g) — generates vectors of elements from g
(gen/vector g num-elements)(gen/vector g min-elements max-elements)(gen/list g) — generates lists of elements from g(gen/set g) — generates sets of elements from g
(gen/set g {:num-elements x, :max-tries 20})(gen/set g {:min-elements x, :max-elements y, :max-tries 20})(gen/map key-gen val-gen) — generates a map with keys from key-gen
and vals from val-gen
gen/setu(gen/sorted-set g) — just like gen/set, but generates sorted-sets(gen/vector-distinct g) — same signature as gen/set, but generates
vectors of distinct elements(gen/list-distinct g) — same signature as gen/set, but generates
lists of distinct elements(gen/vector-distinct-by key-fn g) — generates vectors of elements
where (apply distinct? (map key-fn the-vector))
gen/set(gen/list-distinct-by key-fn g) — generates list of elements
where (apply distinct? (map key-fn the-list))
gen/setgen/bytes — generates a byte array(gen/let [x g] y) — macro, like clojure.core/let, where
the right-hand bindings are generators and the left-hand are
generated values; creates a generator
gen/fmap and gen/bind(gen/fmap f g) — creates a generator that generates (f x) for
x generated from g(gen/bind g f) — similar to gen/fmap, but where (f x) is itself
a generator and (gen/bind g f) generates values from (f x)(gen/such-that pred g) — returns a new generator that generates
only elements from g that match pred
(gen/such-that pred g max-tries)(gen/one-of [g1 g2 ...]) — generates elements from the given
generators, picking generators at random(gen/frequency [[2 g1] [7 g2] ...]) — generates elements from the
given generators, using the given weights to determine the
probability of picking any particular generator(gen/not-empty g) — given a generator that generates collections,
returns a modified generator that never generates empty collections(gen/recursive-gen container-gen scalar-gen) — generates a tree of
values, using container-gen (which is a function like gen/list
which takes and returns a generator) and scalar-gen (a generator
for the leaf values)(gen/resize n g) — creates a variant of g whose size parameter
is always n(gen/scale f g) — creates a variant of g whose size parameter
is (f size)(gen/no-shrink g) — creates a variant of g that does not shrinkCan you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |