aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.core.test/src
diff options
context:
space:
mode:
authorEvgeny Mandrikov <138671+Godin@users.noreply.github.com>2021-03-21 20:10:49 +0100
committerGitHub <noreply@github.com>2021-03-21 20:10:49 +0100
commit5bbe20239ce1e1ed07d039fcf1e465934310d9a4 (patch)
treec9848f21f8dd97f78cdae100d755d39a3cb46e67 /org.jacoco.core.test/src
parentfaa8b7ad2ced6a3f2de8adcca8fd5a0626d64d91 (diff)
downloadjacoco-5bbe20239ce1e1ed07d039fcf1e465934310d9a4.tar.gz
Update KotlinLateinitFilter for Kotlin 1.5 (#1166)
Diffstat (limited to 'org.jacoco.core.test/src')
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/internal/analysis/filter/KotlinLateinitFilterTest.java37
1 files changed, 37 insertions, 0 deletions
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 1c380587..85cbd16c 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
@@ -59,4 +59,41 @@ public class KotlinLateinitFilterTest extends FilterTestBase {
assertIgnored(new Range(expectedFrom, expectedTo));
}
+ /**
+ * <pre>
+ * class Example {
+ * private lateinit var x: String
+ * fun example() = x
+ * }
+ * </pre>
+ */
+ @Test
+ public void should_filter_Kotlin_1_5() {
+ final MethodNode m = new MethodNode(InstrSupport.ASM_API_VERSION, 0,
+ "example", "()Ljava/lang/String;", null, null);
+ Label label = new Label();
+ m.visitVarInsn(Opcodes.ALOAD, 0);
+ m.visitFieldInsn(Opcodes.GETFIELD, "Example", "x",
+ "Ljava/lang/String;");
+ m.visitVarInsn(Opcodes.ASTORE, 1);
+ m.visitVarInsn(Opcodes.ALOAD, 1);
+ m.visitJumpInsn(Opcodes.IFNONNULL, label);
+ final AbstractInsnNode expectedFrom = m.instructions.getLast();
+ m.visitLdcInsn("x");
+ m.visitMethodInsn(Opcodes.INVOKESTATIC,
+ "kotlin/jvm/internal/Intrinsics",
+ "throwUninitializedPropertyAccessException",
+ "(Ljava/lang/String;)V", false);
+ m.visitInsn(Opcodes.ACONST_NULL);
+ m.visitInsn(Opcodes.ATHROW);
+ final AbstractInsnNode expectedTo = m.instructions.getLast();
+ m.visitLabel(label);
+ m.visitVarInsn(Opcodes.ALOAD, 1);
+ m.visitInsn(Opcodes.ARETURN);
+
+ filter.filter(m, context, output);
+
+ assertIgnored(new Range(expectedFrom, expectedTo));
+ }
+
}