I just had a sinking realization today: I have been using assert inside
unittests to check for test results, but actually, this is wrong!
Why? Because when you compile with -release -unittest, all those asserts
disappear, and the unittests become useless. The correct way is to use
enforce instead of assert.
Unfortunately, Phobos unittests are full of asserts rather than enforce.
:-/
(And I contend that compiling with both -release and -unittest is a
valid scenario: it lets you catch bugs that only show up in the release
version, such as accidentally relying on side-effects in asserts, which
work when compiling without -release, but mysteriously fail during
-release. Failing unittests would allow you to catch such mistakes
before you ship it to the irate customer.)
T
--
Computerese Irregular Verb Conjugation: I have preferences. You have
biases. He/She has prejudices. -- Gene Wirchenko

Btw I think this might be an accident, in mars.c there's this
code:
if (global.params.release)
{ global.params.useInvariants = 0;
global.params.useIn = 0;
global.params.useOut = 0;
global.params.useAssert = 0; // <-- note
global.params.useArrayBounds = 1;
global.params.useSwitchError = 0;
}
However then it's followed by this code:
if (global.params.useUnitTests)
global.params.useAssert = 1;
So it's switched off and then on again. I can't tell if this was
deliberate or not. If it's on purpose it should be documented.