aboutsummaryrefslogtreecommitdiffstats
path: root/org.jacoco.core.test
diff options
context:
space:
mode:
authorEvgeny Mandrikov <138671+Godin@users.noreply.github.com>2019-03-14 13:54:13 +0100
committerMarc R. Hoffmann <hoffmann@mountainminds.com>2019-03-14 13:54:13 +0100
commit795c8f9e3b2e7e7abe3f4342bbd4a1dd31530325 (patch)
tree04635a92dadc4309ede496204eec963249e7b5e0 /org.jacoco.core.test
parent771812b48fe8542b89ea66e82ca4b391a130c2b2 (diff)
downloadplatform_external_jacoco-795c8f9e3b2e7e7abe3f4342bbd4a1dd31530325.tar.gz
platform_external_jacoco-795c8f9e3b2e7e7abe3f4342bbd4a1dd31530325.tar.bz2
platform_external_jacoco-795c8f9e3b2e7e7abe3f4342bbd4a1dd31530325.zip
`nextIsInvokeStatic` and `nextIsInvokeVirtual` should check method descriptor (#857)
Diffstat (limited to 'org.jacoco.core.test')
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/AbstractMatcherTest.java72
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinCoroutineFilterTest.java4
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinLateinitFilterTest.java2
3 files changed, 15 insertions, 63 deletions
diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/AbstractMatcherTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/AbstractMatcherTest.java
index 56199bf5..f659632d 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/AbstractMatcherTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/AbstractMatcherTest.java
@@ -137,89 +137,41 @@ public class AbstractMatcherTest {
}
@Test
- public void nextIsInvokeStatic() {
- m.visitInsn(Opcodes.NOP);
- m.visitMethodInsn(Opcodes.INVOKESTATIC, "owner", "name", "()V", false);
-
- // should set cursor to null when owner mismatch
- matcher.cursor = m.instructions.getFirst();
- matcher.nextIsInvokeStatic("another_owner", "name");
- assertNull(matcher.cursor);
-
- // should set cursor to null when name mismatch
- matcher.cursor = m.instructions.getFirst();
- matcher.nextIsInvokeStatic("owner", "another_name");
- assertNull(matcher.cursor);
-
- // should set cursor to next instruction when match
- matcher.cursor = m.instructions.getFirst();
- matcher.nextIsInvokeStatic("owner", "name");
- assertSame(m.instructions.getLast(), matcher.cursor);
-
- // should not do anything when cursor is null
- matcher.cursor = null;
- matcher.nextIsInvokeStatic("owner", "name");
- }
-
- @Test
- public void nextIsInvokeVirtual() {
+ public void nextIsInvoke() {
m.visitInsn(Opcodes.NOP);
m.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "owner", "name", "()V", false);
- // should set cursor to null when owner mismatch
+ // should set cursor to null when opcode mismatch
matcher.cursor = m.instructions.getFirst();
- matcher.nextIsInvokeVirtual("another_owner", "name");
+ matcher.nextIsInvoke(Opcodes.INVOKESTATIC, "owner", "name", "()V");
assertNull(matcher.cursor);
- // should set cursor to null when name mismatch
+ // should set cursor to null when owner mismatch
matcher.cursor = m.instructions.getFirst();
- matcher.nextIsInvokeVirtual("owner", "another_name");
+ matcher.nextIsInvoke(Opcodes.INVOKEVIRTUAL, "another_owner", "name",
+ "()V");
assertNull(matcher.cursor);
- // should set cursor to next instruction when match
- matcher.cursor = m.instructions.getFirst();
- matcher.nextIsInvokeVirtual("owner", "name");
- assertSame(m.instructions.getLast(), matcher.cursor);
-
- // should not do anything when cursor is null
- matcher.cursor = null;
- matcher.nextIsInvokeVirtual("owner", "name");
- }
-
- @Test
- public void nextIsInvokeSuper() {
- m.visitInsn(Opcodes.NOP);
- m.visitMethodInsn(Opcodes.INVOKESPECIAL, "owner", "not_init", "()V",
- false);
-
// should set cursor to null when name mismatch
matcher.cursor = m.instructions.getFirst();
- matcher.nextIsInvokeSuper("owner", "()V");
- assertNull(matcher.cursor);
-
- m.instructions.clear();
- m.visitInsn(Opcodes.NOP);
- m.visitMethodInsn(Opcodes.INVOKESPECIAL, "owner", "<init>", "()V",
- false);
-
- // should set cursor to null when owner mismatch
- matcher.cursor = m.instructions.getFirst();
- matcher.nextIsInvokeSuper("another_owner", "()V");
+ matcher.nextIsInvoke(Opcodes.INVOKEVIRTUAL, "owner", "another_name",
+ "()V");
assertNull(matcher.cursor);
// should set cursor to null when descriptor mismatch
matcher.cursor = m.instructions.getFirst();
- matcher.nextIsInvokeSuper("owner", "(I)V");
+ matcher.nextIsInvoke(Opcodes.INVOKEVIRTUAL, "owner", "name",
+ "(Lanother_descriptor;)V");
assertNull(matcher.cursor);
// should set cursor to next instruction when match
matcher.cursor = m.instructions.getFirst();
- matcher.nextIsInvokeSuper("owner", "()V");
+ matcher.nextIsInvoke(Opcodes.INVOKEVIRTUAL, "owner", "name", "()V");
assertSame(m.instructions.getLast(), matcher.cursor);
// should not do anything when cursor is null
matcher.cursor = null;
- matcher.nextIsInvokeSuper("owner", "()V");
+ matcher.nextIsInvoke(Opcodes.INVOKEVIRTUAL, "owner", "name", "()V");
}
@Test
diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinCoroutineFilterTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinCoroutineFilterTest.java
index b5b06743..127ae309 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinCoroutineFilterTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinCoroutineFilterTest.java
@@ -53,7 +53,7 @@ public class KotlinCoroutineFilterTest extends FilterTestBase {
{
m.visitVarInsn(Opcodes.ALOAD, 1);
m.visitMethodInsn(Opcodes.INVOKESTATIC, "kotlin/ResultKt",
- "throwOnFailure", "", false);
+ "throwOnFailure", "(Ljava/lang/Object;)V", false);
range1.toInclusive = m.instructions.getLast();
}
@@ -83,7 +83,7 @@ public class KotlinCoroutineFilterTest extends FilterTestBase {
{
m.visitVarInsn(Opcodes.ALOAD, 1);
m.visitMethodInsn(Opcodes.INVOKESTATIC, "kotlin/ResultKt",
- "throwOnFailure", "", false);
+ "throwOnFailure", "(Ljava/lang/Object;)V", false);
}
m.visitVarInsn(Opcodes.ALOAD, 1);
range2.toInclusive = m.instructions.getLast();
diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinLateinitFilterTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinLateinitFilterTest.java
index 5b5f3285..c9e34bab 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinLateinitFilterTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinLateinitFilterTest.java
@@ -47,7 +47,7 @@ public class KotlinLateinitFilterTest extends FilterTestBase {
m.visitMethodInsn(Opcodes.INVOKESTATIC,
"kotlin/jvm/internal/Intrinsics",
"throwUninitializedPropertyAccessException",
- "Ljava/lang/String;", false);
+ "(Ljava/lang/String;)V", false);
final AbstractInsnNode expectedTo = m.instructions.getLast();
m.visitLabel(l2);
m.visitMethodInsn(Opcodes.INVOKEVIRTUAL,