Fix List.takeLast for lists without RandomAccess

This commit is contained in:
Marek Langiewicz
2017-05-01 11:31:47 +02:00
committed by ilya-g
parent 8da4839f22
commit 934b0b8c38
4 changed files with 7 additions and 3 deletions
@@ -579,6 +579,10 @@ class CollectionTest {
assertEquals(coll, coll.takeLast(coll.size + 1))
assertFails { coll.takeLast(-1) }
val collWithoutRandomAccess = object : List<String> by coll {}
assertEquals(listOf("abc"), collWithoutRandomAccess.takeLast(1))
assertEquals(listOf("bar", "abc"), collWithoutRandomAccess.takeLast(2))
}
@Test fun takeLastWhile() {