Skip to content

Commit

Permalink
Fix sample code syntax and not compile mulitplatform code
Browse files Browse the repository at this point in the history
  • Loading branch information
G00fY2 committed Mar 23, 2022
1 parent b4a756e commit 3e42301
Showing 1 changed file with 9 additions and 8 deletions.
Expand Up @@ -2,6 +2,7 @@ package io.gitlab.arturbosch.detekt.rules.bugs

import io.gitlab.arturbosch.detekt.rules.KotlinCoreEnvironmentTest
import io.gitlab.arturbosch.detekt.test.compileAndLintWithContext
import io.gitlab.arturbosch.detekt.test.lintWithContext
import org.assertj.core.api.Assertions.assertThat
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.junit.jupiter.api.Nested
Expand Down Expand Up @@ -159,9 +160,9 @@ class ElseCaseInsteadOfExhaustiveWhenSpec(private val env: KotlinCoreEnvironment
fun `does not report when _expect_ sealed _when_ expression used as statement contains _else_ case`() {
val code = """
expect sealed class Variant {
object VariantA : Variant()
class VariantB : Variant()
object VariantC : Variant()
class VariantA : Variant
class VariantB : Variant
class VariantC : Variant
}
fun whenOnSealedFail(v: Variant) {
Expand All @@ -172,16 +173,16 @@ class ElseCaseInsteadOfExhaustiveWhenSpec(private val env: KotlinCoreEnvironment
}
}
"""
assertThat(subject.compileAndLintWithContext(env, code)).isEmpty()
assertThat(subject.lintWithContext(env, code)).isEmpty()
}

@Test
fun `does not report when _expect_ sealed _when_ expression contains _else_ case`() {
val code = """
expect sealed class Variant {
object VariantA : Variant()
class VariantB : Variant()
object VariantC : Variant()
class VariantA : Variant
class VariantB : Variant
class VariantC : Variant
}
fun whenOnSealedFail(v: Variant) {
Expand All @@ -192,7 +193,7 @@ class ElseCaseInsteadOfExhaustiveWhenSpec(private val env: KotlinCoreEnvironment
}
}
"""
assertThat(subject.compileAndLintWithContext(env, code)).isEmpty()
assertThat(subject.lintWithContext(env, code)).isEmpty()
}
}

Expand Down

0 comments on commit 3e42301

Please sign in to comment.