phobos unit tests

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Sat Sep 3 08:58:51 PDT 2016


On Saturday, September 03, 2016 07:48:14 H. S. Teoh via Digitalmars-d wrote:
> > In any case, for now, I never put non-generic unit tests in templates,
> > and I reject PRs that have them. Sure, having to copy-paste your
> > examples sucks, but it doesn't affect the code of everyone who uses
> > the template, whereas ddoc-ed unit tests do.
>
> [...]
>
> Actually you don't need to copy-paste your examples, which IMO is a bad
> idea to begin with. Just version out the non-generic unittests when
> compiling user code, and you can have the best of both worlds.

And you still have the problem that all of those unit tests will be compiled
into every instantiation of the template that's part of your unittest build.
So, you end up with longer build times and longer run times for your unit
tests. I agree that copy-pasting sucks, but it's what we had to do before
with had ddoc-ed unit tests, and I still think that it's better than
resulting in all of the additional copies of the tests being compiled in and
run - especially if the project isn't small.

- Jonathan M Davis



More information about the Digitalmars-d mailing list