#KT-8708 migrate tests to new trimIdent() and prependIndent

This commit is contained in:
Sergey Mashkov
2015-08-13 14:40:07 +03:00
parent 84ef068f5d
commit 2f7193064f
2 changed files with 2 additions and 59 deletions
@@ -139,33 +139,4 @@ public abstract class AbstractJavaToKotlinConverterSingleFileTest : AbstractJava
private fun createKotlinFile(text: String): JetFile {
return myFixture.configureByText("converterTestFile.kt", text) as JetFile
}
deprecated("use kotlin.trimIndent instead")
private fun String.trimIndent(): String {
val lines = split('\n')
val firstNonEmpty = lines.firstOrNull { !it.trim().isEmpty() }
if (firstNonEmpty == null) {
return this
}
val trimmedPrefix = firstNonEmpty.takeWhile { ch -> ch.isWhitespace() }
if (trimmedPrefix.isEmpty()) {
return this
}
return lines.map { line ->
if (line.trim().isEmpty()) {
""
}
else {
if (!line.startsWith(trimmedPrefix)) {
throw IllegalArgumentException(
"""Invalid line "$line", ${trimmedPrefix.length()} whitespace character are expected""")
}
line.substring(trimmedPrefix.length())
}
}.joinToString(separator = "\n")
}
}