-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add validation test for
Serializable
lambda in Kotlin (#1699)
- Loading branch information
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
...ation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinLambdaSerializableTest.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,52 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2009, 2024 Mountainminds GmbH & Co. KG and Contributors | ||
* This program and the accompanying materials are made available under | ||
* the terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Evgeny Mandrikov - initial API and implementation | ||
* | ||
*******************************************************************************/ | ||
package org.jacoco.core.test.validation.kotlin; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.lang.reflect.Method; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
|
||
import org.jacoco.core.test.validation.ValidationTestBase; | ||
import org.jacoco.core.test.validation.kotlin.targets.KotlinLambdaSerializableTarget; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Test of code coverage in {@link KotlinLambdaSerializableTarget}. | ||
*/ | ||
public class KotlinLambdaSerializableTest extends ValidationTestBase { | ||
|
||
public KotlinLambdaSerializableTest() { | ||
super(KotlinLambdaSerializableTarget.class); | ||
} | ||
|
||
@Test | ||
public void compiler_should_generate_synthetic_deserializeLambda() { | ||
final HashSet<String> names = new HashSet<String>(); | ||
for (final Method method : KotlinLambdaSerializableTarget.class | ||
.getDeclaredMethods()) { | ||
if (method.isSynthetic()) { | ||
names.add(method.getName()); | ||
} | ||
} | ||
|
||
assertEquals(Collections.singleton("$deserializeLambda$"), names); | ||
} | ||
|
||
@Test | ||
public void test_method_count() { | ||
assertMethodCount(/* main + lambda */ 2); | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
...tlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinLambdaSerializableTarget.kt
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,32 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2009, 2024 Mountainminds GmbH & Co. KG and Contributors | ||
* This program and the accompanying materials are made available under | ||
* the terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Evgeny Mandrikov - initial API and implementation | ||
* | ||
*******************************************************************************/ | ||
package org.jacoco.core.test.validation.kotlin.targets | ||
|
||
import org.jacoco.core.test.validation.targets.Stubs.execSerializable | ||
import org.jacoco.core.test.validation.targets.Stubs.nop | ||
|
||
/** | ||
* Test target with [java.io.Serializable] lambda. | ||
*/ | ||
object KotlinLambdaSerializableTarget { | ||
|
||
@JvmStatic | ||
fun main(args: Array<String>) { | ||
|
||
execSerializable { | ||
nop() // assertFullyCovered() | ||
} | ||
|
||
} | ||
|
||
} |