aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.core.test
diff options
context:
space:
mode:
authorAllen Hair <allenhair@google.com>2014-12-16 10:18:04 -0800
committerAllen Hair <allenhair@google.com>2014-12-16 10:18:04 -0800
commitfdd2f4841ba466e3fa7e5c3df285478d06af422c (patch)
tree4eb4610a5cc380048d46bd8baba14912d80cfe03 /org.jacoco.core.test
parent0974a254332d669e6b90f05bc1d999079dca202d (diff)
downloadjacoco-fdd2f4841ba466e3fa7e5c3df285478d06af422c.tar.gz
Extend try-catch blocks to cover inserted probes.
Diffstat (limited to 'org.jacoco.core.test')
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/internal/flow/MethodProbesAdapterTest.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/flow/MethodProbesAdapterTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/flow/MethodProbesAdapterTest.java
index ea329632..5590323f 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/internal/flow/MethodProbesAdapterTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/internal/flow/MethodProbesAdapterTest.java
@@ -312,6 +312,58 @@ public class MethodProbesAdapterTest implements IProbeIdGenerator {
expectedVisitor.visitTableSwitchInsn(0, 1, label, labels);
}
+ @Test
+ public void testVisitTryCatchBlockNoProbe() {
+ Label start = new Label();
+ Label end = new Label();
+ Label handler = new Label();
+
+ adapter.visitTryCatchBlock(start, end, handler, "java/lang/Exception");
+ adapter.visitLabel(start);
+
+ expectedVisitor.visitTryCatchBlock(start, end, handler, "java/lang/Exception");
+ expectedVisitor.visitLabel(start);
+ }
+
+ @Test
+ public void testVisitTryCatchBlockWithProbe() {
+ Label target = new Label();
+ LabelInfo.setSuccessor(target);
+ LabelInfo.setTarget(target);
+ Label end = new Label();
+ Label handler = new Label();
+ Label start = new Label();
+
+ adapter.visitTryCatchBlock(target, end, handler, "java/lang/Exception");
+ adapter.visitLabel(target);
+
+ expectedVisitor.visitTryCatchBlock(start, end, handler, "java/lang/Exception");
+ expectedVisitor.visitLabel(start);
+ expectedVisitor.visitProbe(1000);
+ expectedVisitor.visitLabel(target);
+ }
+
+ @Test
+ public void testVisitMultipleTryCatchBlocksWithProbe() {
+ Label target = new Label();
+ LabelInfo.setSuccessor(target);
+ LabelInfo.setTarget(target);
+ Label end = new Label();
+ Label handler1 = new Label();
+ Label handler2 = new Label();
+ Label start = new Label();
+
+ adapter.visitTryCatchBlock(target, end, handler1, "java/lang/Exception");
+ adapter.visitTryCatchBlock(target, end, handler2, "java/io/IOException");
+ adapter.visitLabel(target);
+
+ expectedVisitor.visitTryCatchBlock(start, end, handler1, "java/lang/Exception");
+ expectedVisitor.visitTryCatchBlock(start, end, handler2, "java/io/IOException");
+ expectedVisitor.visitLabel(start);
+ expectedVisitor.visitProbe(1000);
+ expectedVisitor.visitLabel(target);
+ }
+
// === IProbeIdGenerator ===
public int nextId() {