org.pitest.sequence.Context Java Examples
The following examples show how to use
org.pitest.sequence.Context.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StopMethodMatcher.java From pitest-descartes with GNU Lesser General Public License v3.0 | 6 votes |
static StopMethodMatcher forBody(SequenceQuery<AbstractInsnNode> body) { final SequenceMatcher<AbstractInsnNode> matcher = body.compile( QueryParams.<AbstractInsnNode>params() .withIgnores( isA(LabelNode.class) .or(isA(FrameNode.class)) .or(isA(LineNumberNode.class))) ); return (classTree, methodTree) -> { List<AbstractInsnNode> instructions = methodTree.instructions(); Context<AbstractInsnNode> context = Context.start(methodTree.instructions()); // Ensure that matcher has found a match and that all instructions has been read. return matcher.matches(instructions, context) && context.position() == instructions.size() - 1; }; }
Example #2
Source File: KotlinInterceptor.java From pitest-kotlin with Apache License 2.0 | 5 votes |
private static Predicate<MutationDetails> isKotlinJunkMutation(final ClassTree currentClass) { return a -> { int instruction = a.getInstructionIndex(); MethodTree method = currentClass.methods().stream() .filter(MethodMatchers.forLocation(a.getId().getLocation())) .findFirst() .get(); AbstractInsnNode mutatedInstruction = method.instruction(instruction); Context<AbstractInsnNode> context = Context.start(method.instructions(), DEBUG); context.store(MUTATED_INSTRUCTION.write(), mutatedInstruction); return KOTLIN_JUNK.matches(method.instructions(), context); }; }
Example #3
Source File: MethodReferenceNullCheckFilter.java From pitest with Apache License 2.0 | 5 votes |
private Predicate<MutationDetails> isAnImplicitNullCheck() { return a -> { final int instruction = a.getInstructionIndex(); final MethodTree method = MethodReferenceNullCheckFilter.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 NULL_CHECK.matches(method.instructions(), context); }; }
Example #4
Source File: ForEachLoopFilter.java From pitest with Apache License 2.0 | 5 votes |
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); }; }
Example #5
Source File: ImplicitNullCheckFilter.java From pitest with Apache License 2.0 | 5 votes |
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); }; }
Example #6
Source File: AvoidForLoopCounterFilter.java From pitest with Apache License 2.0 | 5 votes |
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); }; }