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

Reply via email to