Liking cljdoc? Tell your friends :D

com.brunobonacci.rdt


containsclj

(contains expected)
(contains expected looseness)

Checks that the expected result is a subsequence of the actual result:

To succeed, f's result must be (1) contiguous and (2) in the same order as in the contains clause. Here are examples:

[3 4 5 700] => (contains [4 5 700]) ; true [4 700 5] => (contains [4 5 700]) ; false [4 5 'hi 700] => (contains [4 5 700]) ; false

The :in-any-order modifier loosens the second requirement:

['hi 700 5 4] => (contains [4 5 700] :in-any-order) ; true [4 5 'hi 700] => (contains [4 5 700] :in-any-order) ; false b/c 'hi is in middle

The :gaps-ok modifier loosens the first:

[4 5 'hi 700] => (contains [4 5 700] :gaps-ok) ; true [4 700 'hi' 5] => (contains [4 5 700] :gaps-ok) ; false b/c of bad order

The two modifiers can be used at the same time:

[4 700 5] => (contains [4 5 700] :gaps-ok :in-any-order) ; true [4 5 'hi 700] => (contains [4 5 700] :in-any-order :gaps-ok) ; true [700 'hi 4 5 'hi] => (contains [4 5 700] :in-any-order :gaps-ok) ; true

Another way to indicate :in-any-order is to describe what's contained by a set. The following two are equivalent:

[700 4 5] => (contains [4 5 700] :in-any-order) [700 4 5] => (contains #{4 5 700})

:gaps-ok can be used with a set. (So can :in-any-order, but it has no effect.)

Checks that the expected result is a subsequence of the actual result:

To succeed, f's result must be (1) contiguous and (2) in the
same order as in the contains clause. Here are examples:

   [3 4 5 700]   => (contains [4 5 700]) ; true
   [4 700 5]     => (contains [4 5 700]) ; false
   [4 5 'hi 700] => (contains [4 5 700]) ; false

The :in-any-order modifier loosens the second requirement:

   ['hi 700 5 4] => (contains [4 5 700] :in-any-order) ; true
   [4 5 'hi 700] => (contains [4 5 700] :in-any-order) ; false b/c 'hi is in middle

The :gaps-ok modifier loosens the first:

   [4 5 'hi 700]  => (contains [4 5 700] :gaps-ok) ; true
   [4 700 'hi' 5] => (contains [4 5 700] :gaps-ok) ; false b/c of bad order

The two modifiers can be used at the same time:

   [4 700 5]         => (contains [4 5 700] :gaps-ok :in-any-order) ; true
   [4 5 'hi 700]     => (contains [4 5 700] :in-any-order :gaps-ok) ; true
   [700 'hi 4 5 'hi] => (contains [4 5 700] :in-any-order :gaps-ok) ; true

Another way to indicate :in-any-order is to describe
what's contained by a set. The following two are equivalent:

   [700 4 5] => (contains [4 5 700] :in-any-order)
   [700 4 5] => (contains #{4 5 700})

:gaps-ok can be used with a set. (So can :in-any-order, but it has no effect.)
sourceraw docstring

fuzzy-checkerclj

(fuzzy-checker expected)

A checker for the right-hand-side of the arrow which only checks the keys and items in the pattern and accepts additional keys without failing. See README.md for more info.

A checker for the right-hand-side of the arrow which only checks the keys and items
in the pattern and accepts additional keys without failing.
See README.md for more info.
sourceraw docstring

justclj

(just expected)
(just expected looseness)

A variant of contains, just, will fail if the left-hand-side contains any extra values: [1 2 3] => (just [1 2 3]) ; true [1 2 3] => (just [1 2 3 4]) ; false

The first of those seems senseless, since you could just use this:

[1 2 3] => [1 2 3]

However, it's required if you want to use checkers in the expected result:

[1 2 3] => [odd? even? odd?] ; false b/c 2nd-level fns aren't normally treated as checkers. [1 2 3] => (just [odd? even? odd?]) ; true

just is also useful if you don't care about order:

[1 3 2] => (just [1 2 3] :in-any-order) [1 3 2] => (just #{1 2 3})

A variant of contains, just, will fail if the
left-hand-side contains any extra values:
   [1 2 3] => (just [1 2 3])  ; true
   [1 2 3] => (just [1 2 3 4]) ; false

The first of those seems senseless, since you could just use this:

   [1 2 3] => [1 2 3]

However, it's required if you want to use checkers in the expected result:

   [1 2 3] => [odd? even? odd?]  ; false b/c 2nd-level fns aren't normally treated as checkers.
   [1 2 3] => (just [odd? even? odd?]) ; true

just is also useful if you don't care about order:

  [1 3 2] => (just   [1 2 3] :in-any-order)
  [1 3 2] => (just  #{1 2 3})
sourceraw docstring

repl-testcljmacro

(repl-test & [doc & facts :as body])

A top level macro to wrap your test assertions.

Example:

(repl-test "testing addition"
  (reduce + (range 1000)) => 499500)
A top level macro to wrap your test assertions.

Example:

``` clojure
(repl-test "testing addition"
  (reduce + (range 1000)) => 499500)
```
sourceraw docstring

throwsclj

(throws & desiderata)

Checks for a thrown Throwable.

The most common cases are: (fact (foo) => (throws IOException) (fact (foo) => (throws IOException #"No such file")

throws takes three kinds of arguments:

  • A class argument requires that the Throwable be of that class.
  • A string or regular expression requires that the message of the Throwable match the argument.
  • A function argument requires that the function, when applied to the Throwable, return a truthy value.

Arguments can be in any order. Except for a class argument, they can be repeated. So, for example, you can write this: (fact (foo) => (throws #"one part" #"another part"))

Checks for a thrown Throwable.

The most common cases are:
    (fact (foo) => (throws IOException)
    (fact (foo) => (throws IOException #"No such file")

`throws` takes three kinds of arguments:
* A class argument requires that the Throwable be of that class.
* A string or regular expression requires that the `message` of the Throwable
  match the argument.
* A function argument requires that the function, when applied to the Throwable,
  return a truthy value.

Arguments can be in any order. Except for a class argument, they can be repeated.
So, for example, you can write this:
    (fact (foo) => (throws #"one part" #"another part"))
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close