assert(condition[, message]) patch

Lars Ivar Igesund larsivar at igesund.net
Wed May 31 10:52:34 PDT 2006


Walter Bright wrote:

> braddr at puremagic.com wrote:
>> I have been toying with D to bring myself up to speed and I found myself
>> writing
>> a lot of unit tests, always a good thing.  In those unit tests I found
>> myself writing a lot of blocks like:
>> 
>> if (cond)
>> {
>> writefln("some debugging output to make my life easier");
>> assert(false);
>> }
>> 
>> I know many don't like unit tests to have output, but I do.
> 
> Why not:
> 
> assert(!cond); // some debugging output to make my life easier
> 
> ? You'll need to go look at the source anyway when the assert trips, so
> what advantage is there to print the comment?

Because not all the users will have access to the source, or be inclined to
see it. Unless the user get's a readable/understandable assert message
he/she might not get enough information to actually reproduce a test case
for the developer to peruse.

Walter, this is a no-brainer, please put it in.

-- 
Lars Ivar Igesund
blog at http://larsivi.net
DSource & #D: larsivi



More information about the Digitalmars-d mailing list