Merge pull request #21 from bnorm/crlf

Remove carriage returns from source file text
This commit is contained in:
Brian Norman
2020-09-14 20:05:51 -05:00
committed by GitHub
2 changed files with 19 additions and 2 deletions
@@ -84,7 +84,7 @@ class PowerAssertCallTransformer(
override fun lower(irFile: IrFile) { override fun lower(irFile: IrFile) {
file = irFile file = irFile
fileSource = File(irFile.path).readText() fileSource = File(irFile.path).readText().replace("\r\n", "\n")
irFile.transformChildrenVoid() irFile.transformChildrenVoid()
} }
@@ -382,6 +382,23 @@ check(1 == 2) { "the world is broken" }
PowerAssertComponentRegistrar(setOf(FqName("kotlin.check"))) PowerAssertComponentRegistrar(setOf(FqName("kotlin.check")))
) )
} }
@Test
fun carriageReturnRemoval() {
assertMessage(
"""
fun main() {
val a = 0
assert(a == 42)
}""".replace("\n", "\r\n"),
"""
Assertion failed
assert(a == 42)
| |
| false
0
""".trimIndent())
}
} }
fun assertMessage( fun assertMessage(
@@ -390,7 +407,7 @@ fun assertMessage(
vararg plugins: ComponentRegistrar = arrayOf(PowerAssertComponentRegistrar(setOf(FqName("kotlin.assert")))) vararg plugins: ComponentRegistrar = arrayOf(PowerAssertComponentRegistrar(setOf(FqName("kotlin.assert"))))
) { ) {
val result = KotlinCompilation().apply { val result = KotlinCompilation().apply {
sources = listOf(SourceFile.kotlin("main.kt", source)) sources = listOf(SourceFile.kotlin("main.kt", source, trimIndent = false))
useIR = true useIR = true
messageOutputStream = System.out messageOutputStream = System.out
compilerPlugins = plugins.toList() compilerPlugins = plugins.toList()