You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Kover 0.8.1 and previous versions are incorrectly calculating the branch % for some reified extensions. Below is a snippet on how to reproduce the observed error:
Internal Function:
internalinlinefun <reifiedT> sizeOf() : Int where T : Number=when(T::class)
{
Byte::class->Byte.SIZE_BYTESShort::class->Short.SIZE_BYTESInt::class->Int.SIZE_BYTESLong::class->Long.SIZE_BYTESFloat::class->Float.SIZE_BYTESDouble::class->Double.SIZE_BYTESelse->throwException("Unsupported type")
}
Unit Test - results in partial "Branch, %" coverage although the "Instruction, %" is 100%:
@Test
fun sizeOfTest() {
assertEquals(1, sizeOf<Byte>())
assertEquals(2, sizeOf<Short>())
assertEquals(4, sizeOf<Int>())
assertEquals(8, sizeOf<Long>())
assertEquals(4, sizeOf<Float>())
assertEquals(8, sizeOf<Double>())
assertFailsWith<Exception> {
sizeOf<InvalidNumberClass>()
}
}
private class InvalidNumberClass(private val number: Number): Number() {
override fun toByte() = number.toByte()
override fun toShort() = number.toShort()
override fun toInt() = number.toInt()
override fun toLong() = number.toLong()
override fun toFloat() = number.toFloat()
override fun toDouble(): Double = number.toDouble()
}
Environment
Kover Gradle Plugin version: 0.8.1
Gradle version: 8.2
Kotlin project type: Kotlin/Multiplatform
The text was updated successfully, but these errors were encountered:
@shanshin For the last inlined call, the compiler replaced previously used IFEQ with IFNE instruction, so the coverage agent tracks the first branch as covered twice, and the second one as not covered at all.
Kover 0.8.1 and previous versions are incorrectly calculating the branch % for some reified extensions. Below is a snippet on how to reproduce the observed error:
Internal Function:
Unit Test - results in partial "Branch, %" coverage although the "Instruction, %" is 100%:
Environment
The text was updated successfully, but these errors were encountered: