Postmortem: Template unittests are bad & you shouldn't catch Error

Adam D. Ruppe destructionator at gmail.com
Thu Oct 22 19:34:45 UTC 2020


On Thursday, 22 October 2020 at 17:14:54 UTC, Mathias LANG wrote:
> Do you have a bugzilla entry for them by any chance ?

I don't...

> I don't agree with the sentiment that documented unittests are 
> a mistake though: they are a step up from documentation 
> examples, because you are at least guaranteed they compile and 
> pass in the right context.

That's pretty easy to do outside the language though: extracting 
code from the generated documentation is trivial and then you can 
run them through the compiler externally.

Of course that is an extra step so the unittest does have the 
advantage of being obvious and built in, but the official website 
could compile them as part of its existing auto test. And it can 
do it using the same live environment end users actually try, so 
same imports, same compiler version present on the "try it now" 
website, etc., for a more accurate test.


More information about the Digitalmars-d mailing list