[Haskell-cafe] order of assertEqual arguments is counterintuitive

Daneel Yaitskov dyaitskov at gmail.com
Tue Mar 1 17:56:02 UTC 2022

Hi List,

I noticed, that I pay more attention than I should, when working with
assertions, because I am not sure about argument order i.e. whether the
expected value goes first or vice-versa. Does anybody have similar thought?

Such subtle detail should be easy to grasp with regular practice, but I
observe difficulties and I suspect that there is a logical reason for that.

Unit tests appeared long time ago in Java and spread over all languages.
HUnit library inherited de facto standard assert function name and
signature. I don't know reasoning behind original signature.

I spell "assertEqual" expression as:  "Assert that x equals to y"
"y" sounds like a model value (i.e. expected value).

In assignments "x <- y" y is the model value, because it defines "x".
You get "x" - value on the left not on the right.

Similar issue with test fixing - I always have to check first, that an
expected value is actually one. There is no type safety preventing mixing
arguments. I had to open and comprehend a source file with test, because
test log is not 100% safe.


Best regards,
Daniil Iaitskov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20220301/06d866fc/attachment.html>

More information about the Haskell-Cafe mailing list