-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
70 additions
and
0 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
...e.test/src/org/jacoco/core/internal/analysis/filter/KotlinDefaultArgumentsFilterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2009, 2018 Mountainminds GmbH & Co. KG and Contributors | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Evgeny Mandrikov - initial API and implementation | ||
* | ||
*******************************************************************************/ | ||
package org.jacoco.core.internal.analysis.filter; | ||
|
||
import org.jacoco.core.internal.instr.InstrSupport; | ||
import org.junit.Test; | ||
import org.objectweb.asm.Label; | ||
import org.objectweb.asm.Opcodes; | ||
import org.objectweb.asm.tree.MethodNode; | ||
|
||
public class KotlinDefaultArgumentsFilterTest extends FilterTestBase { | ||
|
||
private static MethodNode createMethod() { | ||
final MethodNode m = new MethodNode(InstrSupport.ASM_API_VERSION, | ||
Opcodes.ACC_SYNTHETIC, "origin$default", | ||
"(LTarget;IILjava/lang/Object;)V", null, null); | ||
|
||
m.visitVarInsn(Opcodes.ILOAD, 2); | ||
m.visitInsn(Opcodes.ICONST_1); | ||
m.visitInsn(Opcodes.IAND); | ||
final Label label = new Label(); | ||
m.visitJumpInsn(Opcodes.IFEQ, label); | ||
// default argument | ||
m.visitLdcInsn(42); | ||
m.visitVarInsn(Opcodes.ISTORE, 1); | ||
m.visitLabel(label); | ||
|
||
m.visitVarInsn(Opcodes.ALOAD, 0); | ||
m.visitVarInsn(Opcodes.ILOAD, 1); | ||
m.visitMethodInsn(Opcodes.INVOKESPECIAL, "Target", "origin", "(I)V", | ||
false); | ||
m.visitInsn(Opcodes.RETURN); | ||
|
||
return m; | ||
} | ||
|
||
@Test | ||
public void should_filter() { | ||
final MethodNode m = createMethod(); | ||
|
||
assertIgnored(new Range(m.instructions.get(3), m.instructions.get(3))); | ||
} | ||
|
||
@Test | ||
public void should_not_filter_when_suffix_absent() { | ||
final MethodNode m = createMethod(); | ||
m.name = "synthetic_without_suffix"; | ||
|
||
assertIgnored(); | ||
} | ||
|
||
@Test | ||
public void should_not_filter_when_not_synthetic() { | ||
final MethodNode m = createMethod(); | ||
m.access = 0; | ||
m.name = "not_synthetic$default"; | ||
|
||
assertIgnored(); | ||
} | ||
|
||
} |