[Haskell-cafe] order of assertEqual arguments is counterintuitive

Keith keith.wygant at gmail.com
Wed Mar 2 12:15:32 UTC 2022


Sounds like you want `@?=`, which is less confusingly spelled `shouldBe` in hspec.

-- Keith

Sent from my phone with K-9 Mail.

On 1 March 2022 17:56:02 UTC, Daneel Yaitskov <dyaitskov at gmail.com> wrote:
>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/20220302/d58aaf48/attachment.html>


More information about the Haskell-Cafe mailing list