Phobos Unittest

Johan j at j.nl
Sat Sep 4 11:43:13 UTC 2021


On Saturday, 4 September 2021 at 03:18:01 UTC, Paul Backus wrote:
> On Saturday, 4 September 2021 at 00:09:37 UTC, H. S. Teoh wrote:
>> This is related to the bogonity of the current behaviour of 
>> -unittest, which compiles *all* unittests of *all* imported 
>> modules, even when you're compiling user code that has no 
>> interest in Phobos unittests.
>
> Well, no; it compiles all unittests of all *compiled* modules, 
> not all *imported* modules. So it does not actually include 
> Phobos unittests.
>
> [...]
>
> As Steven Schveighoffer [pointed out][1], Phobos unittests are 
> never included in user code, regardless of whether 
> `StdUnittest` is used.

The "never" is false, https://d.godbolt.org/z/c4oeYM7rG

Unittests inside template code will be added to user code, unless 
the compiler has determined that the template is already 
instantiated in Phobos code (the "template culling" that the 
frontend does, whose behavior is not easily influenced by the 
programmer).

-Johan







More information about the Digitalmars-d-learn mailing list