Skip to content

Commit

Permalink
Merge branch 'main' into add-named-param-test-cases
Browse files Browse the repository at this point in the history
  • Loading branch information
snowe2010 authored Jul 1, 2024
2 parents 65eacfe + 94bb2fa commit c46be67
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions core/src/test/java/com/facebook/ktfmt/format/FormatterTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7545,6 +7545,7 @@ class FormatterTest {

@Test
fun `comment stable test`() {
// currently unstable
val first =
"""
|class Foo { // This is a very long comment that is very long and needs to be line broken because it is long
Expand All @@ -7571,6 +7572,88 @@ class FormatterTest {
assertFormatted(third)
}

@Test
fun `comment stable test - no block`() {
val first =
"""
|class Fooez // This is a very long comment that is very long and needs to be line broken because it is long
|"""
.trimMargin()
val second =
"""
|class Fooez // This is a very long comment that is very long and needs to be line broken because it
| // is long
|"""
.trimMargin()

assertThatFormatting(first).isEqualTo(second)
assertFormatted(second)
}

@Test
fun `comment stable test - two blocks`() {
// currently unstable
val first =
"""
|class Fooez // This is a very long comment that is very long and needs to be line broken because it is long
|class Bar
|"""
.trimMargin()
val second =
"""
|class Fooez // This is a very long comment that is very long and needs to be line broken because it
| // is long
|
|class Bar
|"""
.trimMargin()
val third =
"""
|class Fooez // This is a very long comment that is very long and needs to be line broken because it
|
|// is long
|
|class Bar
|"""
.trimMargin()

assertThatFormatting(first).isEqualTo(second)
assertThatFormatting(second).isEqualTo(third)
assertFormatted(third)
}

@Test
fun `comment stable test - within block`() {
// currently unstable
val first =
"""
|class Foo {
| class Bar // This is a very long comment that is very long and needs to be line broken because it is long
|}
|"""
.trimMargin()
val second =
"""
|class Foo {
| class Bar // This is a very long comment that is very long and needs to be line broken because it
| // is long
|}
|"""
.trimMargin()
val third =
"""
|class Foo {
| class Bar // This is a very long comment that is very long and needs to be line broken because it
| // is long
|}
|"""
.trimMargin()

assertThatFormatting(first).isEqualTo(second)
assertThatFormatting(second).isEqualTo(third)
assertFormatted(third)
}

companion object {
/** Triple quotes, useful to use within triple-quoted strings. */
private const val TQ = "\"\"\""
Expand Down

0 comments on commit c46be67

Please sign in to comment.