[ENH] Assertion
Stephan Rudlof
sr at evolgo.de
Fri May 12 23:44:55 UTC 2000
Stefan Matthias Aust wrote:
>
> Vassili,
>
> I don't really care whether
> [a > 0] assert.
> or
> self assert: [a > 0].
> is used. It's important to have that concept. I added a trivial changeset
> to my update-proposals to allow both ways. We can then simply could the
> occurrences of both alternatives and refactor towards to more often used
> alternative later.
>
> With your approach, Dave's idea to add an descriptive text might be easier:
> [a > 0] assertWith: 'illegal value for a'
> (I disliked the #assert:that: which has a negative assertion block)
Me too, I have possibly (don't know!) misinterpreted it in an earlier
mail...
> Although,
>
> self failIf: [a > 0]
> self failIf: [a > 0] with: 'illegal value for a'
>
> might be alternatives.
Much more better!
And the variants
self assert: [a < 0] failMessage: 'illegal value for a (should be < 0)'
and
self failIf: [a >= 0] failMessage: 'illegal value for a (should be <
0)'
.
I would prefer to state the positive condition, which has to be
fulfilled, though.
But: It's always possible to write
self assert: [(someCondition) not] failMessage: 'illegal value for
someCondition (should be false)'
, but it's difficult to read. In such a case I would also use the
>>failIf: variant.
Stephan
>
> I don't see the necessarity to enable or recompile and disable assertions
> (I already mentioned the Pragmatic Programmer's point of view (a must-have
> book)) so IMHO we should for now go without that feature. If others
> contradict, we should make your code an update.
>
> bye
--
Stephan Rudlof (sr at evolgo.de)
"Genius doesn't work on an assembly line basis.
You can't simply say, 'Today I will be brilliant.'"
-- Kirk, "The Ultimate Computer", stardate 4731.3
More information about the Squeak-dev
mailing list
|