01: package org.hansel.probes;
02:
03: import org.hansel.ProbeData;
04:
05: import org.hansel.stack.HanselValue;
06: import org.objectweb.asm.MethodVisitor;
07: import org.objectweb.asm.Opcodes;
08:
09: /**
10: * A probe for a comparing conditional branch. For decision coverage both possible
11: * conditions for the branch have to be encountered.
12: *
13: * @author Niklas Mehner.
14: */
15: public abstract class CompBranchProbe extends BranchProbe {
16:
17: public CompBranchProbe(ProbeData pd, HanselValue value) {
18: super (pd, value);
19: }
20:
21: protected abstract boolean isTrue(int n, int m);
22:
23: public void hit(int n, int m) {
24: cover(isTrue(n, m));
25: }
26:
27: public void insertProbeCode(MethodVisitor cv) {
28: cv.visitInsn(Opcodes.DUP2);
29: cv.visitLdcInsn(new Integer(getID()));
30: cv.visitMethodInsn(Opcodes.INVOKESTATIC, HIT_CLASS,
31: "hitBranch", "(III)V");
32: }
33: }
|