Skip to content

Commit

Permalink
test sourceOf on different declaration types
Browse files Browse the repository at this point in the history
  • Loading branch information
mfwgenerics committed Jan 2, 2023
1 parent 974cc9f commit d5d8d3b
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions testing/src/test/kotlin/CaptureSourceTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,64 @@ class CaptureSourceTests {
"fun five() = 5", sourceOf(Inner::five)
)
}

@CaptureSource
interface CapturedInterface {
fun type() = "interface"
}

@CaptureSource
object CapturedObj {
val test = "123"
}

@CaptureSource
sealed class CapturedSealed {
object Left: CapturedSealed()
object Right: CapturedSealed()

@CaptureSource
companion object { }
}

@Test
fun `capture assorted declarations`() {
assertEquals(
"""
interface CapturedInterface {
fun type() = "interface"
}
""".trimIndent(),
sourceOf<CapturedInterface>()
)

assertEquals(
"""
object CapturedObj {
val test = "123"
}
""".trimIndent(),
sourceOf<CapturedObj>()
)

assertEquals(
"""
sealed class CapturedSealed {
object Left: CapturedSealed()
object Right: CapturedSealed()
@CaptureSource
companion object { }
}
""".trimIndent(),
sourceOf<CapturedSealed>()
)

assertEquals(
"""
companion object { }
""".trimIndent(),
sourceOf<CapturedSealed.Companion>()
)
}
}

0 comments on commit d5d8d3b

Please sign in to comment.