[Issue 15327] New: -cov should not mark `assert(0)` (and ideally paths leading unconditionally to it) as uncovered

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Nov 13 05:28:57 PST 2015


https://issues.dlang.org/show_bug.cgi?id=15327

          Issue ID: 15327
           Summary: -cov should not mark `assert(0)` (and ideally paths
                    leading unconditionally to it) as uncovered
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: andrei at erdani.com

`assert(0)` is almost always used as a "waveguide terminator" to mark paths
that, if ever reached, mean there's a bug in the code. Consequently, the
`assert(0)` lines and all paths leading to them cannot and should not ever be
covered.

Currently such lines are marked with 0000000 and gratuitously degrade the
coverage ratio of legitimate code.

A simple fix would be to not mark `assert(0)` lines as uncovered (also
`assert(false)` etc). That would be enough to close this issue. A more
sophisticated approach would also do the same with code leading up to the
`assert(0)`.

--


More information about the Digitalmars-d-bugs mailing list