Files
kotlin-fork/compiler/testData/codegen/box/enum/initEntriesInCompanionObject2.kt
T
Nikolay Lunyak bcfafc601e Add EnumEntries to minimal-stdlib-for-tests
This change allows to revert adding `WITH_STDLIB` directive
to tests which happened at `a9343aeb`.

Co-authored-by: Alexander Udalov <Alexander.Udalov@jetbrains.com>
2023-03-02 10:23:38 +00:00

53 lines
756 B
Kotlin
Vendored

// IGNORE_BACKEND: JS
// IGNORE_BACKEND: WASM
var l = ""
enum class Foo {
FOO,
BAR;
init {
l += "Foo.$name;"
}
companion object {
init {
l += "Foo.CO;"
}
val boo = 22
}
}
enum class Foo2 {
FOO,
BAR;
init {
l += "Foo2.$name;"
}
companion object {
init {
l += "Foo2.CO;"
}
val boo = 22
}
}
fun box(): String {
try {
enumValueOf<Foo>("NO")
} catch (e: Throwable) {
l += "caught;"
}
if (l != "Foo.FOO;Foo.BAR;Foo.CO;caught;") return "Failure 0: l = $l"
l = ""
enumValueOf<Foo2>("BAR")
if (l != "Foo2.FOO;Foo2.BAR;Foo2.CO;") return "Failure 1: l = $l"
return "OK"
}