Open NoahTheDuke opened 1 year ago
I like your proposal! I agree that clojure.test/assert-expr
is magical indeed, and I can see that error message being helpful for those who do not understand how things work under the hood.
I also like it; definitely gives some context to the magic that happens via clojure.test/assert-expr
. :+1: for a PR with these changes
clojure.test/assert-expr
is clever but slightly magical, which makes it harder to work with: Where doesmatch?
come from? How does it work? Why aren't there any docstrings? Why does Clojure throw an "unable to resolve symbol: match?" error if I use this outside ofis
?My proposed solution (as seen in clojure-expectations.clojure-test) is to create dummy functions with descriptive docstrings and meaningful argument names that can be referred but will throw exceptions if used outside of
is
calls:This way, a user can write:
And they'll get a reasonable error message:
"match? must be used inside of `is`."
instead of the less helpful messageSyntax error compiling at (example/foo.clj). Unable to resolve symbol: match? in this context.
If this is reasonable, I'd be willing to open a PR with these changes.