Re: [java code coverage] Why isn't short-circuiting taken into account in branch count

19 views
Skip to first unread message

Marc R. Hoffmann

unread,
Mar 28, 2017, 12:23:28 PM3/28/17
to jac...@googlegroups.com
Hi,

the short circuit results in two separate branching points each
containing two branches, so 2+2=4.

You can rewrite the line as

if (0 <= i) if (i < 10)

This is how short circuits expressions get compiled and how JaCoCo sees it.

Regards,
-marc

On 28.03.17 05:04, cmb...@case.edu wrote:
> Hi,
>
> I have a condition that looks something like this:
> if(0 <= i && i < 10)
>
> The coverage report shows 1 of 4 branches missed. I can't expect JaCoCo to recognize the semantics of the condition which make it impossible to reach the fourth branch (i can't be both less than 0 and greater than 10), but why doesn't it just count 3 branches? Thanks to short-circuiting, if the first decision is false, it shouldn't matter what the second one is.
>
>
> Thanks,
> Cassidy
>


Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages