Skip to content

Commit

Permalink
Trigger automatic line separator detection in tests
Browse files Browse the repository at this point in the history
This is required when loading KtFile using standard methods
  • Loading branch information
3flex committed May 5, 2024
1 parent d4c76a4 commit 3045ecf
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package io.github.detekt.parser
import io.github.detekt.test.utils.resourceAsPath
import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.Assertions.assertThatIllegalArgumentException
import org.jetbrains.kotlin.com.intellij.psi.PsiErrorElement
import org.jetbrains.kotlin.psi.KtTreeVisitorVoid
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
Expand All @@ -20,13 +19,19 @@ class KtCompilerSpec {
fun `Kotlin file with LF line separators has extra user data`() {
val ktFile = ktCompiler.compile(path.resolve("DefaultLf.kt"))

// visit file to trigger line detection
ktFile.accept(KtTreeVisitorVoid())

assertThat(ktFile.virtualFile.detectedLineSeparator).isEqualTo("\n")
}

@Test
fun `Kotlin file with CRLF line separators has extra user data`() {
val ktFile = ktCompiler.compile(path.resolve("DefaultCrLf.kt"))

// visit file to trigger line detection
ktFile.accept(KtTreeVisitorVoid())

assertThat(ktFile.virtualFile.detectedLineSeparator).isEqualTo("\r\n")
}

Expand Down

0 comments on commit 3045ecf

Please sign in to comment.