Files
kotlin-fork/compiler/testData/codegen/box/enum/enumCompanionInitJsAndWasm.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

73 lines
1.2 KiB
Kotlin
Vendored

// TARGET_BACKEND: JS
// TARGET_BACKEND: JS_IR
// TARGET_BACKEND: JS_IR_ES6
// TARGET_BACKEND: WASM
// WITH_STDLIB
var result = ""
enum class E(a: String) {
X("x"),
Y("y");
init {
result += "E.init($a);"
}
companion object {
init {
result += "E.companion.init;"
val value = E.values()[0].name
result += "$value;"
}
}
}
enum class F(a: String) {
X("x"),
Y("y");
init {
result += "F.init($a);"
}
companion object {
init {
result += "F.companion.init;"
}
fun foo() {
result += "F.foo();$X;"
}
}
}
enum class G(a: String) {
X("x"),
Y("y");
init {
result += "G.init($a);"
}
object O {
init {
result += "G.O.init;"
}
fun foo() {
result += "G.O.foo();$X;"
}
}
}
fun box(): String {
val y = E.Y
result += "${y.name};"
F.foo()
G.O.foo()
if (result != "E.init(x);E.init(y);E.companion.init;X;Y;F.init(x);F.init(y);F.companion.init;F.foo();X;G.init(x);G.init(y);G.O.init;G.O.foo();X;")
return "fail: $result"
return "OK"
}