Is D's TimSort correct?
Ali Çehreli via Digitalmars-d
digitalmars-d at puremagic.com
Tue Feb 24 11:48:37 PST 2015
On 02/24/2015 11:15 AM, ketmar wrote:
> and it's interesting what complications templates can bring. testing
> templates is relatively hard now, 'cause programmer must ensure that
> every path is instantiated (i'm constantly hitting by the bugs in my
> templates due to missing some codepathes).
I was going to suggest dmd's code coverage tool but I've just witnessed
the problem first-hand: Uninstantiated template code is not visible to
the coverage analyser! :-o
Here is the program, where the code inside 'static if' is not covered
(because argument 'a' is char):
T foo(T)(T v)
{
static if (T.sizeof == 4) {
++v;
}
return v;
}
void main()
{
int a = foo('a');
}
$ dmd deneme.d -cov
$ ./deneme
$ tail --lines=14 deneme.lst
|T foo(T)(T v)
|{
| static if (T.sizeof == 4) {
| ++v;
| }
|
1| return v;
|}
|
|void main()
|{
1| int a = foo('a');
|}
deneme.d is 100% covered
Yay! 100% covered. WAT? :p
Ali
More information about the Digitalmars-d
mailing list