Files
kotlin-fork/plugins/jso/compiler-plugin/testData/box/simple.kt
T

21 lines
488 B
Kotlin
Vendored

package foo
import kotlinx.jso.JsSimpleObject
@JsSimpleObject
external interface User {
var name: String
val age: Int
}
fun box(): String {
val user = User(name = "Name", age = 10)
if (user.name != "Name") return "Fail: problem with `name` property"
if (user.age != 10) return "Fail: problem with `age` property"
val json = js("JSON.stringify(user)")
if (json != "{\"age\":10,\"name\":\"Name\"}") return "Fail: got the next json: $json"
return "OK"
}