added drop(n) and dropWhile(predicates) for KT-2067 - also tail() now returns the usual idea of tail() - namely everything but the head - rather than just the last element. Finally added more test sample code to the kdoc
This commit is contained in:
@@ -302,6 +302,29 @@ class CollectionTest {
|
||||
}
|
||||
}
|
||||
|
||||
test fun drop() {
|
||||
val coll = arrayList("foo", "bar", "abc")
|
||||
assertEquals(arrayList("bar", "abc"), coll.drop(1))
|
||||
assertEquals(arrayList("abc"), coll.drop(2))
|
||||
}
|
||||
|
||||
test fun dropWhile() {
|
||||
val coll = arrayList("foo", "bar", "abc")
|
||||
assertEquals(arrayList("bar", "abc"), coll.dropWhile{ it.startsWith("f") })
|
||||
}
|
||||
|
||||
test fun take() {
|
||||
val coll = arrayList("foo", "bar", "abc")
|
||||
assertEquals(arrayList("foo"), coll.take(1))
|
||||
assertEquals(arrayList("foo", "bar"), coll.take(2))
|
||||
}
|
||||
|
||||
test fun takeWhile() {
|
||||
val coll = arrayList("foo", "bar", "abc")
|
||||
assertEquals(arrayList("foo"), coll.takeWhile{ it.startsWith("f") })
|
||||
assertEquals(arrayList("foo", "bar", "abc"), coll.takeWhile{ it.size == 3 })
|
||||
}
|
||||
|
||||
test fun toArray() {
|
||||
val data = arrayList("foo", "bar")
|
||||
val arr = data.toArray()
|
||||
|
||||
Reference in New Issue
Block a user