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

Partial coverage in when expression for nullable String in Kotlin #1749

Closed
shanshin opened this issue Oct 16, 2024 · 0 comments · Fixed by #1769
Closed

Partial coverage in when expression for nullable String in Kotlin #1749

shanshin opened this issue Oct 16, 2024 · 0 comments · Fixed by #1769
Assignees
Milestone

Comments

@shanshin
Copy link

For the following src/Example.kt

fun testString(p: String?) = when (p) {
    "a", "b" -> 1
    "c" -> 2
    else -> 3
}

fun main() {
    testString("a")
    testString("b")
    testString("c")
    testString("d")
}

execution of

kotlin-2.0.21/bin/kotlinc src -d classes
java -javaagent:jacoco-0.8.13-SNAPSHOT/lib/jacocoagent.jar -cp classes:kotlin-2.0.21/lib/kotlin-stdlib.jar ExampleKt
java -jar jacoco-0.8.13-SNAPSHOT/lib/jacococli.jar report jacoco.exec --classfiles classes --sourcefiles src --html report

produces report
Screenshot 2024-10-16 at 13 58 04
Screenshot 2024-10-16 at 13 58 12

Perhaps relates to this issue.

Expected behaviour

All branches in when expression should be fully covered

Environment

  • JaCoCo version: actual master branch built locally
  • Kotlin 2.0.21
  • Operating system: MacOS 15
  • Tool integration: CLI
@shanshin shanshin added the type: bug 🐛 Something isn't working label Oct 16, 2024
@Godin Godin added this to Filtering Oct 16, 2024
@github-project-automation github-project-automation bot moved this to Awaiting triage in Filtering Oct 16, 2024
@Godin Godin self-assigned this Nov 8, 2024
@Godin Godin moved this from Awaiting triage to To Do in Filtering Nov 8, 2024
@Godin Godin moved this from To Do to In Progress in Filtering Nov 8, 2024
@Godin Godin added this to the 0.8.13 milestone Dec 19, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in Filtering Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants