Introduce T.addTo(MutableCollection<T>), mapNotNull and mapIndexedNotNull extensions.

#KT-4410 Fixed
This commit is contained in:
Ilya Gorbunov
2015-11-07 06:50:19 +03:00
parent 008a8059cf
commit 9323f61eaf
10 changed files with 398 additions and 145 deletions
@@ -244,6 +244,16 @@ abstract class IterableTests<T : Iterable<String>>(val data: T, val empty: T) {
assertEquals(listOf("f", "ba"), indexed)
}
@Test
fun mapNotNull() {
assertEquals(listOf('o'), data.mapNotNull { it.firstOrNull { c -> c in "oui" } })
}
@Test
fun mapIndexedNotNull() {
assertEquals(listOf('b'), data.mapIndexedNotNull { index, s -> s.getOrNull(index - 1) })
}
@Test
fun max() {
expect("foo") { data.max() }