cljs.test/assert-predicate
(assert-predicate msg form)
Source docstring:
Returns generic assertion code for any functional predicate. The
'expected' argument to 'report' will contains the original form, the
'actual' argument will contain the form with all its sub-forms
evaluated. If the predicate returns false, the 'actual' form will
be wrapped in (not...).
(defn assert-predicate
[msg form]
(let [args (rest form)
pred (first form)
{:keys [file line end-line column end-column]} (meta form)]
`(let [values# (list ~@args)
result# (apply ~pred values#)]
(if result#
(report
{:type :pass, :message ~msg,
:file ~file :line ~line :end-line ~end-line :column ~column :end-column ~end-column
:expected '~form, :actual (cons '~pred values#)})
(report
{:type :fail, :message ~msg,
:file ~file :line ~line :end-line ~end-line :column ~column :end-column ~end-column
:expected '~form, :actual (list '~'not (cons '~pred values#))}))
result#)))