A better assert() [was: Re: std.unittests [updated] for review]

bearophile bearophileHUGS at lycos.com
Fri Feb 4 04:10:37 PST 2011


Andrei:

> We need to have at least a definite decision by Feb 7 from Don and 
> Walter that work will be put or not into improving assert as discussed.

I think that fixing assert() is a better strategy, even it may require more work. A problem with assert is that it wants to do too many things, so there are problems:
- assert(0); to mean HALT, that gives some problems
- assert(class_instance); that calls its invariant. (I vaguely remember a problem with this with struct instance invariants).
- Not good enough for unittests, as seen in this thread.

So an effort to improve assert may solve all four those problems. Removing the two purposes (moving them to specialized and explicit features, specialized little tools) and adding the functionality we desire in unittesting.

Bye,
bearophile


More information about the Digitalmars-d mailing list