Yes this namespace's name has five components.
Yes this namespace's name has five components.
(bounded-int low high)
DEPRECATED: see clojure.test.check.generators/large-integer*
Like clojure.test.check.generators/choose, but generates smallish numbers for small sizes.
Both bounds are inclusive.
DEPRECATED: see clojure.test.check.generators/large-integer* Like clojure.test.check.generators/choose, but generates smallish numbers for small sizes. Both bounds are inclusive.
(bounded-recursive-gen container-gen-fn scalar-gen max-breadth max-height)
Same as gen/recursive-gen but allows a bound on both breadth and height. Height = Number of levels of nesting. Eg: level of nesting = 0: [15 -4] level of nesting = 1: [[5 1 -3 -10 -18] [17]] Breadth = Number of elements in a level (number of elements in each vector, in the above eg).
Example 1: Breadth=2, Height=10 This means that no vector will contain more than 2 elements. and there will be at most 10 levels of nested vectors. (last (gen/sample (bounded-recursive-gen gen/vector gen/int 2 10) 20)) => [[[[[] []] [[[[[[[[-11 1] []]]] [[[[3 10] []]] []]] []] []] [[[[[[[16 10] []]] []] []] [[] []]] [[[[]]] []]]]] [[[[]] []]]]]
Example 2: Breadth=10, Height=2 (Opposite of ex 1) This means that no vector will contain more than 10 elements. and there will be atmost 2 levels of nested vectors. (last (gen/sample (bounded-recursive-gen gen/vector gen/int 10 2) 20)) => [[[11 5 3 8 15 -19 -12 -2] [7 3 -12 -11 0 -10 19 -19 -1] [16 -15 19 1]] [[6 -18 -14 -10 -7 -5 5] [7 10 -5] [-19 -5 3 -15 15 17 -18] [16 -15 10 -7] [14 3 5 9 -2 8 -7 11] [-5 17 -19 5 -9 7] [11 -1 -4 5] [-2 13 -16 -4] [-3 -12 -1] [4 15]]] There are atmost 2 nested levels, and no vector contains more than 10 elements.
Same as gen/recursive-gen but allows a bound on both breadth and height. Height = Number of levels of nesting. Eg: level of nesting = 0: [15 -4] level of nesting = 1: [[5 1 -3 -10 -18] [17]] Breadth = Number of elements in a level (number of elements in each vector, in the above eg). Example 1: Breadth=2, Height=10 This means that no vector will contain more than 2 elements. and there will be at most 10 levels of nested vectors. (last (gen/sample (bounded-recursive-gen gen/vector gen/int 2 10) 20)) => [[[[[] []] [[[[[[[[-11 1] []]]] [[[[3 10] []]] []]] []] []] [[[[[[[16 10] []]] []] []] [[] []]] [[[[]]] []]]]] [[[[]] []]]]] Example 2: Breadth=10, Height=2 (Opposite of ex 1) This means that no vector will contain more than 10 elements. and there will be atmost 2 levels of nested vectors. (last (gen/sample (bounded-recursive-gen gen/vector gen/int 10 2) 20)) => [[[11 5 3 8 15 -19 -12 -2] [7 3 -12 -11 0 -10 19 -19 -1] [16 -15 19 1]] [[6 -18 -14 -10 -7 -5 5] [7 10 -5] [-19 -5 3 -15 15 17 -18] [16 -15 10 -7] [14 3 5 9 -2 8 -7 11] [-5 17 -19 5 -9 7] [11 -1 -4 5] [-2 13 -16 -4] [-3 -12 -1] [4 15]]] There are atmost 2 nested levels, and no vector contains more than 10 elements.
(cap-size max-size gen)
Wraps the given generator so that it is never called with a size larger than the max given.
Wraps the given generator so that it is never called with a size larger than the max given.
(datetime)
(datetime {:keys [base-datetime offset-fns offset-min offset-max]
:or {offset-fns valid-offset-fns
offset-min -1000
offset-max 1000
base-datetime yr-2000}})
Generates datetime within given range and format.
base-datetime => By default it'll calculate the dates from year 2000. Generally this is a good idea instead of using (ct/now) since giving the same seed will generate the same output. If you would like to generate from a differnt base-datetime, Pass for example (ct/now) to use current time, Or pass a specific date-time (ct/date-time 2011 11 24)
offset-min & offset-max => The offset number range By default it is -1000 to 1000
offset-fns => List of functions which will be used with the given offset. It randomly picks one of the functions and applies the random offset with the given range. Check valid-offset-fns for possible values. By default its all the values of valid-offset-fns.
For example If you would like to generate datetime from last 10 months to next 10 months: (gen/sample (datetime {:offset-fns [clj-time.core/months] :offset-min -10 :offset-max 10})) => (nil nil nil ....)
Generates datetime within given range and format. base-datetime => By default it'll calculate the dates from year 2000. Generally this is a good idea instead of using (ct/now) since giving the same seed will generate the same output. If you would like to generate from a differnt base-datetime, Pass for example (ct/now) to use current time, Or pass a specific date-time (ct/date-time 2011 11 24) offset-min & offset-max => The offset number range By default it is -1000 to 1000 offset-fns => List of functions which will be used with the given offset. It randomly picks one of the functions and applies the random offset with the given range. Check valid-offset-fns for possible values. By default its all the values of valid-offset-fns. For example If you would like to generate datetime from last 10 months to next 10 months: (gen/sample (datetime {:offset-fns [clj-time.core/months] :offset-min -10 :offset-max 10})) => (nil nil nil ....)
DEPRECATED: see clojure.test.check.generators/double
Generates a Double, which can include Infinity and -Infinity but not NaN.
DEPRECATED: see clojure.test.check.generators/double Generates a Double, which can include Infinity and -Infinity but not NaN.
(for bindings expr)
Like clojure.core/for, but builds up a generator using bind, fmap, and such-that. The right half of each binding pair is a generator, and the left half is the value it's generating. The body of the for should be a generated value.
Both :let and :when are available as in clojure.core/for. Using :when will apply a filter to the previous generator via such-that.
An additional available clause is the :parallel clause, which is an alternative to tuple, for use when several generators are independent.
Like clojure.core/for, but builds up a generator using bind, fmap, and such-that. The right half of each binding pair is a generator, and the left half is the value it's generating. The body of the for should be a generated value. Both :let and :when are available as in clojure.core/for. Using :when will apply a filter to the previous generator via such-that. An additional available clause is the :parallel clause, which is an alternative to tuple, for use when several generators are independent.
(map->hash-map m)
Like test.check.generators/hash-map, but takes a single map argument instead of varargs.
Like test.check.generators/hash-map, but takes a single map argument instead of varargs.
(partition coll)
(partition coll avg-size)
Generates a collection of collection of the elements in coll, such that concatting them together gives the original collection. None of the subcollections will be empty.
Generates a collection of collection of the elements in coll, such that concatting them together gives the original collection. None of the subcollections will be empty.
(string-from-regex regex)
Given a regular expression, returns a generator that generates strings matching that regular expression.
As jvm regular expressions are quite complex, and certain features are quite challenging to implement as generators, this function does not support all of their features. However, it tries to at least accurately recognize features that it doesn't support and throw helpful exceptions if it is called with a regular expression using any of those features.
Given a regular expression, returns a generator that generates strings matching that regular expression. As jvm regular expressions are quite complex, and certain features are quite challenging to implement as generators, this function does not support all of their features. However, it tries to at least accurately recognize features that it doesn't support and throw helpful exceptions if it is called with a regular expression using any of those features.
(sub-map m)
Given a concrete map, randomly selects keys from it to create a subset of the given map. Note: the generated maps may be empty.
Example:
(gen/sample (sub-map {:a 1 :b 2 :c 3})) => ({} {:b 2} {:b 2, :c 3} {:a 1} ...)
Given a concrete map, randomly selects keys from it to create a subset of the given map. Note: the generated maps may be empty. Example: (gen/sample (sub-map {:a 1 :b 2 :c 3})) => ({} {:b 2} {:b 2, :c 3} {:a 1} ...)
(subsequence elements)
Given a collection, generates "subsequences" which are sequences of (not necessarily contiguous) elements from the original collection, in the same order. For collections of distinct elements this is effectively a subset generator, with an ordering guarantee.
Given a collection, generates "subsequences" which are sequences of (not necessarily contiguous) elements from the original collection, in the same order. For collections of distinct elements this is effectively a subset generator, with an ordering guarantee.
(subset elements)
Deprecated variant of subsequence that coerces the result to a set.
Deprecated variant of subsequence that coerces the result to a set.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close