[Issue 13454] New: Unit tests should be compiled in a module, where they are declared
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Sep 10 04:05:19 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13454
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 at puremagic.com
Reporter: dfj1esp02 at 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.
Error:
---
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.
Performance:
---
import core.stdc.stdio:puts;
template A(T)
{
shared int a;
unittest { puts("test"); }
}
int main()
{
A!(int).a=0;
A!(long).a=0;
return 0;
}
---
test
test
---
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
intended.
--
More information about the Digitalmars-d-bugs
mailing list