diff options
author | Rich Hickey <richhickey@gmail.com> | 2008-02-08 21:01:21 +0000 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2008-02-08 21:01:21 +0000 |
commit | 16c725ff4d413909d1e5d02819ca23278c424fbb (patch) | |
tree | 82123193d37ca2552684b8de5aeee6c98adcd081 /src | |
parent | 87a669b00ec9368b392c908516f8f7bf7131e34e (diff) |
added prstr, assert, test
Diffstat (limited to 'src')
-rw-r--r-- | src/boot.clj | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/boot.clj b/src/boot.clj index d7b8f079..8f8d7ac7 100644 --- a/src/boot.clj +++ b/src/boot.clj @@ -1219,6 +1219,23 @@ (defmacro comment [& body]) +(defn prstr [x] + (binding [*out* (new java.io.StringWriter)] + (pr x) + (str *out*))) + +(defmacro assert [x] + `(when-not ~x + (throw (new Exception (strcat "Assert failed: " (prstr '~x)))))) + +(defn +#^{:doc "test [v] finds fn at key :test in var metadata and calls it, presuming failure will throw exception"} +test [v] + (let [f (:test ^v)] + (if f + (do (f) :ok) + :no-test))) + (comment (export '( load-file load |