VARS

any

any-printable

bind

bind-helper

boolean

byte

bytes

call-gen

char

char-alpha-numeric

char-ascii

choose

collapse-rose

container-type

elements

exclude-nth

fmap

frequency

gen-bind

gen-fmap

gen-pure

halfs

hash-map

int

int-rose-tree

join-rose

keyword

list

make-gen

make-size-range-seq

make-stack

map

nat

neg-int

no-shrink

not-empty

one-of

pick

pos-int

rand-range

random

ratio

remove-roses

resize

return

rose-bind

rose-children

rose-filter

rose-fmap

rose-permutations

rose-pure

rose-root

rose-seq

s-neg-int

s-pos-int

sample

sample-seq

sequence

shrink-2

shrink-int

shrink-rose

simple-type

simple-type-printable

sized

sized-container

string

string-alpha-numeric

string-ascii

such-that

tuple

vector

zip-rose

any

any-printable

bind

bind-helper

boolean

byte

bytes

call-gen

char

char-alpha-numeric

char-ascii

choose

collapse-rose

container-type

elements

exclude-nth

fmap

frequency

gen-bind

gen-fmap

gen-pure

halfs

hash-map

int

int-rose-tree

join-rose

keyword

list

make-gen

make-size-range-seq

make-stack

map

nat

neg-int

no-shrink

not-empty

one-of

pick

pos-int

rand-range

random

ratio

remove-roses

resize

return

rose-bind

rose-children

rose-filter

rose-fmap

rose-permutations

rose-pure

rose-root

rose-seq

s-neg-int

s-pos-int

sample

sample-seq

sequence

shrink-2

shrink-int

shrink-rose

simple-type

simple-type-printable

sized

sized-container

string

string-alpha-numeric

string-ascii

such-that

tuple

vector

zip-rose

« Index of all namespaces of this project

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

`(bind generator k)`

Create a new generator that passes the result ofgeninto functionk.kshould return a new generator. This allows you to create new generators that depend on the value of other generators. For example, to create a generator which first generates a vector of integers, and then chooses a random element from that vector: (gen/bind (gen/such-that not-empty (gen/vector gen/int)) ;; this function takes a realized vector, ;; and then returns a new generator which ;; chooses a random element from it gen/elements)

`(choose lower upper)`

Create a generator that returns numbers in the rangemin-rangetomax-range, inclusive.

`(collapse-rose [root children])`

Return a new rose-tree whose depth-one children are the children from depth one _and_ two of the input tree.

`(elements coll)`

Create a generator that randomly chooses an element fromcoll. Examples: (gen/elements [:foo :bar :baz])

`(frequency pairs)`

Create a generator that chooses a generator frompairsbased on the provided likelihoods. The likelihood of a given generator being chosen is its likelihood divided by the sum of all likelihoods Examples: (gen/frequency [[5 gen/int] [3 (gen/vector gen/int)] [2 gen/boolean]])

`(hash-map & kvs)`

Like clojure.core/hash-map, except the values are generators. Returns a generator that makes maps with the supplied keys and values generated using the supplied generators. Examples: (gen/hash-map :a gen/boolean :b gen/nat)

Generates a positive or negative integer bounded by the generator'ssizeparameter. (Really returns a long)

`(join-rose [[inner-root inner-children] children])`

Turn a tree of trees into a single tree. Does this by concatenating children of the inner and outer trees.

`(map key-gen val-gen)`

Create a generator that generates maps, with keys chosen fromkey-genand values chosen fromval-gen.

`(no-shrink gen)`

Create a new generator that is just likegen, except does not shrink at all. This can be useful when shrinking is taking a long time or is not applicable to the domain.

Modifies a generator so that it doesn't generate empty collections. Examples: ;; generate a vector of booleans, but never the empty vector (gen/not-empty (gen/vector gen/boolean))

`(one-of generators)`

Create a generator that randomly chooses a value from the list of provided generators. Shrinks toward choosing an earlier generator, as well as shrinking the value generated by the chosen generator. Examples: (one-of [gen/int gen/boolean (gen/vector gen/int)])

Generates aclojure.lang.Ratio. Shrinks toward 0. Not all values generated will be ratios, as many values returned by/are not ratios.

`(return value)`

Create a generator that always returnsvalue, and never shrinks. You can think of this as theconstantlyof generators.

`(rose-bind m k)`

Takes a Rose tree (m) and a function (k) from values to Rose tree and returns a new Rose tree. This is the monadic bind (>>=) for Rose trees.

`(rose-filter pred [root children])`

Returns a new Rose tree whose values passpred. Values who do not passpredhave their children cut out as well. Takes a list of roses, not a rose

`(rose-permutations roses)`

Create a seq of vectors, where each rose in turn, has been replaced by its children.

`(rose-seq root)`

Create a lazy-seq of all of the (unique) nodes in a shrink-tree. This assumes that two nodes with the same value have the same children. While it's not common, it's possible to create trees that don't fit that description. This function is significantly faster than brute-force enumerating all of the nodes in a tree, as there will be many duplicates.

`(sample generator)`

`(sample generator num-samples)`

Return a sequence ofnum-samples(default 10) realized values fromgenerator.

`(sample-seq generator)`

`(sample-seq generator max-size)`

Return a sequence of realized values fromgenerator.

Private

`(sequence bind-fn return-fn ms)`

Haskell type: Monad m => [m a] -> m [a] Specfically used here to turn a list of generators into a generator of a list.

`(shrink-2 gen)`

Create a new generator likegen, but will consider nodes for shrinking even if their parent passes the test (up to one additional level).

`(sized sized-gen)`

Create a generator that depends on the size parameter.sized-genis a function that takes an integer and returns a generator.

`(such-that pred gen)`

Create a generator that generates values fromgenthat satisfy predicatef. Care is needed to ensure there is a high chancegenwill satisfyf, otherwise it will keep trying forever. Eventually we will add another generator combinator that only tries N times before giving up. In the Haskell version this is calledsuchThatMaybe. Examples: ;; generate non-empty vectors of integers (such-that not-empty (gen/vector gen/int))

`(tuple & generators)`

Create a generator that returns a vector, whose elements are chosen from the generators in the same position. The individual elements shrink according to their generator, but the value will never shrink in count. Examples: (def t (tuple gen/int gen/boolean)) (sample t) ;; => ([1 true] [2 true] [2 false] [1 false] [0 true] [-2 false] [-6 false] ;; => [3 true] [-4 false] [9 true]))