Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
March 14, 2013 -cov doesn't check templated code | ||||
---|---|---|---|---|
| ||||
Code coverage doesn't work with templates. Is this by design? t.d: module t; template t(T) { static if(is(T == int)) alias int t; else static if(is(T == short)) alias short t; } unittest { t!int a = 10; assert(a == 10); } void main() {} $ dmd -unittest -cov -run t t.lst: | module t; | template t(T) { | static if(is(T == int)) | alias int t; | else static if(is(T == short)) | alias short t; | } | unittest { 1| t!int a = 10; 1| assert(a == 10); | } | void main() {} t.d is 100% covered |
March 14, 2013 Re: -cov doesn't check templated code | ||||
---|---|---|---|---|
| ||||
Posted in reply to simendsjo | simendsjo:
> Code coverage doesn't work with templates. Is this by design?
A code coverage tells how many time a line of code is run at run-time. But your template contains no code that is run at run-time. So you are looking for a different kind of counter.
Bye,
bearophile
|
March 14, 2013 Re: -cov doesn't check templated code | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Thursday, 14 March 2013 at 16:09:01 UTC, bearophile wrote:
> simendsjo:
>
>> Code coverage doesn't work with templates. Is this by design?
>
> A code coverage tells how many time a line of code is run at run-time. But your template contains no code that is run at run-time. So you are looking for a different kind of counter.
Makes sense. Would be nice to easily see that the templates are being tested more properly though.
|
March 14, 2013 Re: -cov doesn't check templated code | ||||
---|---|---|---|---|
| ||||
Posted in reply to simendsjo | simendsjo:
> Would be nice to easily see that the templates are being tested more properly though.
Then add an enhancement request in bugzilla. Maybe there is a way to implement it.
I remember someone asking for a compiler switch that lists all the implemented templates...
Bye,
bearophile
|
March 14, 2013 Re: -cov doesn't check templated code | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Thursday, 14 March 2013 at 16:26:21 UTC, bearophile wrote: > simendsjo: > >> Would be nice to easily see that the templates are being tested more properly though. > > Then add an enhancement request in bugzilla. Maybe there is a way to implement it. > > I remember someone asking for a compiler switch that lists all the implemented templates... > > Bye, > bearophile Ok: http://d.puremagic.com/issues/show_bug.cgi?id=9721 |
Copyright © 1999-2021 by the D Language Foundation