Skip to content

Instantly share code, notes, and snippets.

@drawers
Created Jun 13, 2021
Embed
What would you like to do?
@Test
fun `target is a data class`() {
val kotlinSource = SourceFile.kotlin(
"file1.kt", """
package com.tests.summable
import com.tsongkha.kspexample.IntSummable
@IntSummable
data class FooSummable(
val bar: Int = 234,
val baz: Int = 123
)
"""
)
val compilationResult = compile(kotlinSource)
assertEquals(KotlinCompilation.ExitCode.OK, compilationResult.exitCode)
assertSourceEquals(
"""
package com.tests.summable
import kotlin.Int
public fun FooSummable.sumInts(): Int {
val sum = bar + baz
return sum
}""",
compilationResult.sourceFor("FooSummable.kt")
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment