-
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
2 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...t.validation.kotlin/src/org/jacoco/core/test/validation/kotlin/KotlinInlineClassTest.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,27 @@ | ||
/******************************************************************************* | ||
* 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 org.jacoco.core.test.validation.ValidationTestBase; | ||
import org.jacoco.core.test.validation.kotlin.targets.KotlinInlineClassTarget; | ||
|
||
/** | ||
* Test of code coverage in {@link KotlinInlineClassTarget}. | ||
*/ | ||
public class KotlinInlineClassTest extends ValidationTestBase { | ||
|
||
public KotlinInlineClassTest() { | ||
super(KotlinInlineClassTarget.class); | ||
} | ||
|
||
} |
75 changes: 75 additions & 0 deletions
75
...tion.kotlin/src/org/jacoco/core/test/validation/kotlin/targets/KotlinInlineClassTarget.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,75 @@ | ||
/******************************************************************************* | ||
* 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.nop | ||
|
||
/** | ||
* Test target for `inline class`. | ||
*/ | ||
object KotlinInlineClassTarget { | ||
|
||
interface Base { | ||
fun base() | ||
} | ||
|
||
@JvmInline | ||
value class I1(val value: String) : Base { // assertEmpty() | ||
|
||
init { // assertEmpty() | ||
nop() // assertFullyCovered() | ||
} // assertEmpty() | ||
|
||
constructor() : this("") { // assertFullyCovered() | ||
nop() // assertFullyCovered() | ||
} // assertEmpty() | ||
|
||
val length: Int // assertEmpty() | ||
get() = value.length // assertFullyCovered() | ||
|
||
fun f(p: String) { // assertEmpty() | ||
nop(p) // assertFullyCovered() | ||
} // assertFullyCovered() | ||
|
||
fun f(p: I1) { // assertEmpty() | ||
nop(p) // assertFullyCovered() | ||
} // assertFullyCovered() | ||
|
||
override fun base() { // assertEmpty() | ||
nop() // assertFullyCovered() | ||
} // assertFullyCovered() | ||
|
||
} // assertEmpty() | ||
|
||
@JvmInline | ||
value class I2(val value: String) { // assertEmpty() | ||
|
||
override fun toString(): String { // assertEmpty() | ||
return "Value: $value" // assertNotCovered() | ||
} // assertEmpty() | ||
|
||
} // assertEmpty() | ||
|
||
@JvmStatic | ||
fun main(args: Array<String>) { | ||
val i = I1() | ||
i.value | ||
i.length | ||
i.f("") | ||
i.f(i) | ||
i.base() | ||
|
||
I2("") | ||
} | ||
|
||
} |