singleOrNull methods should never throw exception #KT-5424 Fixed

This commit is contained in:
Ilya Ryzhenkov
2014-07-15 20:59:02 +04:00
committed by Evgeny Gerashchenko
parent d4db837dec
commit 2b6fcc0b7c
3 changed files with 34 additions and 94 deletions
@@ -146,11 +146,11 @@ abstract class IterableTests<T : Iterable<String>>(val data: T, val empty: T) {
Test
fun singleOrNull() {
fails { data.singleOrNull() }
fails { empty.singleOrNull() }
expect(null) { data.singleOrNull() }
expect(null) { empty.singleOrNull() }
expect("foo") { data.singleOrNull { it.startsWith("f") } }
expect("bar") { data.singleOrNull { it.startsWith("b") } }
fails {
expect(null) {
data.singleOrNull { it.length == 3 }
}
}