[squeak-dev] assert:equals: in Object

Levente Uzonyi leves at caesar.elte.hu
Fri Oct 9 23:03:59 UTC 2020


Hi Eliot,

On Fri, 9 Oct 2020, Eliot Miranda wrote:

> Hi All,
> 
>     moving code from a test into a workspace and back is painful because Object does not implement assert:equals: or assert:equals:description: even though it implements assert:description:.  So one has to edit out the
> equals: moving to the workspace and edit it back in again on the way back.  I'd like to suggest implementing Object>>assert:equals: and Object>>assert:equals:description: but I won't, because someone is bound to criticise it
> as being too green or ill considered or some other depressing BS.

In my opinion, it would be better to get rid of #assert:equals: and 
#assert:equals:description:. Many find the order of its arguments 
confusing, and they are only good to help tracking down what failed.
If #assert: could give information about it's argument: the source code
and probably the values of the variables in it, then #assert:equals: would 
simply become unnecessary.

For example

| x y |
x := 'foo'.
y := 1.
self assert: x = y.

would signal an exception with the message 'Assertion failed: x = y (x = 
''foo'', y = 1)' instead of just 'Assertion failed'.


Levente

> _,,,^..^,,,_
> best, Eliot
> 
>


More information about the Squeak-dev mailing list