Get rid of deprecated annotations and modifiers in stdlib (besides JS)

This commit is contained in:
Denis Zharkov
2015-09-14 16:35:30 +03:00
parent 9c4564a5a6
commit 5cecaa6f87
133 changed files with 1203 additions and 1085 deletions
+22 -11
View File
@@ -14,27 +14,32 @@ class OrderingTest {
val v1 = Item("wine", 9)
val v2 = Item("beer", 10)
Test fun compareByCompareTo() {
@Test
fun compareByCompareTo() {
val diff = v1.compareTo(v2)
assertTrue(diff < 0)
}
Test fun compareByNameFirst() {
@Test
fun compareByNameFirst() {
val diff = compareValuesBy(v1, v2, { it.name }, { it.rating })
assertTrue(diff > 0)
}
Test fun compareByRatingFirst() {
@Test
fun compareByRatingFirst() {
val diff = compareValuesBy(v1, v2, { it.rating }, { it.name })
assertTrue(diff < 0)
}
Test fun compareSameObjectsByRatingFirst() {
@Test
fun compareSameObjectsByRatingFirst() {
val diff = compareValuesBy(v1, v1, { it.rating }, { it.name })
assertTrue(diff == 0)
}
Test fun compareNullables() {
@Test
fun compareNullables() {
val v1: Item? = this.v1
val v2: Item? = null
val diff = compareValuesBy(v1, v2) { it?.rating }
@@ -43,7 +48,8 @@ class OrderingTest {
assertTrue(diff2 < 0)
}
Test fun sortComparatorThenComparator() {
@Test
fun sortComparatorThenComparator() {
val comparator = comparator<Item> { a, b -> a.name.compareTo(b.name) } thenComparator { a, b -> a.rating.compareTo(b.rating) }
val diff = comparator.compare(v1, v2)
@@ -53,7 +59,8 @@ class OrderingTest {
assertEquals(v1, items[1])
}
Test fun combineComparators() {
@Test
fun combineComparators() {
val byName = compareBy<Item> { it.name }
val byRating = compareBy<Item> { it.rating }
val v3 = Item(v1.name, v1.rating + 1)
@@ -67,7 +74,8 @@ class OrderingTest {
assertTrue( (byRating thenDescending byName).compare(v4, v2) < 0 )
}
Test fun sortByThenBy() {
@Test
fun sortByThenBy() {
val comparator = compareBy<Item> { it.rating } thenBy { it.name }
val diff = comparator.compare(v1, v2)
@@ -77,7 +85,8 @@ class OrderingTest {
assertEquals(v2, items[1])
}
Test fun sortByThenByDescending() {
@Test
fun sortByThenByDescending() {
val comparator = compareBy<Item> { it.rating } thenByDescending { it.name }
val diff = comparator.compare(v1, v2)
@@ -87,7 +96,8 @@ class OrderingTest {
assertEquals(v2, items[1])
}
Test fun sortUsingFunctionalComparator() {
@Test
fun sortUsingFunctionalComparator() {
val comparator = compareBy<Item>({ it.name }, { it.rating })
val diff = comparator.compare(v1, v2)
assertTrue(diff > 0)
@@ -96,7 +106,8 @@ class OrderingTest {
assertEquals(v1, items[1])
}
Test fun sortUsingCustomComparator() {
@Test
fun sortUsingCustomComparator() {
val comparator = object : Comparator<Item> {
override fun compare(o1: Item, o2: Item): Int {
return compareValuesBy(o1, o2, { it.name }, { it.rating })