Files
kotlin-fork/plugins/kotlinx-serialization/testData/boxIr/sealedInterfaces.kt
T
Leonid Startsev fba2f5ea4e Expand most kotlinx.serialization tests on JS backend
to enhance and increase test coverage of the plugin.
2024-01-10 12:17:34 +00:00

35 lines
589 B
Kotlin
Vendored

// WITH_STDLIB
package a
import kotlinx.serialization.*
import kotlinx.serialization.descriptors.*
import kotlin.test.assertEquals
interface I
sealed interface SI
@Serializable
sealed interface SSI
@Serializable
class Holder(
val i: I,
val si: SI,
val ssi: SSI
)
fun SerialDescriptor.checkKind(index: Int, kind: String) {
assertEquals(kind, getElementDescriptor(index).kind.toString())
}
fun box(): String {
val desc = Holder.serializer().descriptor
desc.checkKind(0, "OPEN")
desc.checkKind(1, "OPEN")
desc.checkKind(2, "SEALED")
return "OK"
}