On Saturday, 3 September 2016 at 03:36:06 UTC, Manu wrote:
This document: https://wiki.dlang.org/Contributing_to_Phobos
States: "Avoid unittest in templates (it will generate a new
unittest for each instance) - put your tests outside"
Sounds reasonable, but then I realised that most of my unit
tests are documenting unittests... this recommendation is in
conflict with the documentation standards... who wins?
For the rationale see e.g. this thread:
https://forum.dlang.org/post/wnydmelyxprvhsxew...@forum.dlang.org
A trick around this is sth. like:
version(D_Ddoc)
{
enum doUnittest = true;
}
else
{
version(unittest)
{
enum doUnittest = true;
}
else
{
enum doUnittest = false;
}
}
and then `static if (doUnittest)` the tests inside. For example
ndslice uses a similar pattern.