CrossClj

0.5.6 docs

SourceDocs



RECENT
    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

    « Index of all namespaces of this project

    A recursive generator that will generate many different, often nested, values
    
    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 of gen into function
    k. k should 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)
    
    
    Generates one of true or false. Shrinks to false.
    
    Generates java.lang.Bytes, using the full byte-range.
    
    Generates byte-arrays.
    
    (call-gen {generator-fn :gen} rnd size)
    Generates character from 0-255.
    
    Generate alpha-numeric characters.
    
    Generate only ascii character.
    
    (choose lower upper)
    Create a generator that returns numbers in the range
    min-range to max-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.
    (container-type inner-type)
    (elements coll)
    Create a generator that randomly chooses an element from coll.
    
    Examples:
    
        (gen/elements [:foo :bar :baz])
    
    Private
    (exclude-nth n coll)
    Exclude the nth value in a collection.
    
    (fmap f gen)
    (frequency pairs)
    Create a generator that chooses a generator from pairs based 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]])
    
    (gen-bind {h :gen} k)
    (gen-fmap k {h :gen})
    (gen-pure value)
    Private
    (halfs n)
    (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's
    size parameter.
    (Really returns a long)
    Private
    (int-rose-tree value)
    (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.
    Generate keywords.
    
    (list generator)
    Like vector, but generators lists.
    
    (make-gen generator-fn)
    (make-size-range-seq max-size)
    Private
    (make-stack children stack)
    (map key-gen val-gen)
    Create a generator that generates maps, with keys chosen from
    key-gen and values chosen from val-gen.
    Generates natural numbers, starting at zero. Shrinks to zero.
    
    Generate negative integers bounded by the generator's size parameter.
    
    (no-shrink gen)
    Create a new generator that is just like gen, 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)])
    
    
    Private
    (pick [h & tail] n)
    Generate positive integers bounded by the generator's size parameter.
    
    (rand-range rnd lower upper)
    (random)(random seed)
    Generates a clojure.lang.Ratio. Shrinks toward 0. Not all values generated
    will be ratios, as many values returned by / are not ratios.
    (remove-roses roses)
    (resize n {gen :gen})
    Create a new generator with size always bound to n.
    
    (return value)
    Create a generator that always returns value,
    and never shrinks. You can think of this as
    the constantly of 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-children [_root children])
    Returns the children of the root of the Rose tree.
    
    (rose-filter pred [root children])
    Returns a new Rose tree whose values pass pred. Values who
    do not pass pred have their children cut out as well.
    Takes a list of roses, not a rose
    (rose-fmap f [root children])
    Applies functions f to all values in the tree.
    
    (rose-permutations roses)
    Create a seq of vectors, where each rose in turn, has been replaced
    by its children.
    (rose-pure x)
    Puts a value x into a Rose tree, with no children.
    
    (rose-root [root _children])
    Returns the root of a Rose tree.
    
    (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.
    Generate strictly negative integers bounded by the generator's size
    parameter.
    Generate strictly positive integers bounded by the generator's size
    parameter.
    (sample generator)(sample generator num-samples)
    Return a sequence of num-samples (default 10)
    realized values from generator.
    (sample-seq generator)(sample-seq generator max-size)
    Return a sequence of realized values from generator.
    
    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 like gen, but will consider nodes for shrinking
    even if their parent passes the test (up to one additional level).
    Private
    (shrink-int integer)
    (shrink-rose f roses)
    (sized sized-gen)
    Create a generator that depends on the size parameter.
    sized-gen is a function that takes an integer and returns
    a generator.
    (sized-container inner-type)
    Generate strings. May generate unprintable characters.
    
    Generate alpha-numeric strings.
    
    Generate ascii strings.
    
    (such-that pred gen)
    Create a generator that generates values from gen that satisfy predicate
    f. Care is needed to ensure there is a high chance gen will satisfy f,
    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 called suchThatMaybe.
    
    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]))
    
    (vector generator)(vector generator num-elements)(vector generator min-elements max-elements)
    Create a generator whose elements are chosen from gen. The count of the
    vector will be bounded by the size generator parameter.
    (zip-rose f roses)
    Apply f to the sequence of Rose trees roses.