I have function defined as:
I implemented it as
if (x < 0) return 0;
return x;
I have test testing that for x equals to 0 does return 0.
But mutant
if (x <= 0) return 0;
return x;
is surviving.
Any tips how to cover this mutant?
On the face of it this is a classic equivalent mutant. However, your if statement can be replaced with
return Math.max(0,x);
Which is an improvement as it expresses the intent of the logic at a glance, and does not create the mutation.
The Math.max implementation will be a variation of your original code. In that location there is no improvement that can be made, and the mutation there must be treated as equivalent (i.e. ignored).