Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Macros

marick edited this page · 2 revisions
Clone this wiki locally

In some versions of Lisp, if was a macro that expanded into cond, something like this:

(defmacro my-if [test true-branch false-branch]
  `(cond ~test ~true-branch :else ~false-branch))

There are (at least!) two ways of testing such a macro. You can test that code that uses it behaves correctly. (Does it take the true branch when the test is true? The false branch otherwise?) You can also expand a form with the macro and check that the right expansion is produced. The =expands-to=> arrow helps you do that:

(fact
  (my-if (odd? 1) 1 2) =expands-to=> (clojure.core/cond (odd? 1) 1 :else 2))
Something went wrong with that request. Please try again.