CrossClj

0.1.0 docs

SourceDocs



RECENT
    VARS
    ->RecordMatcher
    <
    <=
    =
    >
    >=
    all-of
    any-of
    assert-good-matcher
    char?
    coll?
    contains-in-order
    contains-in-order-matches
    contains-string
    decimal?
    describe-class-mismatch
    describe-list
    describe-mismatch-feature
    empty?
    ends-with
    equal-ignoring-case
    equal-ignoring-whitespace
    every?
    falsey?
    float?
    fn?
    format-message
    has-count
    has-count-that
    has-denominator
    has-entry
    has-entry-that
    has-key
    has-nth
    has-numerator
    has-val
    includes
    instance?
    is
    is-in?
    isa?
    keyword?
    list?
    make-record-matcher
    map->RecordMatcher
    map?
    Matcher
    nil?
    not
    on
    pp
    ratio?
    rational?
    re-matches
    run-match
    seq?
    set?
    some
    standard-describe-mismatch
    starts-with
    string?
    symbol?
    truthy?
    type-matcher
    vector?

    « Index of all namespaces of this project

    (->RecordMatcher match description describe-mismatch)
    Positional factory function for class matcha.RecordMatcher.
    
    (< a)
    matches based if the value given is greater-than or equal to
    
    (matcha/run-match (matcha/< 1) 2) ; => passes
    (matcha/run-match (matcha/< 1) 0) ; => fails
    (<= a)
    matches based if the value given is greater-than or equal to
    
    (matcha/run-match (matcha/<= 1) 1) ; => passes
    (matcha/run-match (matcha/<= 1) 0) ; => fails
    (= a)
    matches based on equality of the value given
    
    (matcha/run-match (matcha/= 1) 1) ; => passes
    (matcha/run-match (matcha/= 1) 2) ; => fails
    (> a)
    matches based if the value given is greater-than
    
    (matcha/run-match (matcha/> 1) 2) ; => passes
    (matcha/run-match (matcha/> 1) 0) ; => fails
    (>= a)
    matches based if the value given is less-than or equal to
    
    (matcha/run-match (matcha/<= 1) 1) ; => passes
    (matcha/run-match (matcha/<= 1) 0) ; => fails
    (all-of & ms)
    matches if all of the matchers given pass:
    
    (matcha/run-match (matcha/all-of (matcha/= 1) (matcha/= 1)) 1) ; => passes
    (matcha/run-match (matcha/all-of (matcha/= 1) (matcha/= 1)) 2) ; => fails
    (any-of & ms)
    passes if any of the given matchers pass:
    
    (matcha/run-match (matcha/any-of (matcha/= 1) (matcha/= 2)) 2) ; => passes
    (matcha/run-match (matcha/any-of (matcha/= 3) (matcha/= 2)) 1) ; => fails
    (assert-good-matcher {:keys [match description describe-mismatch], :as matcher})
    passes if the value is a char
    (matcha/run-match matcha/char? {}) ; => passes
    (matcha/run-match matcha/char? 1) ; => fails
    passes if the value is a collection
    
    (matcha/run-match matcha/coll? []) ; => passes
    (matcha/run-match matcha/coll? 5) ; => fails
    (contains-in-order & strings)
    passes if the string contains the strings in order
    
    (matcha/run-match (matcha/contains-in-order "a" "b") "ab") ; => passes
    (matcha/run-match (matcha/contains-in-order "a" "b") "ac") ; => fails
    (contains-in-order-matches given-string strings)
    (contains-string s)
    passes if the string includes the given string
    
    (matcha/run-match (matcha/contains-string "a") "a") ; => passes
    (matcha/run-match (matcha/contains-string "a") "b") ; => fails
    passes if the value is a decimal
    
    (matcha/run-match matcha/decimal? bigdec 1)) ; => passes
    (matcha/run-match matcha/decimal? 5) ; => fails
    (describe-class-mismatch x)
    (describe-list call xs)
    (describe-mismatch-feature x feature-name feature-mismatch)
    matches if the collection passed is empty
    
    (matcha/run-match matcha/empty? [1]) ; => passes
    (matcha/run-match matcha/empty? [])  ; => fails
    (ends-with s)
    passes if the string ends with the given string
    
    (matcha/run-match (matcha/ends-with "a") "ba") ; => passes
    (matcha/run-match (matcha/ends-with "a") "ab") ; => fails
    (equal-ignoring-case s)
    passes if the string is equal to the other string ignoring case
    
    (matcha/run-match (matcha/equal-ignoring-case "a") "A") ; => passes
    (matcha/run-match (matcha/equal-ignoring-case "a") "ab") ; => fails
    (equal-ignoring-whitespace s)
    passes if the string is equal to the other string ignoring whitespace
    
    (matcha/run-match (matcha/equal-ignoring-whitespace "a") "a ") ; => passes
    (matcha/run-match (matcha/equal-ignoring-whitespace "a ") "ab") ; => fails
    (every? m)
    passes if every element of the sequence received matches the matcher
    
    (matcha/run-match (matcha/every? (matcha/= 1)) [1]) ; => passes
    (matcha/run-match (matcha/every? (matcha/= 1)) [2]) ; => fails
    passes if the value is falsey
    
    (matcha/run-match matcha/falsey? #{}) ; => passes
    (matcha/run-match matcha/falsey? nil) ; => fails
    passes if the value is a float
    
    (matcha/run-match matcha/float? (float 1.0)) ; => passes
    (matcha/run-match matcha/float? 5) ; => fails
    passes if the value is a function
    
    (matcha/run-match matcha/fn? #()) ; => passes
    (matcha/run-match matcha/fn? 5) ; => fails
    (format-message result)
    turns the results of a failing match into a human readable error message,
    suitable for printing with clojure.core/print or clojure.core/println
    (has-count n)
    passes if the sequence received has the given count
    (matcha/run-match (matcha/has-count 1) [1]) ; => passes
    (matcha/run-match (matcha/has-count 2) [])  ; => fails
    (has-count-that m)
    passes if the sequence received has the given count
    (matcha/run-match (matcha/has-count-that (matcha/= 1)) [1]) ; => passes
    (matcha/run-match (matcha/has-count-that (matcha/= 1)) [])  ; => fails
    (has-denominator n)
    passes if the ratio has the denominator given
    (matcha/run-match (matcha/has-numerator 1) 1/10) ; => passes
    (matcha/run-match matcha/nil? 1) ; => fails
    (has-entry k v)
    passes if the map received has the given map-entry
    
    (matcha/run-match (matcha/has-entry :a 1) {:a 1}) ; => passes
    (matcha/run-match (matcha/has-entry :a 1) {:a 2})  ; => fails
    (has-entry-that k matcher)
    passes if the map received has a value at the key given that matches the matcher
    
    (matcha/run-match (matcha/has-entry-that :a (matcha/= 1)) {:a 1}) ; => passes
    (matcha/run-match (matcha/has-entry-that :a (matcha/= 2)) {:a 2})  ; => fails
    (has-key v)
    passes if the map received has the given key
    
    (matcha/run-match (matcha/has-key 1) {:a 1}) ; => passes
    (matcha/run-match (matcha/has-key 1) {:a 2})  ; => fails
    (has-nth m n)
    passes if the sequence received has the value matching the matcher given at
    (nth n)
    
    (matcha/run-match (matcha/has-count 1) [1]) ; => passes
    (matcha/run-match (matcha/has-count 2) [])  ; => fails
    (has-numerator n)
    passes if the ratio has the numerator given
    (matcha/run-match (matcha/has-numerator 1) 1/10) ; => passes
    (matcha/run-match matcha/nil? 1) ; => fails
    (has-val v)
    passes if the map received has the given val
    
    (matcha/run-match (matcha/has-val 1) {:a 1}) ; => passes
    (matcha/run-match (matcha/has-val 1) {:a 2})  ; => fails
    (includes x)
    passes if the sequence received includes the given item
    
    (matcha/run-match (matcha/includes 1) [1]) ; => passes
    (matcha/run-match (matcha/includes 1) [2]) ; => fails
    (instance? klazz)
    passes if the value matches the given class
    (matcha/run-match (matcha/instance? clojure.lang.Keyword) :foo) ; => passes
    (matcha/run-match (matcha/instance? clojure.lang.Keyword) 1) ; => fails
    macro
    (is matcher x)
    clojure.test integration
    
    runs a matcher against a given value, reporting failures via clojure.test
    (just like clojure.test/is)
    (is-in? xs)
    passes if the value is included in the given collection
    
    (matcha/run-match (matcha/is-in? [1]) 1) ; => passes
    (matcha/run-match (matcha/is-in? [5]) 1) ; => fails
    (isa? parent)
    passes if the value isa? the given object
    
    (matcha/run-match (matcha/isa? :parent) :child) ; => passes
    (matcha/run-match (matcha/isa? :child) :child) ; => fails
    passes if the value is a keyword
    (matcha/run-match matcha/keyword? :foo) ; => passes
    (matcha/run-match matcha/keyword? 1) ; => fails
    passes if the value is a list
    
    (matcha/run-match matcha/list? '()) ; => passes
    (matcha/run-match matcha/list? 5) ; => fails
    (make-record-matcher match description)(make-record-matcher match description describe-mismatch)
    (map->RecordMatcher m__7585__auto__)
    Factory function for class matcha.RecordMatcher, taking a map of keywords to field values.
    
    passes if the value is a map
    (matcha/run-match matcha/map? {}) ; => passes
    (matcha/run-match matcha/map? 1) ; => fails
    protocol
    (describe-mismatch this a)
    returns a human readable string of the mismatch of the matcher and the value given. It is an *error* to call describe-mismatch without checking match first, and you should expect unspecified behavior, exceptions, and so on.
    
    (description this)
    returns a human readable description of the matcher
    
    (match this a)
    returns a truthy value if the matcher matches the given value
    
    passes if the value is nil
    (matcha/run-match matcha/nil? nil) ; => passes
    (matcha/run-match matcha/nil? 1) ; => fails
    (not m)
    passes if the given matcher fails
    (matcha/run-match (matcha/not (matcha/= 1)) 1) ; => passes
    (matcha/run-match (matcha/not (matcha/= 2)) 1) ; => fails
    (on f m feature-name)(on f m feature-name class-name)
    combinator. Passes if the (f the-value) matches the matcher
    
    passes if the value is a ratio
    
    (matcha/run-match matcha/ratio? 1/5) ; => passes
    (matcha/run-match matcha/ratio? 5) ; => fails
    passes if the value is a rational
    
    (matcha/run-match matcha/rational? 1) ; => passes
    (matcha/run-match matcha/rational? "a") ; => fails
    (re-matches re)
    passes if the string matches the regex given
    
    (matcha/run-match (matcha/is-in? #"\d+") "1") ; => passes
    (matcha/run-match (matcha/is-in? #"\d+") "a") ; => fails
    (run-match matcher a)
    runs a matcher, given a value to match against.
    Returns a map:
    
    if the matcher matches the value:
    {:pass? true}
    
    if the matcher fails:
    {:pass? false
     :matcher matcher
     :expected (a string)
     :was (a string)}
    
    the results can be made human readable with (format-message result)
    passes if the value is a seq
    (matcha/run-match matcha/seq? {}) ; => passes
    (matcha/run-match matcha/seq? 1) ; => fails
    passes if the value is a set
    
    (matcha/run-match matcha/set? #{}) ; => passes
    (matcha/run-match matcha/set? 5) ; => fails
    (some m)
    passes if some elements of the sequence received matches the matcher
    
    (matcha/run-match (matcha/some? (matcha/= 1)) [1 2]) ; => passes
    (matcha/run-match (matcha/some? (matcha/= 1)) [2]) ; => fails
    (standard-describe-mismatch x)
    (starts-with s)
    passes if the string starts with the given string
    
    (matcha/run-match (matcha/starts-with "a") "ab") ; => passes
    (matcha/run-match (matcha/starts-with "a") "ba") ; => fails
    passes if the value is a string
    (matcha/run-match matcha/string? "foo") ; => passes
    (matcha/run-match matcha/string? 1) ; => fails
    passes if the value is a symbol
    (matcha/run-match matcha/symbol? 'foo) ; => passes
    (matcha/run-match matcha/symbol? 1) ; => fails
    passes if the value is truthy
    
    (matcha/run-match matcha/truthy? #{}) ; => passes
    (matcha/run-match matcha/truthy? nil) ; => fails
    (type-matcher pred type-name m)
    checks the value matches a predicate before matching
    using the matcher given.
    passes if the value is a vector
    (matcha/run-match matcha/vector? {}) ; => passes
    (matcha/run-match matcha/vector? 1) ; => fails