mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
JS: make enum valueOf() throw if not found.
This commit is contained in:
@@ -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 {
|
||||
|
||||
13
compiler/testData/codegen/box/enum/valueof.kt
vendored
13
compiler/testData/codegen/box/enum/valueof.kt
vendored
@@ -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"
|
||||
Reference in New Issue
Block a user