summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2008-02-08 21:01:21 +0000
committerRich Hickey <richhickey@gmail.com>2008-02-08 21:01:21 +0000
commit16c725ff4d413909d1e5d02819ca23278c424fbb (patch)
tree82123193d37ca2552684b8de5aeee6c98adcd081 /src
parent87a669b00ec9368b392c908516f8f7bf7131e34e (diff)
added prstr, assert, test
Diffstat (limited to 'src')
-rw-r--r--src/boot.clj17
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