summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Bedra <aaron@aaronbedra.com>2011-04-15 11:39:00 -0400
committerStuart Halloway <stu@thinkrelevance.com>2011-04-29 11:16:12 -0400
commitcd2c2e1f7206578e34efa7ac6579d7dd187f59e7 (patch)
tree987991d0f96092ee1fb5dd29c63ac3ab43980d40
parent34489bddcceb2c1102c30e6b3e417d981097453c (diff)
#CLJ-774 Assert can now accept an optional message string
Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
-rw-r--r--src/clj/clojure/core.clj14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj
index 6f41594e..1e6b8355 100644
--- a/src/clj/clojure/core.clj
+++ b/src/clj/clojure/core.clj
@@ -4178,12 +4178,16 @@
(defmacro assert
"Evaluates expr and throws an exception if it does not evaluate to
- logical true."
+ logical true."
{:added "1.0"}
- [x]
- (when *assert*
- `(when-not ~x
- (throw (new AssertionError (str "Assert failed: " (pr-str '~x)))))))
+ ([x]
+ (when *assert*
+ `(when-not ~x
+ (throw (new AssertionError (str "Assert failed: " (pr-str '~x)))))))
+ ([x message]
+ (when *assert*
+ `(when-not ~x
+ (throw (new AssertionError (str "Assert failed: " ~message " " (pr-str '~x))))))))
(defn test
"test [v] finds fn at key :test in var metadata and calls it,