I've come across this a few times, and for the life of me can't figure out any way to kill this. A quick sample (this is using classes from
vavr.io; the List is regular java.util.List though):
public static <T> Try<List<T>> flattenTry(final List<Try<T>> listOfTries) {
final Try<Seq<T>> zero = Try.success(Stream.empty());
final BiFunction<Try<Seq<T>>, Try<? extends T>, Try<Seq<T>>> f =
(result, future) -> result.flatMap(seq -> future.map(seq::append)); // this is the line with the problem.
return Iterator.ofAll(listOfTries).foldLeft(zero, f).map(Seq::toJavaList);
}
There are a total of 5 mutations created for the problem line; I have tests for it that are killing all of them except for the "removed call to java/lang/Object::getClass → SURVIVED".
I've happened across this a few times while working with lambdas - this is the only sample I can find that's generic enough I'm comfortable sharing it from work.
I'm using the gradle plugin, but have it configured to use pitest 1.2.2. I've got it configured to use the following mutators:
mutators = [
'CONDITIONALS_BOUNDARY',
'NEGATE_CONDITIONALS',
'INCREMENTS',
'INVERT_NEGS',
'MATH',
'RETURN_VALS',
'VOID_METHOD_CALLS',
'NON_VOID_METHOD_CALLS',
'REMOVE_CONDITIONALS'
]
I'm not a stickler for 100% coverage (of course, it'd be nice), but it would be nice to look at the report and know that what's red is something I can address. Any suggestions? Is there some way to test for a call to Object::getClass, or some way to avoid calls to it?
Thanks!