|
| 1 | +/******************************************************************************* |
| 2 | + * Copyright (c) 2009, 2024 Mountainminds GmbH & Co. KG and Contributors |
| 3 | + * This program and the accompanying materials are made available under |
| 4 | + * the terms of the Eclipse Public License 2.0 which is available at |
| 5 | + * http://www.eclipse.org/legal/epl-2.0 |
| 6 | + * |
| 7 | + * SPDX-License-Identifier: EPL-2.0 |
| 8 | + * |
| 9 | + * Contributors: |
| 10 | + * Evgeny Mandrikov - initial API and implementation |
| 11 | + * |
| 12 | + *******************************************************************************/ |
| 13 | +package org.jacoco.core.test.validation.kotlin; |
| 14 | + |
| 15 | +import static org.junit.Assert.assertEquals; |
| 16 | + |
| 17 | +import java.lang.reflect.Method; |
| 18 | +import java.util.Collections; |
| 19 | +import java.util.HashSet; |
| 20 | + |
| 21 | +import org.jacoco.core.test.validation.ValidationTestBase; |
| 22 | +import org.jacoco.core.test.validation.kotlin.targets.KotlinLambdaSerializableTarget; |
| 23 | +import org.junit.Test; |
| 24 | + |
| 25 | +/** |
| 26 | + * Test of code coverage in {@link KotlinLambdaSerializableTarget}. |
| 27 | + */ |
| 28 | +public class KotlinLambdaSerializableTest extends ValidationTestBase { |
| 29 | + |
| 30 | + public KotlinLambdaSerializableTest() { |
| 31 | + super(KotlinLambdaSerializableTarget.class); |
| 32 | + } |
| 33 | + |
| 34 | + @Test |
| 35 | + public void compiler_should_generate_synthetic_deserializeLambda() { |
| 36 | + final HashSet<String> names = new HashSet<String>(); |
| 37 | + for (final Method method : KotlinLambdaSerializableTarget.class |
| 38 | + .getDeclaredMethods()) { |
| 39 | + if (method.isSynthetic()) { |
| 40 | + names.add(method.getName()); |
| 41 | + } |
| 42 | + } |
| 43 | + |
| 44 | + assertEquals(Collections.singleton("$deserializeLambda$"), names); |
| 45 | + } |
| 46 | + |
| 47 | + @Test |
| 48 | + public void test_method_count() { |
| 49 | + assertMethodCount(/* main + lambda */ 2); |
| 50 | + } |
| 51 | + |
| 52 | +} |
0 commit comments