|
8 | 8 | to clojure.test functionality.
|
9 | 9 |
|
10 | 10 | We do not support ClojureScript in clojure.test mode, sorry."
|
11 |
| - (:require [clojure.string :as str] |
| 11 | + (:require [clojure.data :as data] |
| 12 | + [clojure.string :as str] |
12 | 13 | [clojure.test :as t]))
|
13 | 14 |
|
| 15 | +(def humane-test-output? |
| 16 | + "If Humane Test Output is available, activate it, and enable compatibility |
| 17 | + of our =? with it." |
| 18 | + (try |
| 19 | + (require 'pjstadig.humane-test-output) |
| 20 | + ((resolve 'pjstadig.humane-test-output/activate!)) |
| 21 | + true |
| 22 | + (catch Throwable _))) |
| 23 | + |
14 | 24 | ;; stub functions for :refer compatibility:
|
15 | 25 | (defn- bad-usage [s]
|
16 | 26 | `(throw (IllegalArgumentException.
|
|
30 | 40 | (let [[_ e a] form]
|
31 | 41 | `(let [e# ~e
|
32 | 42 | a# ~a
|
33 |
| - r# (if (fn? e#) (e# a#) (= e# a#))] |
| 43 | + r# (if (fn? e#) (e# a#) (= e# a#)) |
| 44 | + humane?# (and humane-test-output? (not (fn? e#)))] |
34 | 45 | (if r#
|
35 | 46 | (t/do-report {:type :pass, :message ~msg,
|
36 | 47 | :expected '~form, :actual (if (fn? e#)
|
37 | 48 | (list '~e a#)
|
38 | 49 | a#)})
|
39 | 50 | (t/do-report {:type :fail, :message ~msg,
|
40 |
| - :expected '~form, :actual (if (fn? e#) |
41 |
| - (list '~'not (list '~e a#)) |
42 |
| - (list '~'not (list '~'=? e# a#)))})) |
| 51 | + :diffs (if humane?# |
| 52 | + [[a# (take 2 (data/diff e# a#))]] |
| 53 | + []) |
| 54 | + :expected (if humane?# e# '~form) |
| 55 | + :actual (cond (fn? e#) |
| 56 | + (list '~'not (list '~e a#)) |
| 57 | + humane?# |
| 58 | + [a#] |
| 59 | + :else |
| 60 | + (list '~'not (list '~'=? e# a#)))})) |
43 | 61 | r#)))
|
44 | 62 |
|
45 | 63 | (defmacro ?
|
|
0 commit comments