Skip to content

Commit

Permalink
Add tests covering TWiStErRob's last example.
Browse files Browse the repository at this point in the history
  • Loading branch information
TWiStErRob committed Jan 19, 2023
1 parent adf5d96 commit 9aa3041
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,43 @@ class MaxLineLengthSpec {
assertThat(rule.findings).hasSize(1)
assertThat(rule.findings).hasTextLocations(22 to 96)
}

@Test
fun `report the correct lines on interpolated strings - issue #5314`() {
val rule = MaxLineLength(
TestConfig(
MAX_LINE_LENGTH to "65",
)
)

rule.visitKtFile(
compileContentForTest(
"""
interface TaskContainer {
fun register(name: String, block: Number.() -> Unit = {})
}
interface Project {
val tasks: TaskContainer
}
fun repros(project: Project) {
val part = "name".capitalize()
project.tasks.register("shortName${'$'}{part}WithSuffix")
project.tasks.register("veryVeryVeryVeryVeryVeryLongName${'$'}{part}WithSuffix1")
project.tasks.register("veryVeryVeryVeryVeryVeryLongName${'$'}{part}WithSuffix2") {
this.toByte()
}
project.tasks
.register("veryVeryVeryVeryVeryVeryLongName${'$'}{part}WithSuffix3") {
this.toByte()
}
}
""".trimIndent()
)
)
assertThat(rule.findings).hasTextLocations(
" project.tasks.register(\"veryVeryVeryVeryVeryVeryLongName\${part}WithSuffix1\")",
" project.tasks.register(\"veryVeryVeryVeryVeryVeryLongName\${part}WithSuffix2\") {",
" .register(\"veryVeryVeryVeryVeryVeryLongName\${part}WithSuffix3\") {",
)
}
}

0 comments on commit 9aa3041

Please sign in to comment.