Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defmacro are
- "Checks multiple assertions with a template expression.
- See clojure.template/do-template for an explanation of
- templates.
- Example: (are [x y] (= x y)
- 2 (+ 1 1)
- 4 (* 2 2))
- Expands to:
- (do (is (= 2 (+ 1 1)))
- (is (= 4 (* 2 2))))
- Note: This breaks some reporting features, such as line numbers."
- {:added "1.1"}
- [argv expr & args]
- (if (and
- ;; Catch no args, i.e., (are [a b] (= a b))
- (seq args)
- ;; Catch wrong number of args
- (zero? (mod (count args) (count argv))))
- `(temp/do-template ~argv (is ~expr) ~@args)
- (throw (IllegalArgumentException. "The number of args doesn't match are's argv."))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement