On Thursday, 1 September 2016 at 18:11:55 UTC, angel wrote:
If one creates a unittest block in a templated class (or struct), the unittest block will be multiplied per class specialization, which might turn out to be quite large number.

E.g.
 struct A(T) {
     ...
     unittest {
         ...
     }
 }

 ...

 auto a = A!int;
 auto b = A!int;
 auto c = A!double;

The unittest block will be instantiated twice (per A!int and A!double). But in some (many ?) cases unittest doesn't even exercise the generics, merely using some particular type.

What is it, a bug ?

Not a bug. Everything inside a template get copied for each template instantiation. It would strange if there were exceptions. That doesn't mean that it is an intentional feature. See http://wiki.dlang.org/DIP82.

Reply via email to