diff options
author | Evgeny Mandrikov <138671+Godin@users.noreply.github.com> | 2019-06-11 18:16:52 +0200 |
---|---|---|
committer | Marc R. Hoffmann <hoffmann@mountainminds.com> | 2019-06-11 18:16:52 +0200 |
commit | 6c62355297e378224d8fba1dd1c26d75b7ed998b (patch) | |
tree | b494f35574f25b80b0b9f3ecc21bc1963ff0bb81 /org.jacoco.core.test/src | |
parent | 219088deac4b5af5d5c7346da65042894585d5c4 (diff) | |
download | jacoco-6c62355297e378224d8fba1dd1c26d75b7ed998b.tar.gz |
ProbeInserter should update indexes of local variables in annotations (#894)
Diffstat (limited to 'org.jacoco.core.test/src')
-rw-r--r-- | org.jacoco.core.test/src/org/jacoco/core/internal/instr/ProbeInserterTest.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/instr/ProbeInserterTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/instr/ProbeInserterTest.java index c086f514..ddcaf9ce 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/internal/instr/ProbeInserterTest.java +++ b/org.jacoco.core.test/src/org/jacoco/core/internal/instr/ProbeInserterTest.java @@ -18,8 +18,10 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Opcodes; +import org.objectweb.asm.TypeReference; /** * Unit tests for {@link ProbeInserter}. @@ -183,6 +185,28 @@ public class ProbeInserterTest { } @Test + public void should_remap_LocalVariableAnnotation() { + ProbeInserter pi = new ProbeInserter(0, "m", "(I)V", actualVisitor, + arrayStrategy); + + final Label start = new Label(); + pi.visitLabel(start); + final Label end = new Label(); + pi.visitLabel(end); + + pi.visitLocalVariableAnnotation(TypeReference.LOCAL_VARIABLE, null, + new Label[] { start }, new Label[] { end }, new int[] { 2 }, + "LNonNull;", false); + + expectedVisitor.visitLabel(start); + expectedVisitor.visitLabel(end); + // Local variables are shifted by one: + expectedVisitor.visitLocalVariableAnnotation( + TypeReference.LOCAL_VARIABLE, null, new Label[] { start }, + new Label[] { end }, new int[] { 3 }, "LNonNull;", false); + } + + @Test public void testVisitMaxs1() { ProbeInserter pi = new ProbeInserter(0, "m", "(II)V", actualVisitor, arrayStrategy); |