Is it a bug in unittest ?

ZombineDev via Digitalmars-d digitalmars-d at puremagic.com
Fri Sep 2 10:03:45 PDT 2016


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.


More information about the Digitalmars-d mailing list