[Issue 12269] Unittest within template struct scope is not executed

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Feb 28 04:21:49 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12269



--- Comment #5 from growlercab at gmail.com 2014-02-28 04:21:45 PST ---
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
---
Yes, I understand this and I'd expect the compile failure. 

I don't think it is a good idea to conditionally compile/execute unittests
according to whether templates are instantiated, which is why I was saying they
should not be treated as regular functions that are subject to
template/struct/class scope.

Of course that may raise other issues I haven't thought of...I'm not a
compiler/language developer by any means :)

Anyway, thanks for taking the time to look into this issue. It is only a minor
problem due to my preferred unittest structure/workflow. I can work around it
easily enough.

Cheers,
ed

-- 
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