@Override boolean couldCauseInfiniteLoop(MethodTree method, MutationDetails each) { final AbstractInsnNode instruction = method.instruction(each.getInstructionIndex()); return instruction.getOpcode() == Opcodes.IINC; }
@Override boolean couldCauseInfiniteLoop(MethodTree method, MutationDetails each) { final AbstractInsnNode instruction = method.instruction(each.getInstructionIndex()); return isIteratorNext(instruction); }
@Override public boolean test(MutationDetails a) { if (!MUTATOR_ID.equals(a.getMutator())) { return false; } final MethodTree method = NullReturnsFilter.this.currentClass.methods().stream() .filter(MethodMatchers.forLocation(a.getId().getLocation())) .findFirst() .get(); final int mutatedInstruction = a.getInstructionIndex(); return returnsNull(method, mutatedInstruction); }
private Predicate<MutationDetails> isEquivalent(Mutater m) { return a -> { if (!MUTATOR_IDS.contains(a.getMutator())) { return false; } final MethodTree method = PrimitiveEquivalentFilter.this.currentClass.methods().stream() .filter(MethodMatchers.forLocation(a.getId().getLocation())) .findFirst() .get(); return ZERO_CONSTANTS.contains(method.realInstructionBefore(a.getInstructionIndex()).getOpcode()); }; }
@Override public boolean test(MutationDetails a) { if (!MUTATOR_IDS.contains(a.getMutator())) { return false; } final int instruction = a.getInstructionIndex(); final MethodTree method = HardCodedTrueEquivalentFilter.this.currentClass.methods().stream() .filter(MethodMatchers.forLocation(a.getId().getLocation())) .findFirst().get(); return primitiveTrue(instruction, method) || boxedTrue(instruction, method); }
private Boolean shortCutEquals(MethodTree tree, MutationDetails a, Mutater m) { if (!mutatesAConditionalJump(tree, a.getInstructionIndex())) { return false; } final ClassTree mutant = ClassTree.fromBytes(m.getMutation(a.getId()).getBytes()); final MethodTree mutantEquals = mutant.methods().stream() .filter(MethodMatchers.forLocation(tree.asLocation())) .findFirst() .get(); return ALWAYS_FALSE.matches(mutantEquals.instructions()); }
private Predicate<MutationDetails> mutatesAForLoopCounter() { return a -> { final int instruction = a.getInstructionIndex(); final MethodTree method = AvoidForLoopCounterFilter.this.currentClass.methods().stream() .filter(MethodMatchers.forLocation(a.getId().getLocation())) .findFirst().get(); final AbstractInsnNode mutatedInstruction = method.instruction(instruction); final Context<AbstractInsnNode> context = Context.start(method.instructions(), DEBUG); context.store(MUTATED_INSTRUCTION.write(), mutatedInstruction); return MUTATED_FOR_COUNTER.matches(method.instructions(), context); }; }
private Predicate<MutationDetails> mutatesIteratorLoopPlumbing() { return a -> { final int instruction = a.getInstructionIndex(); final MethodTree method = ForEachLoopFilter.this.currentClass.methods().stream() .filter(MethodMatchers.forLocation(a.getId().getLocation())) .findFirst() .get(); final AbstractInsnNode mutatedInstruction = method.instruction(instruction); final Context<AbstractInsnNode> context = Context.start(method.instructions(), DEBUG); context.store(MUTATED_INSTRUCTION.write(), mutatedInstruction); return ITERATOR_LOOP.matches(method.instructions(), context); }; }
private Predicate<MutationDetails> isAnImplicitNullCheck() { return a -> { final int instruction = a.getInstructionIndex(); final MethodTree method = ImplicitNullCheckFilter.this.currentClass.methods().stream() .filter(MethodMatchers.forLocation(a.getId().getLocation())) .findFirst() .get(); final AbstractInsnNode mutatedInstruction = method.instruction(instruction); final Context<AbstractInsnNode> context = Context.start(method.instructions(), DEBUG); context.store(MUTATED_INSTRUCTION.write(), mutatedInstruction); return GET_CLASS_NULL_CHECK.matches(method.instructions(), context); }; }
private Function<MutationDetails, Loc> toLocation(final ClassTree tree) { return a -> { final MethodTree method = tree.method(a.getId().getLocation()).get(); final Loc l = new Loc(); l.index = a.getInstructionIndex(); l.node = method.instruction(a.getInstructionIndex()); return l; }; }
@Override public boolean test(MutationDetails a) { if (!MUTATOR_IDS.contains(a.getMutator())) { return false; } final MethodTree method = EmptyReturnsFilter.this.currentClass.methods().stream() .filter(MethodMatchers.forLocation(a.getId().getLocation())) .findFirst() .get(); final int mutatedInstruction = a.getInstructionIndex(); return returnsZeroValue(method, mutatedInstruction) || returnsEmptyString(method, mutatedInstruction) || returns(method, mutatedInstruction, "java/util/Optional","empty") || returns(method, mutatedInstruction, "java/util/Collections","emptyList") || returns(method, mutatedInstruction, "java/util/Collections","emptySet") || returns(method, mutatedInstruction, "java/util/List","of") || returns(method, mutatedInstruction, "java/util/Set","of"); }