TupleN classes and their usages replaced by Pair and Triple

(KT-2358 Drop tuples)

 #KT-2358 In Progress
This commit is contained in:
Andrey Breslav
2012-09-07 21:23:38 +04:00
parent 8333448f10
commit 89fd0526cf
18 changed files with 58 additions and 59 deletions
+3 -3
View File
@@ -93,13 +93,13 @@ class CollectionJVMTest {
test fun sortBy() {
expect(arrayList("two" to 2, "three" to 3)) {
arrayList("three" to 3, "two" to 2).sortBy { it._2 }
arrayList("three" to 3, "two" to 2).sortBy { it.second }
}
expect(arrayList("three" to 3, "two" to 2)) {
arrayList("three" to 3, "two" to 2).sortBy { it._1 }
arrayList("three" to 3, "two" to 2).sortBy { it.first }
}
expect(arrayList("two" to 2, "three" to 3)) {
arrayList("three" to 3, "two" to 2).sortBy { it._1.length }
arrayList("three" to 3, "two" to 2).sortBy { it.first.length }
}
}
+2 -2
View File
@@ -38,8 +38,8 @@ class ListTest {
val wis = data.withIndices()
var index = 0
for (withIndex in wis) {
assertEquals(withIndex._1, index)
assertEquals(withIndex._2, data[index])
assertEquals(withIndex.first, index)
assertEquals(withIndex.second, data[index])
index++
}
assertEquals(data.size(), index)
+5 -5
View File
@@ -103,7 +103,7 @@ class MapTest {
}
test fun createUsingTuples() {
val map = hashMap(#("a", 1), #("b", 2))
val map = hashMap(Pair("a", 1), Pair("b", 2))
assertEquals(2, map.size)
assertEquals(1, map.get("a"))
assertEquals(2, map.get("b"))
@@ -117,7 +117,7 @@ class MapTest {
}
test fun createLinkedMap() {
val map = linkedMap(#("c", 3), #("b", 2), #("a", 1))
val map = linkedMap(Pair("c", 3), Pair("b", 2), Pair("a", 1))
assertEquals(1, map.get("a"))
assertEquals(2, map.get("b"))
assertEquals(3, map.get("c"))
@@ -125,7 +125,7 @@ class MapTest {
}
test fun createSortedMap() {
val map = sortedMap(#("c", 3), #("b", 2), #("a", 1))
val map = sortedMap(Pair("c", 3), Pair("b", 2), Pair("a", 1))
assertEquals(1, map.get("a"))
assertEquals(2, map.get("b"))
assertEquals(3, map.get("c"))
@@ -133,7 +133,7 @@ class MapTest {
}
test fun toSortedMap() {
val map = hashMap<String,Int>(#("c", 3), #("b", 2), #("a", 1))
val map = hashMap<String,Int>(Pair("c", 3), Pair("b", 2), Pair("a", 1))
val sorted = map.toSortedMap<String,Int>()
assertEquals(1, sorted.get("a"))
assertEquals(2, sorted.get("b"))
@@ -142,7 +142,7 @@ class MapTest {
}
test fun toSortedMapWithComparator() {
val map = hashMap(#("c", 3), #("bc", 2), #("bd", 4), #("abc", 1))
val map = hashMap(Pair("c", 3), Pair("bc", 2), Pair("bd", 4), Pair("abc", 1))
val c = comparator<String>{ a, b ->
val answer = a.length() - b.length()
if (answer == 0) a.compareTo(b) else answer
@@ -15,7 +15,7 @@ class Serial(val a : String) : java.lang.Object(), Serializable {
class SerialTest() : TestCase() {
fun testMe() {
val tuple = #("lala", "bbb", Serial("serial"))
val tuple = Triple("lala", "bbb", Serial("serial"))
val op = { -> tuple.toString() }
val baos = ByteArrayOutputStream()
+1 -1
View File
@@ -52,7 +52,7 @@ class MapJsTest {
*/
test fun createUsingTuples() {
val map = hashMap(#("a", 1), #("b", 2))
val map = hashMap(Pair("a", 1), Pair("b", 2))
assertEquals(2, map.size)
assertEquals(1, map.get("a"))
assertEquals(2, map.get("b"))