JoinColony / solcover

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

Unbracketed If consequents / alternates not getting statement or line coverage #26

Closed cgewecke closed 7 years ago

cgewecke commented 7 years ago
if (x ==1 ) throw;

gets covered as:

StatementCoverage('test.sol',1);
if (x == 1) {BranchCoverage('test.sol',1,0);throw;}else { BranchCoverage('test.sol',1,1);}

It should be the same as the bracketed version if(x==1){throw;}:

StatementCoverage('test.sol',1);
if (x == 1) {BranchCoverage('test.sol',1,0);  StatementCoverage('test.sol',2);
throw; }else { BranchCoverage('test.sol',1,1);}

Ditto

if (x == 1 )
  y = 2;

currently covered as:

StatementCoverage('test.sol',1);
if (x == 1) 
            {BranchCoverage('test.sol',1,0);throw;}else { BranchCoverage('test.sol',1,1);}

When the consequent is bracketed it gets statement and line coverage:

StatementCoverage('test.sol',1);
if (x == 1){BranchCoverage('test.sol',1,0); 
Coverage('test.sol',6);
             StatementCoverage('test.sol',2);
throw;
        }else { BranchCoverage('test.sol',1,1);}

Submitting a PR for this later today.