Add tests with multiple conditions types in 'when'

This commit is contained in:
Alexey Sedunov
2013-05-14 16:50:06 +04:00
parent 4ab816a888
commit 5dc08a5d25
9 changed files with 113 additions and 1 deletions
@@ -0,0 +1,12 @@
fun test(n: Int): String {
return <caret>when (n) {
!is Int -> "???"
in 0..10 -> "small"
in 10..100 -> "average"
in 100..1000 -> "big"
1000000 -> "million"
!in -100..-10 -> "good"
is Int -> "unknown"
else -> "unknown"
}
}
@@ -0,0 +1,10 @@
fun test(n: Int): String {
return <caret>if (n !is Int) "???"
else if (n in 0..10) "small"
else if (n in 10..100) "average"
else if (n in 100..1000) "big"
else if (n == 1000000) "million"
else if (n !in -100..-10) "good"
else if (n is Int) "unknown"
else "unknown"
}