aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.core.test/src/org/jacoco/core
diff options
context:
space:
mode:
authorEvgeny Mandrikov <138671+Godin@users.noreply.github.com>2019-07-22 12:22:07 +0200
committerMarc R. Hoffmann <hoffmann@mountainminds.com>2019-07-22 12:22:07 +0200
commit07f10794af7dd5e1ee8d2225ae57b291ffce1c77 (patch)
tree9448f3cf1b470e74bbb57504516746ec1c46e705 /org.jacoco.core.test/src/org/jacoco/core
parent103c66f569962cf15c6669ba5445f619f3040281 (diff)
downloadjacoco-07f10794af7dd5e1ee8d2225ae57b291ffce1c77.tar.gz
KotlinDefaultArgumentsFilter should not assume that all parameters consume one slot (#908)
Diffstat (limited to 'org.jacoco.core.test/src/org/jacoco/core')
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultArgumentsFilterTest.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultArgumentsFilterTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultArgumentsFilterTest.java
index 721abfb0..d649e8e0 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultArgumentsFilterTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultArgumentsFilterTest.java
@@ -184,4 +184,38 @@ public class KotlinDefaultArgumentsFilterTest extends FilterTestBase {
assertIgnored(new Range(m.instructions.get(3), m.instructions.get(3)));
}
+ /**
+ * <pre>
+ * data class C(val x: Long = 42)
+ * </pre>
+ */
+ @Test
+ public void should_filter_methods_with_parameters_that_consume_two_slots() {
+ final MethodNode m = new MethodNode(InstrSupport.ASM_API_VERSION,
+ Opcodes.ACC_SYNTHETIC, "<init>",
+ "(JILkotlin/jvm/internal/DefaultConstructorMarker;)V", null,
+ null);
+ context.classAnnotations
+ .add(KotlinGeneratedFilter.KOTLIN_METADATA_DESC);
+
+ m.visitVarInsn(Opcodes.ILOAD, 3);
+ m.visitInsn(Opcodes.ICONST_1);
+ m.visitInsn(Opcodes.IAND);
+ final Label label = new Label();
+ m.visitJumpInsn(Opcodes.IFEQ, label);
+ // default argument
+ m.visitLdcInsn(Integer.valueOf(42));
+ m.visitVarInsn(Opcodes.ISTORE, 1);
+ m.visitLabel(label);
+ m.visitVarInsn(Opcodes.ALOAD, 0);
+ m.visitVarInsn(Opcodes.ILOAD, 1);
+ m.visitMethodInsn(Opcodes.INVOKESPECIAL, "Owner", "<init>", "(J)V",
+ false);
+ m.visitInsn(Opcodes.RETURN);
+
+ filter.filter(m, context, output);
+
+ assertIgnored(new Range(m.instructions.get(3), m.instructions.get(3)));
+ }
+
}