Rename sortedDescendingBy to sortedByDescending

This commit is contained in:
Ilya Gorbunov
2015-07-27 20:08:44 +03:00
parent 002c3e850f
commit 521e0b679d
5 changed files with 89 additions and 89 deletions
@@ -828,8 +828,8 @@ class ArraysTest {
fun String.nullIfEmpty() = if (isEmpty()) null else this
arrayOf(null, "").let {
expect(listOf(null, "")) { it.sortedBy { it.orEmpty()}}
expect(listOf("", null)) { it.sortedDescendingBy { it.orEmpty() }}
expect(listOf("", null)) { it.sortedDescendingBy { it?.nullIfEmpty() }}
expect(listOf("", null)) { it.sortedByDescending { it.orEmpty() }}
expect(listOf("", null)) { it.sortedByDescending { it?.nullIfEmpty() }}
}
}
@@ -567,15 +567,15 @@ class CollectionTest {
test fun sortedBy() {
assertEquals(listOf("two" to 2, "three" to 3), listOf("three" to 3, "two" to 2).sortedBy { it.second })
assertEquals(listOf("three" to 3, "two" to 2), listOf("three" to 3, "two" to 2).sortedBy { it.first })
assertEquals(listOf("three", "two"), listOf("two", "three").sortedDescendingBy { it.length() })
assertEquals(listOf("three", "two"), listOf("two", "three").sortedByDescending { it.length() })
}
test fun sortedNullableBy() {
fun String.nullIfEmpty() = if (isEmpty()) null else this
listOf(null, "").let {
expect(listOf(null, "")) { it.sortedBy { it.orEmpty()}}
expect(listOf("", null)) { it.sortedDescendingBy { it.orEmpty() }}
expect(listOf("", null)) { it.sortedDescendingBy { it?.nullIfEmpty() }}
expect(listOf("", null)) { it.sortedByDescending { it.orEmpty() }}
expect(listOf("", null)) { it.sortedByDescending { it?.nullIfEmpty() }}
}
}
@@ -323,12 +323,12 @@ public class SequenceTest {
test fun sortedBy() {
sequenceOf("it", "greater", "less").let {
it.sortedBy { it.length() }.iterator().assertSorted { a, b -> compareValuesBy(a, b) { it.length() } <= 0 }
it.sortedDescendingBy { it.length() }.iterator().assertSorted { a, b -> compareValuesBy(a, b) { it.length() } >= 0 }
it.sortedByDescending { it.length() }.iterator().assertSorted { a, b -> compareValuesBy(a, b) { it.length() } >= 0 }
}
sequenceOf('a', 'd', 'c', null).let {
it.sortedBy {it}.iterator().assertSorted { a, b -> compareValues(a, b) <= 0 }
it.sortedDescendingBy {it}.iterator().assertSorted { a, b -> compareValues(a, b) >= 0 }
it.sortedByDescending {it}.iterator().assertSorted { a, b -> compareValues(a, b) >= 0 }
}
}