Skip to content

Commit

Permalink
Add repro case for #1076
Browse files Browse the repository at this point in the history
  • Loading branch information
ZacSweers committed Sep 20, 2021
1 parent 575c469 commit 0869845
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions kotlinpoet/src/test/java/com/squareup/kotlinpoet/FileSpecTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1041,4 +1041,23 @@ class FileSpecTest {
|""".trimMargin()
)
}

class WackyKey
class OhNoThisDoesNotCompile

@OptIn(ExperimentalStdlibApi::class)
@Test fun longCommentWithTypes() {
val someLongParameterizedTypeName = typeNameOf<List<Map<String, Collection<Map<WackyKey, OhNoThisDoesNotCompile>>>>>()
val file = FileSpec.builder("com.squareup.tacos", "Taco")
.addComment("this is a long line with a possibly long type: %T", someLongParameterizedTypeName)
.build()
assertThat(file.toString()).isEqualTo(
"""
|// this is a long line with a possibly long type: List<Map<String, Collection<Map<WackyKey, OhNoThisDoesNotCompile>>>>
|package com.squareup.tacos
|
|""".trimMargin()
)
}

}

1 comment on commit 0869845

@glureau
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I presume the imports are required here?

assertThat(file.toString()).isEqualTo(
  """
  |// this is a long line with a possibly long type: List<Map<String, Collection<Map<FileSpecTest.WackyKey, FileSpecTest.OhNoThisDoesNotCompile>>>>
  |package com.squareup.tacos
  |
  |import com.squareup.kotlinpoet.FileSpecTest
  |import kotlin.String
  |import kotlin.collections.Collection
  |import kotlin.collections.List
  |import kotlin.collections.Map
  |
  |""".trimMargin()
)

Please sign in to comment.