Improve onEach templates.

Add new functions to reference API.
Add tests for onEach
  #KT-8220
This commit is contained in:
Ilya Gorbunov
2016-10-01 03:51:59 +03:00
parent 5bde230d4a
commit dc57d69085
10 changed files with 115 additions and 14 deletions
@@ -192,6 +192,17 @@ abstract class IterableTests<T : Iterable<String>>(val data: T, val empty: T) {
assertEquals(6, count)
}
@Test
fun onEach() {
var count = 0
val newData = data.onEach { count += it.length }
assertEquals(6, count)
assertTrue(data === newData)
// static types test
val list: ArrayList<Int> = arrayListOf(1, 2, 3).onEach { }
}
@Test
fun contains() {
assertTrue(data.contains("foo"))