Details
-
Type:
Enhancement
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: Approved Backlog
-
Component/s: None
-
Labels:None
-
Approval:Incomplete
Description
Here is an implementation you can paste into a repl. Feedback wanted:
(defn ^{:private true} local-bindings
"Produces a map of the names of local bindings to their values."
[env]
(let [symbols (map key env)]
(zipmap (map (fn [sym] `(quote ~sym)) symbols) symbols)))
(defmacro assert
"Evaluates expr and throws an exception if it does not evaluate to
logical true."
{:added "1.0"}
[x]
(when *assert*
(let [bindings (local-bindings &env)]
`(when-not ~x
(let [sep# (System/getProperty "line.separator")]
(throw (AssertionError. (apply str "Assert failed: " (pr-str '~x) sep#
(map (fn [[k# v#]] (str "\t" k# " : " v# sep#)) ~bindings)))))))))
Attachments
Activity
Aaron Bedra
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Assignee | Stuart Halloway [ stu ] | |
| Reporter | Assembla Importer [ importer ] | |
| Priority | Major [ 3 ] |
Stuart Halloway
made changes -
| Approval | Incomplete | |
| Waiting On | stu |
Stuart Halloway
made changes -
| Assignee | Stuart Halloway [ stu ] | |
| Waiting On | stu | richhickey |
Christopher Redinger
made changes -
| Fix Version/s | Approved Backlog [ 10034 ] | |
| Fix Version/s | Release.Next [ 10038 ] |
Andy Fingerhut
made changes -
| Attachment | clj-415-assert-prints-locals-v1.txt [ 11684 ] |
Converted from http://www.assembla.com/spaces/clojure/tickets/415