wishlist: a version of assert-equality with a default argument
tpapp opened this issue · comments
It would be more convenient to write
(deftest foo (bar)
(assert-equality #'my-fancy-equality value1 expression1)
(assert-equality #'my-fancy-equality value2 expression2)
(assert-equality #'my-fancy-equality value3 expression3))
as something like
(deffixture bar (@body)
(let ((*assert-same-test* #'my-fancy-equality))
@body))
(deftest foo (bar)
(assert-same value1 expression1)
(assert-same value2 expression2)
(assert-same value3 expression3))
The wrapper could also be something like
(deffixture bar (@body)
(with-assert-same-test (#'my-fancy-equality)
@body))
Obviously the function/macro/variable names are just examples and it is very likely that you can come up with something better. This functionality is present in other libraries, eg lift:*lift-equality-test*
.
I will try and get to this by the end of the month. Been bogged down with other things.
I decided to go with the first method clunit:*clunit-equality-test*
. The update to the ASSERT-EQUALITY
macro is unfortunately not backwards compatible. See http://tgutu.github.com/clunit/api/clunit.xml#assert-equality
I have also marked the other ASSERT-EQ*
macros as depreciated in the API. I think going forward, ASSERT-EQUALITY
should suffice.
N.B. I have updated the documentation on how to use the test dependency option by adding an example http://tgutu.github.com/clunit/#clunit_12
Thanks for the change. But I would not insist on deprecating the other assert-eq...
forms: I like the fact that they don't use a global variable and thus they lead to very clear code when a CL equality operator suffices for testing. To tell the truth, I also liked assert-equality
in its previous form; it just got tedious when I was comparing many things with the same operator. But for a single use, wrapping it in a let
is even worse.
All in all I would prefer if you reverted this change, and optionally re-introduced the new assert-equality
under a different name (maybe assert-equality*
), making the old one available under its old name. This would also lead to a backward-compatible change.
Sorry for not communicating my suggestion more clearly.
As soon as you said that, it made so much more sense. Made the change immediately before anyone pulled I hope.