mike.holler
10/28/2022, 4:08 PMconst val
and cannot be val
). Does anybody have any suggestions? The test below fails right now, but I'd like to make it pass by only adding code. I'd love to use .trimIndent()
when declaring myString
but I can't. Is there something I can use that the compiler will unfold?
const val myString = """
This is my string. I wrap it across multiple lines when it
becomes too long, but there should be no lines visible when
using this string. In other words, the newlines should be
compiled out of this string, and the margin collapsed. Is
there any compiler plugin I can use that can help make this
a reality?
"""
class ExampleTest {
@Test
fun `precompiled multi-line string has no newlines`() {
expectThat(myString).doesNotContain('/n')
}
}
Vampire
10/28/2022, 9:36 PMtrimIndent
would trim the indents, but not kill the linebreaks.
Can't you just make the multi-line string a string concatenation, iirc that is something the compiler can handle:
const val myString =
"This is my string. I wrap it across multiple lines when it " +
"becomes too long, but there should be no lines visible when " +
"using this string. In other words, the newlines should be " +
"compiled out of this string, and the margin collapsed. Is " +
"there any compiler plugin I can use that can help make this " +
"a reality?"
Klitos Kyriacou
10/31/2022, 8:58 AM'/n'
should be '\n'