www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13454] New: Unit tests should be compiled in a module, where


          Issue ID: 13454
           Summary: Unit tests should be compiled in a module, where they
                    are declared
           Product: D
           Version: D1 & D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: performance
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: dfj1esp02 sneakemail.com

http://forum.dlang.org/post/luoc6f$2qcg$1 digitalmars.com
There's no way to disable unittests compiled as part of templates, instantiated
from another library.

template A(T)
  int a;
  unittest{ f(); }

version(unittest) void f(){}
If this module is compiled without unittests, `f` function will not be
compiled, then if another module is compiled with unittests and instantiates
the template, the template's unittest is compiled and it will link with `f`
function, which wasn't compiled, so linking will fail? There will be no way to
compile the importing module with unittests.

import core.stdc.stdio:puts;
template A(T)
    shared int a;
    unittest { puts("test"); }

int main()
    return 0;
The same test was executed twice (for each instance of a template). It's
questionable that duplicating tests for each instantiation of a template is

Sep 10 2014