Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation test for Serializable lambda in Kotlin #1699

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add validation test for Serializable lambda in Kotlin
  • Loading branch information
Godin committed Dec 17, 2024
commit 5b767bce9fae0b511a23d7cf7434158d63813b84
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);
}

}
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()
}

}

}