On Saturday, 3 September 2016 at 17:16:24 UTC, Jonathan M Davis
wrote:
On Saturday, September 03, 2016 16:56:08 ZombineDev via
Digitalmars-d wrote:
You can just enable the unittests for a single instance that
you
know for sure that it will be used. For example:
1)
https://github.com/dlang/phobos/blob/v2.071.2-b3/std/experimental/ndslice/sl
ice.d#L808
2)
https://github.com/dlang/phobos/blob/v2.071.2-b3/std/experimental/ndslice/sl ice.d#L947
So, in order to avoid having the unit tests compiled into the
code of anyone who uses your template, you have to create a
special version identifier that you use with your unit test
build and your documentation build, and then you version the
tests within the template with that version. And in order to
avoid having the unit test compiled into every instantiation of
that template during your test, you have to also put it in a
static if for a specific instantiation? Sure, that's feasible,
but that's getting _ugly_.
- Jonathan M Davis
I like and support your DIP about static unittests, I was just
pointing out that there are workarounds, mainly for people like
Manu, who need ways to get their job done now.
Personally, I think that putting a single `static if
(doUnittests)` before each unittest is not too much, considering
how flexible the doUnittests condition can be (e.g. check if ddoc
or unittest build, check template parameters, etc.).