Files
kotlin-fork/compiler/testData/codegen/box/enum/companionAccessingEnumValue.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

35 lines
586 B
Kotlin
Vendored

private var logs = ""
enum class Foo(val text: String) {
FOO("foo"),
BAR("bar"),
PING("foo");
init {
logs += "${text}A;"
}
companion object {
init {
logs += "StatA;"
}
val first = values()[0]
init {
logs += "Stat${first.text};"
}
}
init {
logs += "${text}B;"
}
}
fun box(): String {
Foo.FOO
if (Foo.first !== Foo.FOO) return "FAIL 0: ${Foo.first}"
if (logs != "fooA;fooB;barA;barB;fooA;fooB;StatA;Statfoo;") return "FAIL 1: ${logs}"
return "OK"
}