[Issue 19163] New: static/tuple foreach counted incorrectly in coverage analysis
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Aug 13 07:52:21 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=19163
Issue ID: 19163
Summary: static/tuple foreach counted incorrectly in coverage
analysis
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: simen.kjaras at gmail.com
import std.meta : AliasSeq;
unittest {
foreach (n; 0..7)
sw: switch (n) {
static foreach (i, e; AliasSeq!(int, string, bool))
case i:
break sw;
foreach (i, e; AliasSeq!(int, string, bool))
case i+3:
break sw;
default:
break;
}
static foreach (i, e; AliasSeq!(int, string, bool)) {
}
foreach (i, e; AliasSeq!(int, string, bool)) {
}
}
The above code gives this coverage analysis:
|import std.meta : AliasSeq;
|
|unittest {
24| foreach (n; 0..7)
7| sw: switch (n) {
0000000| static foreach (i, e; AliasSeq!(int, string, bool))
3| case i:
3| break sw;
0000000| foreach (i, e; AliasSeq!(int, string, bool))
3| case i+3:
3| break sw;
1| default:
1| break;
| }
6| static foreach (i, e; AliasSeq!(int, string, bool)) {
| }
6| foreach (i, e; AliasSeq!(int, string, bool)) {
| }
|}
Four things stand out here - the static foreach and tuple foreach inside the
switch has a coverage count of 0, and the foreach outside are counted. I
contend that both are incorrect - the lines contain no run-time executable
code, and so shouldn't show up in the coverage report at all.
--
More information about the Digitalmars-d-bugs
mailing list