I am initializing a final int field in a constructor by inspecting a local scale
int value with respect to zero.
My code is of the form:
final int scale = calculateScale();
if (scale == 0) {
this.scale = 0;
} else if (scale > 0) {
this.scale = 1;
} else {
this.scale = -1;
}
I would expect this is a common pattern, since a Comparator also returns one of three values, -1, 0 or 1.
Pitest complains about the scale > 0
conditional, declaring the mutation scale >= 0
survives.
However, scale cannot be zero at that point, otherwise it would have entered the first conditional block.
In my opinion, pitest is testing an invalid mutation, and a quick dataflow analysis would reveal scale
cannot be zero.
I don't like to modify code to fool pitest, but how could this be expressed such that pitest doesn't complain?