Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit 89f1d5c

Browse files
authored
Merge pull request #21 from bnorm/crlf
Remove carriage returns from source file text
2 parents 22a1e16 + 6de1f2a commit 89f1d5c

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

kotlin-power-assert-plugin/src/main/kotlin/com/bnorm/power/PowerAssertCallTransformer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
}

kotlin-power-assert-plugin/src/test/kotlin/com/bnorm/power/test.kt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff 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

387404
fun 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()

0 commit comments

Comments
 (0)