macro | removed v1.9.542 | added v1.9.216 | Edit |
(assert spec x)
spec-checking assert expression. Returns x if x is valid? according to spec, else throws an error with explain-data plus ::failure of :assertion-failed. Can be disabled at either compile time or runtime: If *compile-asserts* is false at compile time, compiles to x. Defaults to the negation value of the ':elide-asserts' compiler option, or true if not set. If (check-asserts?) is false at runtime, always returns x. Defaults to value of 'cljs.spec/*runtime-asserts*', or false if not set. You can toggle check-asserts? with (check-asserts bool).
(defmacro assert
[spec x]
`(if *compile-asserts*
(if *runtime-asserts*
(assert* ~spec ~x)
~x)
~x))