[ENH] Assertion

David N. Smith (IBM) dnsmith at watson.ibm.com
Fri May 26 18:50:14 UTC 2000


At 10:50 -0800 5/25/00, Lex Spoon wrote:
>Stephan Rudlof <sr at evolgo.de> wrote:
>> >     self failIf: [a > 0]
>> >     self failIf: [a > 0] with: 'illegal value for a'
>> >
>
>Adding an explanation is a great idea.  However, how about using a more
>meaningful word than a generic "with" or "that".  For instance:
>
>	self assert: [ x <= 0 ] explanation: 'x should be positive'
>
>-Lex

It's longer and harder to type, and thus someone is less likely to use an assertion in marginal cases, however I don't like #with: either.

I once used an Assert class with messages like:

	Assert that: 'x should be positive' when: [ x <= 0 ]

which suggests:

	self assertThat: 'x should be positive' when: [ x <= 0 ]

and as a shorthand:

	self assert: 'x should be positive' when: [ x <= 0 ]

Dave
_______________________________
David N. Smith
IBM T J Watson Research Center
Hawthorne, NY
_______________________________
Any opinions or recommendations
herein are those of the author  
and not of his employer.





More information about the Squeak-dev mailing list