unittest blocks not being run inside of class and struct templates

NoBigDeal256 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jul 24 19:11:20 PDT 2017


For example this code:

class Test {
     unittest {
         assert(false);
     }
}

fails when ran with dmd test.d -unittest like you'd expect. But 
if I make it a class template:

class Test(T) {
     unittest {
         assert(false);
     }
}

it passes when it should fail because the unittest block is never 
executed. Why is this? While googling I found this thread 
http://forum.dlang.org/thread/Xns98A859B0CD274pchapinsovernet@63.105.9.61 but surely that bug hasn't gone unfixed for 11 years...


More information about the Digitalmars-d-learn mailing list