Files
kotlin-fork/backend.native/tests/codegen/enum/companionObject.kt
T
Nikolay Igotti c6a4ec2ff4 Add enumeration support. (#128)
* Add enumeration support.

* Enum classes lowering.

* merge fix

* merge fix

* used arrayOf from irModule

* changed lowering quant from body to file

* refactoring

* review fixes

* lowering for GET_OBJECT in enums

* enabled tests

* added tests

* moved tests to separate dir

* renamed test files

* moved phase up

* review fixes

* reformat
2017-01-25 14:39:36 +05:00

24 lines
624 B
Kotlin

enum class Game {
ROCK,
PAPER,
SCISSORS;
companion object {
fun foo() = ROCK
val bar = PAPER
val values2 = values()
val scissors = valueOf("SCISSORS")
}
}
fun box(): String {
if (Game.foo() != Game.ROCK) return "Fail 1"
if (Game.bar != Game.PAPER) return "Fail 2: ${Game.bar}"
if (Game.values().size != 3) return "Fail 3"
if (Game.valueOf("SCISSORS") != Game.SCISSORS) return "Fail 4"
if (Game.values2.size != 3) return "Fail 5"
if (Game.scissors != Game.SCISSORS) return "Fail 6"
return "OK"
}
fun main(args: Array<String>) = println(box())