Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-cov does not account for inline conditionals #18889

Open
dlangBugzillaToGithub opened this issue Sep 23, 2014 · 1 comment
Open

-cov does not account for inline conditionals #18889

dlangBugzillaToGithub opened this issue Sep 23, 2014 · 1 comment

Comments

@dlangBugzillaToGithub
Copy link

Andrei Alexandrescu (@andralex) reported this on 2014-09-23T15:24:26Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=13524

CC List

  • yebblies

Description

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?
@dlangBugzillaToGithub
Copy link
Author

yebblies commented on 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant