diff options
author | Evgeny Mandrikov <138671+Godin@users.noreply.github.com> | 2021-03-21 20:10:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-21 20:10:49 +0100 |
commit | 5bbe20239ce1e1ed07d039fcf1e465934310d9a4 (patch) | |
tree | c9848f21f8dd97f78cdae100d755d39a3cb46e67 /org.jacoco.core.test/src/org/jacoco/core | |
parent | faa8b7ad2ced6a3f2de8adcca8fd5a0626d64d91 (diff) | |
download | jacoco-5bbe20239ce1e1ed07d039fcf1e465934310d9a4.tar.gz |
Update KotlinLateinitFilter for Kotlin 1.5 (#1166)
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/KotlinLateinitFilterTest.java | 37 |
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)); + } + } |