Move properties of enum class object to the enum class
Similar to how it's done for usual classes
This commit is contained in:
@@ -11,7 +11,7 @@ enum class Game {
|
||||
|
||||
fun box(): String {
|
||||
if (Game.foo() != Game.ROCK) return "Fail 1"
|
||||
// TODO: fix initialization order and uncomment
|
||||
// TODO: fix initialization order and uncomment (KT-5761)
|
||||
// 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"
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
class Test {
|
||||
String test() {
|
||||
String s;
|
||||
|
||||
s = Klass.NAME;
|
||||
if (!s.equals("Klass")) throw new AssertionError("Fail class: " + s);
|
||||
|
||||
s = Trait.NAME;
|
||||
if (!s.equals("Trait")) throw new AssertionError("Fail trait: " + s);
|
||||
|
||||
s = Enoom.NAME;
|
||||
if (!s.equals("Enoom")) throw new AssertionError("Fail enum: " + s);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
class Klass {
|
||||
class object {
|
||||
val NAME = "Klass"
|
||||
}
|
||||
}
|
||||
|
||||
trait Trait {
|
||||
class object {
|
||||
val NAME = "Trait"
|
||||
}
|
||||
}
|
||||
|
||||
enum class Enoom {
|
||||
class object {
|
||||
val NAME = "Enoom"
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = Test().test()
|
||||
Reference in New Issue
Block a user