[Issue 12269] Unittest within template struct scope is not executed
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Feb 28 00:45:57 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12269
--- Comment #4 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2014-02-28 00:45:54 PST ---
(In reply to comment #3)
> IMO all unittests should be lifted to module scope by the compiler, excepting
> static-if and version() blocks. This way there would be no unittests that are
> missed because a template was not instantiated.
I don't think you're following me here, if you have:
struct S(T)
{
T val;
}
It doesn't matter where you put the unittest, it cannot possibly know what to
instantiate 'S' with. Here's an example of a unittest within a struct block
that could be both compilable and non-compilable based on what S is
instantiated with:
-----
struct S(T)
{
T val;
unittest
{
/// this will fail if 'T' is not int
static assert(is(T == int));
}
}
alias S_Int = S!int;
alias S_Float = S!float; // triggers compile-time failure
-----
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list