diff options
author | Evgeny Mandrikov <Godin@users.noreply.github.com> | 2018-11-27 13:16:14 +0100 |
---|---|---|
committer | Marc R. Hoffmann <hoffmann@mountainminds.com> | 2018-11-27 13:16:14 +0100 |
commit | 78b28dc8463c301b207c60f0394251d4f2ae9aba (patch) | |
tree | e7b3a4179c10e834ec4bc43d972cc8c5d82b5bef /org.jacoco.core.test.validation.kotlin | |
parent | 276e1cb2ad4b4e2341e487a90285382324eec712 (diff) | |
download | platform_external_jacoco-78b28dc8463c301b207c60f0394251d4f2ae9aba.tar.gz platform_external_jacoco-78b28dc8463c301b207c60f0394251d4f2ae9aba.tar.bz2 platform_external_jacoco-78b28dc8463c301b207c60f0394251d4f2ae9aba.zip |
Report code coverage correctly for Kotlin methods with default arguments (#774)
Diffstat (limited to 'org.jacoco.core.test.validation.kotlin')
2 files changed, 62 insertions, 0 deletions
diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinDefaultArgumentsTest.java b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinDefaultArgumentsTest.java new file mode 100644 index 00000000..4199cf7c --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinDefaultArgumentsTest.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * 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.test.validation.kotlin; + +import org.jacoco.core.test.validation.ValidationTestBase; +import org.jacoco.core.test.validation.kotlin.targets.KotlinDefaultArgumentsTarget; + +/** + * Test of functions with default arguments. + */ +public class KotlinDefaultArgumentsTest extends ValidationTestBase { + + public KotlinDefaultArgumentsTest() { + super(KotlinDefaultArgumentsTarget.class); + } + +} diff --git a/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDefaultArgumentsTarget.kt b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDefaultArgumentsTarget.kt new file mode 100644 index 00000000..6943f206 --- /dev/null +++ b/org.jacoco.core.test.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinDefaultArgumentsTarget.kt @@ -0,0 +1,36 @@ +/******************************************************************************* + * 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.test.validation.kotlin.targets + +/** + * Test target for functions with default arguments. + */ +object KotlinDefaultArgumentsTarget { + + private fun f(a: String = "a", b: String = "b") { // assertFullyCovered(0, 0) + } + + private fun branch(a: Boolean, b: String = if (a) "a" else "b") { // assertFullyCovered(0, 2) + } + + @JvmStatic + fun main(args: Array<String>) { + f(a = "a") + f(b = "b") + /* next invocation doesn't use synthetic method: */ + f("a", "b") + + branch(false) + branch(true) + } + +} |