Quick fix "Add remaining when branches" with some tests

This commit is contained in:
Mikhail Glukhikh
2016-01-11 18:37:21 +03:00
parent 44b07d8dfa
commit 8b6156abd6
11 changed files with 162 additions and 3 deletions
@@ -0,0 +1,4 @@
// "Add remaining branches" "true"
fun test(b: Boolean) = wh<caret>en(b) {
false -> 0
}
@@ -0,0 +1,5 @@
// "Add remaining branches" "true"
fun test(b: Boolean) = when(b) {
false -> 0
true -> throw AssertionError("")
}
@@ -0,0 +1,5 @@
// "Add remaining branches" "true"
enum class Color { R, G, B }
fun test(c: Color) = wh<caret>en(c) {
Color.B -> 0xff
}
@@ -0,0 +1,7 @@
// "Add remaining branches" "true"
enum class Color { R, G, B }
fun test(c: Color) = when(c) {
Color.B -> 0xff
Color.R -> throw AssertionError("")
Color.G -> throw AssertionError("")
}
@@ -0,0 +1,11 @@
// "Add remaining branches" "true"
sealed class Variant {
object Singleton : Variant()
class Something(val x: Int) : Variant()
object Another : Variant()
}
fun test(v: Variant?) = wh<caret>en(v) {
Variant.Singleton -> "s"
}
@@ -0,0 +1,14 @@
// "Add remaining branches" "true"
sealed class Variant {
object Singleton : Variant()
class Something(val x: Int) : Variant()
object Another : Variant()
}
fun test(v: Variant?) = when(v) {
Variant.Singleton -> "s"
is Variant.Something -> throw AssertionError("")
Variant.Another -> throw AssertionError("")
null -> throw AssertionError("")
}