JS: make enum valueOf() throw if not found.

This commit is contained in:
Anton Bannykh
2016-12-05 16:46:43 +03:00
parent e0c75f1fb8
commit 1957ac347a
7 changed files with 36 additions and 12 deletions

View File

@@ -1,6 +1,3 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS
enum class Empty
fun box(): String {

View File

@@ -3,9 +3,20 @@ enum class Color {
BLUE
}
fun throwsOnGreen(): Boolean {
try {
Color.valueOf("GREEN")
return false
}
catch (e: Exception) {
return true
}
}
fun box() = if(
Color.valueOf("RED") == Color.RED
&& Color.valueOf("BLUE") == Color.BLUE
&& Color.values()[0] == Color.RED
&& Color.values()[1] == Color.BLUE
) "OK" else "fail"
&& throwsOnGreen()
) "OK" else "fail"