[squeak-dev] assert:equals: in Object

H. Hirzel hannes.hirzel at gmail.com
Fri Oct 23 13:47:42 UTC 2020


Hello

On 10/13/20, Thiede, Christoph
<Christoph.Thiede at student.hpi.uni-potsdam.de> wrote:
>> Then IMO we should follow suit.  For once I agree with them ;-)
>
> Nooo ... :( I don't know their reasons, but inverting a long-existing
> convention from one day to another seems like a true nightmare to me.

If I understand correctly Pharo has swapped
     assert:equals: in TestCase
to
     equals:assert: in TestCase

Is this so?

If yes then the impact for changes is actually quite small for Squeak.
It means that in addition to


assert: expected equals: actual

	^self
		assert: expected = actual
		description: [ self comparingStringBetween: expected and: actual ]


a method

equals: actual assert: expected

       ^assert: expected equals: actual

is also needed in Squeak.

> This would invalidate the semantics of every existing test case that was ever
> written for Squeak/Smalltalk.

Not the semantics which is the about the meaning. It is a minor syntax
change (= change of structure/ form): the order of arguments in one or
two methods.

So one or two methods more in Squeak fixes this.

> Plus, IMHO it is often useful to order parameters by their complexity
> ascending (e.g., put blocks last) to provide a good writeability/readability
> of a message's senders. While the expected argument often is a constant, the
> actual argument mainly is the result of a possibly complex operation, e.g.:
>
> self assert: 42 equals: (myComputer
>     doComplexComputationWith: 6
>     and: 7
>     mode: #multiplyInt).
>
> How would the opposite read like?
>
> self assert: (myComputer
>     doComplexComputationWith: 6
>     and: 7
>     mode: #multiplyInt) equals: 42.
>
> IMO, much less comprehensible.

I agree that the former

self assert: 42 equals: (myComputer
       doComplexComputationWith: 6
       and: 7
      mode: #multiplyInt).

is much more readable. This is what Squeak implements.

Best wishes
Hannes

> Best,
> Christoph
>
> ________________________________
> Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag
> von Eliot Miranda <eliot.miranda at gmail.com>
> Gesendet: Dienstag, 13. Oktober 2020 04:02:48
> An: The general-purpose Squeak developers list
> Betreff: Re: [squeak-dev] assert:equals: in Object
>
>
>
> On Mon, Oct 12, 2020 at 12:27 PM Jakob Reschke
> <forums.jakob at resfarm.de<mailto:forums.jakob at resfarm.de>> wrote:
> Eliot Miranda-2 wrote
>> - appealing to the SUnit community to reverse the order of arguments to
>> assert:equals:, plus a rewrite rule that reversed the obvious cases where
>> the first argument is a literal constant.
>
> For what it is worth, Pharo has just swapped the parameters... which makes
> all "portable" test cases awkward.
>
> Then IMO we should follow suit.  For once I agree with them ;-)
> --
> Sent from: http://forum.world.st/Squeak-Dev-f45488.html
>
>
>
> --
> _,,,^..^,,,_
> best, Eliot
>


More information about the Squeak-dev mailing list