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

Mariano Martinez Peck marianopeck at gmail.com
Sat Apr 30 16:20:06 CEST 2011

Hi guys. I always code my tests something like this:

    | universalAnswer |
    universalAnswer := 30.
    universalAnswer := universalAnswer + 11.
    self assert: universalAnswer equals: 42.

In this case, 42 is the "expected" and "universalAnswer" is the "actual"
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:
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".


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gforge.inria.fr/pipermail/pharo-project/attachments/20110430/b5eaa51a/attachment.htm>

More information about the Pharo-project mailing list