[Pharo-project] I am the only one who finds #assert:equals: oppostite to expected?

Sean Allen sean at monkeysnatchbanana.com
Sat Apr 30 18:48:50 CEST 2011


You are not alone on this.

On Sat, Apr 30, 2011 at 10:20 AM, Mariano Martinez Peck <
marianopeck at gmail.com> wrote:

> Hi guys. I always code my tests something like this:
>
> testBlah
>     | universalAnswer |
>     universalAnswer := 30.
>     universalAnswer := universalAnswer + 11.
>     self assert: universalAnswer equals: 42.
>
> In this case, 42 is the "expected" and "universalAnswer" is the "actual"
> value.
> I feel weird writing like this:
>
>     self assert: 42 equals: universalAnswer.
>
> I don't know why...but I do..the same as when doing should: []  raise:
> Error.
> In that case you put the "actual" first and the "expected" at the end...
>
> ok....the "problem" is that assert:equals:  is in fact:   asserts: expected
> equals: actual  instead of
> asserts: actual equals: expected
>
> So, with my test I would receive a description in the debugger that says
> "'Expected 41 but was 42.'"
> which is completely the opposite. Of course, if I write my tests in the way
> I don't like, that is:
>  self assert: 42 equals: universalAnswer.
>
> then i got the correct message "'Expected 42 but was 41.'"
>
> I don't pretend pharo change this because I guess it is standard, and blah
> blah blah. But senders of #assert:equals: should both, some written as mine
> (so the message is incorrect for them) and some correct.
>
> In addition, I think it is a problem of the selector name. If we could make
> it clearer, the won't be necessary to confuse "actual" with "expected".
>
> Cheers
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gforge.inria.fr/pipermail/pharo-project/attachments/20110430/4e7e2539/attachment.htm>


More information about the Pharo-project mailing list