This repository was archived by the owner on Jun 3, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
kotlin-power-assert-plugin/src
main/kotlin/com/bnorm/power
test/kotlin/com/bnorm/power Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ class PowerAssertCallTransformer(
8484
8585 override fun lower (irFile : IrFile ) {
8686 file = irFile
87- fileSource = File (irFile.path).readText()
87+ fileSource = File (irFile.path).readText().replace( " \r\n " , " \n " )
8888
8989 irFile.transformChildrenVoid()
9090 }
Original file line number Diff line number Diff line change @@ -382,6 +382,23 @@ check(1 == 2) { "the world is broken" }
382382 PowerAssertComponentRegistrar (setOf (FqName (" kotlin.check" )))
383383 )
384384 }
385+
386+ @Test
387+ fun carriageReturnRemoval () {
388+ assertMessage(
389+ """
390+ fun main() {
391+ val a = 0
392+ assert(a == 42)
393+ }""" .replace(" \n " , " \r\n " ),
394+ """
395+ Assertion failed
396+ assert(a == 42)
397+ | |
398+ | false
399+ 0
400+ """ .trimIndent())
401+ }
385402}
386403
387404fun assertMessage (
@@ -390,7 +407,7 @@ fun assertMessage(
390407 vararg plugins : ComponentRegistrar = arrayOf(PowerAssertComponentRegistrar (setOf(FqName ("kotlin.assert"))))
391408) {
392409 val result = KotlinCompilation ().apply {
393- sources = listOf (SourceFile .kotlin(" main.kt" , source))
410+ sources = listOf (SourceFile .kotlin(" main.kt" , source, trimIndent = false ))
394411 useIR = true
395412 messageOutputStream = System .out
396413 compilerPlugins = plugins.toList()
You can’t perform that action at this time.
0 commit comments