Files
kotlin-fork/plugins/kotlinx-serialization/testData/boxIr/delegatedInterface.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

22 lines
561 B
Kotlin
Vendored

// WITH_STDLIB
import kotlinx.serialization.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.*
@Serializable()
class Dto(
val data: Map<Int, Int>
) : Map<Int, Int> by data
fun box(): String {
val dto = Dto(mapOf(1 to 2))
val s = Json.encodeToString(dto)
if (s != """{"data":{"1":2}}""") return s
val d = Json.decodeFromString<Dto>(s)
if (d.size != 1) return "Delegation to Map failed"
if (d.data != dto.data) return "Equals failed ${d.data}"
return "OK"
}