JoinColony / solcover

Code coverage for solidity
MIT License
64 stars 8 forks source link

"Same line" statements belonging to loop bodies are not reported. #37

Closed cgewecke closed 7 years ago

cgewecke commented 7 years ago

Istanbul reports a JS statement like this as follows

for(var x = 0; x < 10; x++){ y += 1; }

forloop

The solcover report: forloopsol

The instrumentation looks like this:

Coverage('/Users/user/Sites/sol-coveralls/solcover/test.sol',5);
         StatementCoverage('/Users/user/Sites/sol-coveralls/solcover/test.sol',1);
for(var x = 0; x < 10; x++){  StatementCoverage('/Users/user/Sites/sol-coveralls/solcover/test.sol',2);
y+=1; }
    }

If the statement in the body of the ForStatement is on its own line, the reporting is correct. Do these same line statements needs their own Coverage(etc) event?

area commented 7 years ago

I guess this is a philosophical difference more than anything. It is interesting that the istanbul instrumentation shows it being run 10 times though - the natural fix for this would lead to it being marked as run 11 times.

I like the idea of taking Istanbul as the source of 'truth' for what our instrumentation should be doing, but I suspect getting that line being marked as run ten times will prove tricky.

cgewecke commented 7 years ago

Right. I'm going to close. No one writes a loop like this anyway.