Liking cljdoc? Tell your friends :D
Clojure only.

effective.core


expectcljmacro

(expect effect config)
(expect effect composition config)

Asserts modifications specified by config using the clojure.test API.

effect is a Clojure form representing the effect to test.

config is expected to be a collection of monitor configurations. Each of those to be a hashmap with the following keys:

keyrequired?description
:to-changeyesexpression to evaluate
:fromnoexpected value of :to-change
before the effect
:tonoexpected value of :to-change
after the effect
:bynoexpected numerical difference
of :to-change before and
after the effect

Examples:

(let [x (atom 10)]
  (expect (swap! x inc)
          [{:to-change @x
            :from 0
            :to 1}]))

The above expands to the following:

(let [x (atom 10)]
  (let [before-0 @x
        _ (swap! x inc)
        after-0 @x]
    (is (= 0 before-0) ":from check failed")
    (is (= 1 after-0) ":to check failed")))

(let [x (atom [:a :b :c])]
  (expect (swap! x pop)
          [{:to-change (count @x) :by -1}]))

The above expands to the following:

(let [x (atom [:a :b :c])]
  (let [before-0 (count @x)
        _ (swap! x pop)
        after-0 (count @x)]
    (is (= -1 (- after-0 before-0)) ":by check failed")))

(let [x (atom "ABC")]
  (expect (swap! x clojure.string/upper-case)
          :any
          [{:to-change (count @x) :from 3 :to 4}
           {:to-not-change @x}]))

The above expands to the following:

(let [x (atom "ABC")]
  (let [before-0 (count @x)
        before-1 @x
        _ (swap! x clojure.string/upper-case)
        after-0 (count @x)
        after-1 @x]
    (is (or (and (= 3 before-0)
                 (= 4 after-0))
            (= after-1 before-1)))))
Asserts modifications specified by `config` using the `clojure.test` API.

`effect` is a Clojure form representing the effect to test.

`config` is expected to be a collection of monitor configurations. Each of
those to be a hashmap with the following keys:

| key          | required? | description                    |
| ------------ | --------- | ------------------------------ |
| `:to-change` | **yes**   | expression to evaluate         |
| `:from`      | **no**    | expected value of `:to-change` |
|              |           | before the effect              |
| `:to`        | **no**    | expected value of `:to-change` |
|              |           | after the effect               |
| `:by`        | **no**    | expected numerical difference  |
|              |           | of `:to-change` before and     |
|              |           | after the effect               |

**Examples**:
``` clojure
(let [x (atom 10)]
  (expect (swap! x inc)
          [{:to-change @x
            :from 0
            :to 1}]))
```

The above expands to the following:

``` clojure
(let [x (atom 10)]
  (let [before-0 @x
        _ (swap! x inc)
        after-0 @x]
    (is (= 0 before-0) ":from check failed")
    (is (= 1 after-0) ":to check failed")))
```

---

``` clojure
(let [x (atom [:a :b :c])]
  (expect (swap! x pop)
          [{:to-change (count @x) :by -1}]))
```

The above expands to the following:

``` clojure
(let [x (atom [:a :b :c])]
  (let [before-0 (count @x)
        _ (swap! x pop)
        after-0 (count @x)]
    (is (= -1 (- after-0 before-0)) ":by check failed")))
```

---

``` clojure
(let [x (atom "ABC")]
  (expect (swap! x clojure.string/upper-case)
          :any
          [{:to-change (count @x) :from 3 :to 4}
           {:to-not-change @x}]))
```

The above expands to the following:

``` clojure
(let [x (atom "ABC")]
  (let [before-0 (count @x)
        before-1 @x
        _ (swap! x clojure.string/upper-case)
        after-0 (count @x)
        after-1 @x]
    (is (or (and (= 3 before-0)
                 (= 4 after-0))
            (= after-1 before-1)))))
```
raw docstring

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

× close