use of org.objectweb.asm.tree.AbstractInsnNode in project jacoco by jacoco.
the class InstructionsBuilderTest method jumps_should_propagate_coverage_status.
@Test
public void jumps_should_propagate_coverage_status() {
InsnNode i1 = new InsnNode(Opcodes.NOP);
builder.addInstruction(i1);
Label l2 = new Label();
builder.addJump(l2, 0);
builder.addLabel(l2);
InsnNode i2 = new InsnNode(Opcodes.NOP);
builder.addInstruction(i2);
// mark i2 as covered
builder.addProbe(1, 0);
// coverage should be propagated to i1
Map<AbstractInsnNode, Instruction> map = builder.getInstructions();
assertEquals(CounterImpl.COUNTER_0_1, map.get(i1).getInstructionCounter());
}
use of org.objectweb.asm.tree.AbstractInsnNode in project jacoco by jacoco.
the class MethodCoverageCalculatorTest method should_replace_branches_with_merged_instructions.
@Test
public void should_replace_branches_with_merged_instructions() {
InsnNode i1 = addInsn(1, false, false, false);
InsnNode i2 = addInsn(2, true);
InsnNode i3 = addInsn(2, false);
InsnNode i4 = addInsn(2, false);
MethodCoverageCalculator c = new MethodCoverageCalculator(instructions);
c.merge(i4, i3);
c.merge(i3, i2);
c.replaceBranches(i1, new HashSet<AbstractInsnNode>(Arrays.asList(i2, i3, i4)));
c.calculate(coverage);
assertLine(1, 0, 1, 0, 3);
}
use of org.objectweb.asm.tree.AbstractInsnNode in project jacoco by jacoco.
the class MethodCoverageCalculatorTest method setup.
@Before
public void setup() {
instructions = new HashMap<AbstractInsnNode, Instruction>();
coverage = new MethodCoverageImpl("run", "()V", null);
list = new InsnList();
}
use of org.objectweb.asm.tree.AbstractInsnNode in project jacoco by jacoco.
the class MethodCoverageCalculator method applyMerges.
private void applyMerges() {
// Merge to the representative:
for (final Entry<AbstractInsnNode, AbstractInsnNode> entry : merged.entrySet()) {
final AbstractInsnNode node = entry.getKey();
final Instruction instruction = instructions.get(node);
final AbstractInsnNode representativeNode = findRepresentative(node);
ignored.add(node);
instructions.put(representativeNode, instructions.get(representativeNode).merge(instruction));
entry.setValue(representativeNode);
}
// Get merged value back from representative
for (final Entry<AbstractInsnNode, AbstractInsnNode> entry : merged.entrySet()) {
instructions.put(entry.getKey(), instructions.get(entry.getValue()));
}
}
use of org.objectweb.asm.tree.AbstractInsnNode in project jacoco by jacoco.
the class SynchronizedFilter method filter.
public void filter(final MethodNode methodNode, final IFilterContext context, final IFilterOutput output) {
for (final TryCatchBlockNode tryCatch : methodNode.tryCatchBlocks) {
if (tryCatch.type != null) {
continue;
}
if (tryCatch.start == tryCatch.handler) {
continue;
}
final AbstractInsnNode to = new Matcher(tryCatch.handler).match();
if (to == null) {
continue;
}
output.ignore(tryCatch.handler, to);
}
}
Aggregations