Bug 13524 – -cov does not account for inline conditionals

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-09-23T15:24:26Z
Last change time
2024-12-13T18:29:10Z
Assigned to
No Owner
Creator
Andrei Alexandrescu
Moved to GitHub: dmd#18889 →

Comments

Comment #0 by andrei — 2014-09-23T15:24:26Z
Executing code with -cov does not account for things like: auto x = condition ? fun() : gun(); If condition is always the same, one of the function calls isn't covered, and cov does not detect that. Writing the condition on 2-3 lines does work, but coverage analysis shouldn't require code reformatting. (Same goes about the arguably less frequent if (condition) fun(); else gun(); and other constructs that cram several statements on one line.) Thoughts on how we could fix that? One idea for output is to write "000:nnn" instead of the customary "0000000", where nnn is the column number (999 for overflow). Would this be doable?
Comment #1 by yebblies — 2014-11-04T09:52:52Z
(In reply to Andrei Alexandrescu from comment #0) > > If condition is always the same, one of the function calls isn't covered, > and cov does not detect that. Writing the condition on 2-3 lines does work, > but coverage analysis shouldn't require code reformatting. > It does require reformatting, because dmd's coverage is line-based. I would expect an expression-based coverage implementation to be much more complicated, both in output format and internal implementation.
Comment #2 by robert.schadek — 2024-12-13T18:29:10Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18889 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB