Another idiom I wish were gone from phobos/druntime

via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 5 00:13:31 PST 2015


On Thursday, 5 February 2015 at 08:01:06 UTC, Jonathan M Davis 
wrote:
> the function exits, but in the vast majority of cases, what 
> you're testing
> with an out contract is what unit tests would be testing, in 
> which case, the
> out blocks don't really add anything, and since they're forced 
> to be
> general, you can't test for specific results like you can with 
> a unit test.

That would be true if:
- the unit test was doing exhaustive testing
- the unit test is fully specified
- the unit test is proven correct

But post conditions that are part of a specification can in 
theory be used for optimization when you link object files from 
different sources. So you can change the implementation of one 
object file with only linking as long as the specification itself 
does not change. Well, if you had a separate specification...


More information about the Digitalmars-d mailing list