[dmd-internals] assert inside unittest sucks

Sean Kelly sean at invisibleduck.org
Sun Jun 27 21:22:31 PDT 2010


On Jun 27, 2010, at 8:32 PM, Andrei Alexandrescu wrote:

> Has anyone played with the new assert semantics? I find them a significant step down from before.
> 
> Consider:
> 
> int x;
> ...
> assert(x == 2, text(x));
> 
> I'm not seeing an actual message informing that an assertion has failed! In case it does fail the text is just printed and as such it is indistinguishable from regular debug chatter.
> 
> Walter, please revert the semantics of assert. This can't be worked with.
> 
> If you do want to improve things, please have assert abort the current unittest and continue to the next one. The current semantics is unbearable.

Yup, hate it.  I'd like each each unittest block to have its own entry in the ModuleInfo struct.  Then it would be a library issue to determine what granularity (or if) tests should be resumed.  If we really want a "report but don't throw" routine I'd prefer it be a library function named something like validate().  There's no reason to mess with the behavior of assert in this way.


More information about the dmd-internals mailing list