Skip to content

Commit

Permalink
(WIP) add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Godin committed Dec 22, 2021
1 parent ac756b6 commit fbab8e7
Showing 1 changed file with 25 additions and 0 deletions.
Expand Up @@ -121,6 +121,31 @@ public void should_filter_Kotlin_1_5() {
assertIgnored(new Range(expectedFrom, expectedTo));
}

@Test
public void should_filter_Kotlin_1_6() {
context.classAnnotations
.add(KotlinGeneratedFilter.KOTLIN_METADATA_DESC);

final Label label = new Label();
m.visitInsn(Opcodes.DUP);
m.visitJumpInsn(Opcodes.IFNONNULL, label);
final AbstractInsnNode expectedFrom = m.instructions.getLast();
m.visitInsn(Opcodes.POP);
m.visitTypeInsn(Opcodes.NEW, "java/lang/NullPointerException");
m.visitInsn(Opcodes.DUP);
m.visitLdcInsn("null cannot be cast to non-null type kotlin.String");
m.visitMethodInsn(Opcodes.INVOKESPECIAL,
"java/lang/NullPointerException", "<init>",
"(Ljava/lang/String;)V", false);
m.visitInsn(Opcodes.ATHROW);
final AbstractInsnNode expectedTo = m.instructions.getLast();
m.visitLabel(label);

filter.filter(m, context, output);

assertIgnored(new Range(expectedFrom, expectedTo));
}

@Test
public void should_not_filter_when_not_kotlin() {
m.visitInsn(Opcodes.DUP);
Expand Down

0 comments on commit fbab8e7

Please sign in to comment.