We're updating the issue view to help you get more done. 

smarter assert (prints locals)

Description

Here is an implementation you can paste into a repl. Feedback wanted:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 (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)))))))))

Environment

None

Status

Assignee

Unassigned

Reporter

import

Labels

Approval

Vetted

Patch

Code

Fix versions

Priority

Major