[Issue 13291] unittest should be allowed inside template functions

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Dec 17 16:38:12 PST 2014


https://issues.dlang.org/show_bug.cgi?id=13291

Andrei Alexandrescu <andrei at erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #9 from Andrei Alexandrescu <andrei at erdani.com> ---
I just realized this can be realized with relative ease as follows:

void fun(T)(T arg)
{
   version(unittest)
   {
      ... testing ...
   }
   ... stuff ...
}

To avoid running unittests every time:

void fun(T)(T arg)
{
   version(unittest) for (static bool tested; !tested; tested = true)
   {
      ... testing stuff ...
   }
   ... stuff ...
}

--


More information about the Digitalmars-d-bugs mailing list