Open Kwaq opened 8 years ago
The 2nd version will not generate an INEG instruction for pitest to mutate.
The final keyword enables the compiler to definitively infer the value i will have, so it can replace the code with the equivalent
public int containsINeg() {
return -1;
}
The mutator could be expanded to also negate the sign of any constants, but I'm not sure this would be a good idea.
I don't usually enable the existing constants mutator myself as it generates a lot of noise - this would suffer the same problem. If we were to negate constants it would be best implemented as a separate mutator that could be optionally enabled.
@hcoles Thanks for the explanation.
Is Invert Negatives Mutator supposed to work only on method params? It looks like it works on local variables, but only if they are not final. This works:
but this is not
Test case at my repo 501463d7ba6efe6aaea09ff7f98eac667eefd7ac