You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So it seems our implementation for the instrumentation of ternary statements was unsupported all along, so that's not going to be supported again like I hoped it was going to...
I think, unfortunately, this leaves us with replacing ternary statements with 'full' if/then/else statements as the only option if we want this branch coverage back...
The text was updated successfully, but these errors were encountered:
This could be possible in the new design using a strategy similar to the one proposed for #175here.
0.7.0 instruments as shown below. Line/branch hits are tracked by inspecting the vm stack at each opcode step and picking out hashes we've passed to an injected "coverage" function:
contractTest {
function coverage_0xab123(bytes32c__0xab123) publicpure {}
function a(uintx) public {
coverage_0xab123(0xa9065...549e2); /* line */if (x ==1) {
coverage_0xab123(0x85e7e...afacf); /* branch */coverage_0xab123(0xfa262...4fb28); /* line */
x =3;
} else {
coverage_0xab123(0xb54c1...3ef6b); /* branch */
}
}
If we modify this approach and define two coverage functions which return true/false bool respectively...
function covFn_True(bytes32hash) publicpurereturns (bool) {
returntrue;
}
function covFn_False(bytes32hash) publicpurereturns (bool) {}
We should be able to detect ternary branches by injecting like this:
a ? b : c;
// Transformed to:
( covFn_True(h) && a ||covFn_False(h) ) ? b : c;
If a == true, the true branch gets marked (and executes).
if a == false, the false branch gets marked (but does not execute).
I think this is correct but the injection logic itself might be tricky to get right with complex conditions.
So it seems our implementation for the instrumentation of ternary statements was unsupported all along, so that's not going to be supported again like I hoped it was going to...
I think, unfortunately, this leaves us with replacing ternary statements with 'full' if/then/else statements as the only option if we want this branch coverage back...
The text was updated successfully, but these errors were encountered: