assert

macrosince v0.0-927 clojure.core/assertEdit
(assert x)
(assert x message)

(assert x) - throw exception if x is false
(assert x message) - include message if assertion fails

Returns nil.


Examples:

(assert true)
;;=> nil

(assert false)
;;=> Uncaught Error: Assert failed: false

(assert (= 1 2) "1 is not 2")
;;=> Uncaught Error: Assert failed: 1 is not 2
;;   (= 1 2)

Source docstring:
Evaluates expr and throws an exception if it does not evaluate to
logical true.
Source code @ clojurescript:src/main/clojure/cljs/core.cljc
(core/defmacro assert
  ([x]
     (core/when *assert*
       `(when-not ~x
          (throw (js/Error. ~(core/str "Assert failed: " (core/pr-str x)))))))
  ([x message]
     (core/when *assert*
       `(when-not ~x
          (throw (js/Error.
                  (cljs.core/str "Assert failed: " ~message "\n" ~(core/pr-str x))))))))