Get rid of deprecated annotations and modifiers in stdlib (besides JS)
This commit is contained in:
@@ -7,14 +7,14 @@ import test.collections.behaviors.*
|
||||
|
||||
class CollectionTest {
|
||||
|
||||
test fun joinTo() {
|
||||
@test fun joinTo() {
|
||||
val data = listOf("foo", "bar")
|
||||
val buffer = StringBuilder()
|
||||
data.joinTo(buffer, "-", "{", "}")
|
||||
assertEquals("{foo-bar}", buffer.toString())
|
||||
}
|
||||
|
||||
test fun join() {
|
||||
@test fun join() {
|
||||
val data = listOf("foo", "bar")
|
||||
val text = data.join("-", "<", ">")
|
||||
assertEquals("<foo-bar>", text)
|
||||
@@ -24,7 +24,7 @@ class CollectionTest {
|
||||
assertEquals("a, b, c, *", text2)
|
||||
}
|
||||
|
||||
test fun filterNotNull() {
|
||||
@test fun filterNotNull() {
|
||||
val data = listOf(null, "foo", null, "bar")
|
||||
val foo = data.filterNotNull()
|
||||
|
||||
@@ -36,7 +36,7 @@ class CollectionTest {
|
||||
}
|
||||
}
|
||||
|
||||
test fun mapNotNull() {
|
||||
@test fun mapNotNull() {
|
||||
val data = listOf(null, "foo", null, "bar")
|
||||
val foo = data.mapNotNull { it.length() }
|
||||
assertEquals(2, foo.size())
|
||||
@@ -47,7 +47,7 @@ class CollectionTest {
|
||||
}
|
||||
}
|
||||
|
||||
test fun listOfNotNull() {
|
||||
@test fun listOfNotNull() {
|
||||
val l1: List<Int> = listOfNotNull(null)
|
||||
assertTrue(l1.isEmpty())
|
||||
|
||||
@@ -59,7 +59,7 @@ class CollectionTest {
|
||||
assertEquals(listOf("value1", "value2"), l3)
|
||||
}
|
||||
|
||||
test fun filterIntoSet() {
|
||||
@test fun filterIntoSet() {
|
||||
val data = listOf("foo", "bar")
|
||||
val foo = data.filterTo(hashSetOf<String>()) { it.startsWith("f") }
|
||||
|
||||
@@ -74,7 +74,7 @@ class CollectionTest {
|
||||
}
|
||||
}
|
||||
|
||||
test fun fold() {
|
||||
@test fun fold() {
|
||||
// lets calculate the sum of some numbers
|
||||
expect(10) {
|
||||
val numbers = listOf(1, 2, 3, 4)
|
||||
@@ -93,7 +93,7 @@ class CollectionTest {
|
||||
}
|
||||
}
|
||||
|
||||
test fun foldWithDifferentTypes() {
|
||||
@test fun foldWithDifferentTypes() {
|
||||
expect(7) {
|
||||
val numbers = listOf("a", "ab", "abc")
|
||||
numbers.fold(1) { a, b -> a + b.length() }
|
||||
@@ -105,49 +105,49 @@ class CollectionTest {
|
||||
}
|
||||
}
|
||||
|
||||
test fun foldWithNonCommutativeOperation() {
|
||||
@test fun foldWithNonCommutativeOperation() {
|
||||
expect(1) {
|
||||
val numbers = listOf(1, 2, 3)
|
||||
numbers.fold(7) { a, b -> a - b }
|
||||
}
|
||||
}
|
||||
|
||||
test fun foldRight() {
|
||||
@test fun foldRight() {
|
||||
expect("1234") {
|
||||
val numbers = listOf(1, 2, 3, 4)
|
||||
numbers.map { it.toString() }.foldRight("") { a, b -> a + b }
|
||||
}
|
||||
}
|
||||
|
||||
test fun foldRightWithDifferentTypes() {
|
||||
@test fun foldRightWithDifferentTypes() {
|
||||
expect("1234") {
|
||||
val numbers = listOf(1, 2, 3, 4)
|
||||
numbers.foldRight("") { a, b -> "" + a + b }
|
||||
}
|
||||
}
|
||||
|
||||
test fun foldRightWithNonCommutativeOperation() {
|
||||
@test fun foldRightWithNonCommutativeOperation() {
|
||||
expect(-5) {
|
||||
val numbers = listOf(1, 2, 3)
|
||||
numbers.foldRight(7) { a, b -> a - b }
|
||||
}
|
||||
}
|
||||
|
||||
test
|
||||
@test
|
||||
fun merge() {
|
||||
expect(listOf("ab", "bc", "cd")) {
|
||||
listOf("a", "b", "c").merge(listOf("b", "c", "d")) { a, b -> a + b }
|
||||
}
|
||||
}
|
||||
|
||||
test
|
||||
@test
|
||||
fun zip() {
|
||||
expect(listOf("a" to "b", "b" to "c", "c" to "d")) {
|
||||
listOf("a", "b", "c").zip(listOf("b", "c", "d"))
|
||||
}
|
||||
}
|
||||
|
||||
test fun partition() {
|
||||
@test fun partition() {
|
||||
val data = listOf("foo", "bar", "something", "xyz")
|
||||
val pair = data.partition { it.length() == 3 }
|
||||
|
||||
@@ -155,7 +155,7 @@ class CollectionTest {
|
||||
assertEquals(listOf("something"), pair.second, "pair.second")
|
||||
}
|
||||
|
||||
test fun reduce() {
|
||||
@test fun reduce() {
|
||||
expect("1234") {
|
||||
val list = listOf("1", "2", "3", "4")
|
||||
list.reduce { a, b -> a + b }
|
||||
@@ -168,7 +168,7 @@ class CollectionTest {
|
||||
}
|
||||
}
|
||||
|
||||
test fun reduceRight() {
|
||||
@test fun reduceRight() {
|
||||
expect("1234") {
|
||||
val list = listOf("1", "2", "3", "4")
|
||||
list.reduceRight { a, b -> a + b }
|
||||
@@ -181,7 +181,7 @@ class CollectionTest {
|
||||
}
|
||||
}
|
||||
|
||||
test fun groupBy() {
|
||||
@test fun groupBy() {
|
||||
val words = listOf("a", "abc", "ab", "def", "abcd")
|
||||
val byLength = words.groupBy { it.length() }
|
||||
assertEquals(4, byLength.size())
|
||||
@@ -197,14 +197,14 @@ class CollectionTest {
|
||||
assertEquals(2, l3.size())
|
||||
}
|
||||
|
||||
test fun plusRanges() {
|
||||
@test fun plusRanges() {
|
||||
val range1 = 1..3
|
||||
val range2 = 4..7
|
||||
val combined = range1 + range2
|
||||
assertEquals((1..7).toList(), combined)
|
||||
}
|
||||
|
||||
test fun mapRanges() {
|
||||
@test fun mapRanges() {
|
||||
val range = 1..3 map { it * 2 }
|
||||
assertEquals(listOf(2, 4, 6), range)
|
||||
}
|
||||
@@ -216,18 +216,18 @@ class CollectionTest {
|
||||
assertEquals(listOf("foo", "bar", "cheese", "wine"), list2)
|
||||
}
|
||||
|
||||
test fun plusElement() = testPlus { it + "cheese" + "wine" }
|
||||
test fun plusCollection() = testPlus { it + listOf("cheese", "wine") }
|
||||
test fun plusArray() = testPlus { it + arrayOf("cheese", "wine") }
|
||||
test fun plusSequence() = testPlus { it + sequenceOf("cheese", "wine") }
|
||||
@test fun plusElement() = testPlus { it + "cheese" + "wine" }
|
||||
@test fun plusCollection() = testPlus { it + listOf("cheese", "wine") }
|
||||
@test fun plusArray() = testPlus { it + arrayOf("cheese", "wine") }
|
||||
@test fun plusSequence() = testPlus { it + sequenceOf("cheese", "wine") }
|
||||
|
||||
test fun plusCollectionBug() {
|
||||
@test fun plusCollectionBug() {
|
||||
val list = listOf("foo", "bar") + listOf("cheese", "wine")
|
||||
assertEquals(listOf("foo", "bar", "cheese", "wine"), list)
|
||||
}
|
||||
|
||||
|
||||
test fun plusAssign() {
|
||||
@test fun plusAssign() {
|
||||
// lets use a mutable variable of readonly list
|
||||
var l: List<String> = listOf("cheese")
|
||||
val lOriginal = l
|
||||
@@ -254,12 +254,12 @@ class CollectionTest {
|
||||
assertEquals(expected_, b.toList())
|
||||
}
|
||||
|
||||
test fun minusElement() = testMinus(expected = listOf("foo", "bar")) { it - "bar" - "zoo" }
|
||||
test fun minusCollection() = testMinus { it - listOf("bar", "zoo") }
|
||||
test fun minusArray() = testMinus { it - arrayOf("bar", "zoo") }
|
||||
test fun minusSequence() = testMinus { it - sequenceOf("bar", "zoo") }
|
||||
@test fun minusElement() = testMinus(expected = listOf("foo", "bar")) { it - "bar" - "zoo" }
|
||||
@test fun minusCollection() = testMinus { it - listOf("bar", "zoo") }
|
||||
@test fun minusArray() = testMinus { it - arrayOf("bar", "zoo") }
|
||||
@test fun minusSequence() = testMinus { it - sequenceOf("bar", "zoo") }
|
||||
|
||||
test fun minusIsEager() {
|
||||
@test fun minusIsEager() {
|
||||
val source = listOf("foo", "bar")
|
||||
val list = arrayListOf<String>()
|
||||
val result = source - list
|
||||
@@ -270,7 +270,7 @@ class CollectionTest {
|
||||
assertEquals(source, result)
|
||||
}
|
||||
|
||||
test fun minusAssign() {
|
||||
@test fun minusAssign() {
|
||||
// lets use a mutable variable of readonly list
|
||||
val data: List<String> = listOf("cheese", "foo", "beer", "cheese", "wine")
|
||||
var l = data
|
||||
@@ -293,7 +293,7 @@ class CollectionTest {
|
||||
|
||||
|
||||
|
||||
test fun requireNoNulls() {
|
||||
@test fun requireNoNulls() {
|
||||
val data = arrayListOf<String?>("foo", "bar")
|
||||
val notNull = data.requireNoNulls()
|
||||
assertEquals(listOf("foo", "bar"), notNull)
|
||||
@@ -308,37 +308,37 @@ class CollectionTest {
|
||||
}
|
||||
}
|
||||
|
||||
test fun reverse() {
|
||||
@test fun reverse() {
|
||||
val data = listOf("foo", "bar")
|
||||
val rev = data.reversed()
|
||||
assertEquals(listOf("bar", "foo"), rev)
|
||||
}
|
||||
|
||||
test fun reverseFunctionShouldReturnReversedCopyForList() {
|
||||
@test fun reverseFunctionShouldReturnReversedCopyForList() {
|
||||
val list: List<Int> = listOf(2, 3, 1)
|
||||
expect(listOf(1, 3, 2)) { list.reversed() }
|
||||
expect(listOf(2, 3, 1)) { list }
|
||||
}
|
||||
|
||||
test fun reverseFunctionShouldReturnReversedCopyForIterable() {
|
||||
@test fun reverseFunctionShouldReturnReversedCopyForIterable() {
|
||||
val iterable: Iterable<Int> = listOf(2, 3, 1)
|
||||
expect(listOf(1, 3, 2)) { iterable.reversed() }
|
||||
expect(listOf(2, 3, 1)) { iterable }
|
||||
}
|
||||
|
||||
|
||||
test fun drop() {
|
||||
@test fun drop() {
|
||||
val coll = listOf("foo", "bar", "abc")
|
||||
assertEquals(listOf("bar", "abc"), coll.drop(1))
|
||||
assertEquals(listOf("abc"), coll.drop(2))
|
||||
}
|
||||
|
||||
test fun dropWhile() {
|
||||
@test fun dropWhile() {
|
||||
val coll = listOf("foo", "bar", "abc")
|
||||
assertEquals(listOf("bar", "abc"), coll.dropWhile { it.startsWith("f") })
|
||||
}
|
||||
|
||||
test fun dropLast() {
|
||||
@test fun dropLast() {
|
||||
val coll = listOf("foo", "bar", "abc")
|
||||
assertEquals(coll, coll.dropLast(0))
|
||||
assertEquals(emptyList<String>(), coll.dropLast(coll.size()))
|
||||
@@ -349,7 +349,7 @@ class CollectionTest {
|
||||
fails { coll.dropLast(-1) }
|
||||
}
|
||||
|
||||
test fun dropLastWhile() {
|
||||
@test fun dropLastWhile() {
|
||||
val coll = listOf("Foo", "bare", "abc" )
|
||||
assertEquals(coll, coll.dropLastWhile { false })
|
||||
assertEquals(listOf<String>(), coll.dropLastWhile { true })
|
||||
@@ -357,7 +357,7 @@ class CollectionTest {
|
||||
assertEquals(listOf("Foo"), coll.dropLastWhile { it.all { it in 'a'..'z' } })
|
||||
}
|
||||
|
||||
test fun take() {
|
||||
@test fun take() {
|
||||
val coll = listOf("foo", "bar", "abc")
|
||||
assertEquals(emptyList<String>(), coll.take(0))
|
||||
assertEquals(listOf("foo"), coll.take(1))
|
||||
@@ -368,7 +368,7 @@ class CollectionTest {
|
||||
fails { coll.take(-1) }
|
||||
}
|
||||
|
||||
test fun takeWhile() {
|
||||
@test fun takeWhile() {
|
||||
val coll = listOf("foo", "bar", "abc")
|
||||
assertEquals(emptyList<String>(), coll.takeWhile { false })
|
||||
assertEquals(coll, coll.takeWhile { true })
|
||||
@@ -376,7 +376,7 @@ class CollectionTest {
|
||||
assertEquals(listOf("foo", "bar", "abc"), coll.takeWhile { it.length() == 3 })
|
||||
}
|
||||
|
||||
test fun takeLast() {
|
||||
@test fun takeLast() {
|
||||
val coll = listOf("foo", "bar", "abc")
|
||||
|
||||
assertEquals(emptyList<String>(), coll.takeLast(0))
|
||||
@@ -388,7 +388,7 @@ class CollectionTest {
|
||||
fails { coll.takeLast(-1) }
|
||||
}
|
||||
|
||||
test fun takeLastWhile() {
|
||||
@test fun takeLastWhile() {
|
||||
val coll = listOf("foo", "bar", "abc")
|
||||
assertEquals(emptyList<String>(), coll.takeLastWhile { false })
|
||||
assertEquals(coll, coll.takeLastWhile { true })
|
||||
@@ -396,7 +396,7 @@ class CollectionTest {
|
||||
assertEquals(listOf("bar", "abc"), coll.takeLastWhile { it[0] < 'c' })
|
||||
}
|
||||
|
||||
test fun copyToArray() {
|
||||
@test fun copyToArray() {
|
||||
val data = listOf("foo", "bar")
|
||||
val arr = data.toTypedArray()
|
||||
println("Got array ${arr}")
|
||||
@@ -408,14 +408,14 @@ class CollectionTest {
|
||||
}
|
||||
}
|
||||
|
||||
test fun count() {
|
||||
@test fun count() {
|
||||
val data = listOf("foo", "bar")
|
||||
assertEquals(2, data.count())
|
||||
assertEquals(3, hashSetOf(12, 14, 15).count())
|
||||
assertEquals(0, ArrayList<Double>().count())
|
||||
}
|
||||
|
||||
test fun first() {
|
||||
@test fun first() {
|
||||
val data = listOf("foo", "bar")
|
||||
assertEquals("foo", data.first())
|
||||
assertEquals(15, listOf(15, 19, 20, 25).first())
|
||||
@@ -423,7 +423,7 @@ class CollectionTest {
|
||||
fails { arrayListOf<Int>().first() }
|
||||
}
|
||||
|
||||
test fun last() {
|
||||
@test fun last() {
|
||||
val data = listOf("foo", "bar")
|
||||
assertEquals("bar", data.last())
|
||||
assertEquals(25, listOf(15, 19, 20, 25).last())
|
||||
@@ -431,7 +431,7 @@ class CollectionTest {
|
||||
fails { arrayListOf<Int>().last() }
|
||||
}
|
||||
|
||||
test fun subscript() {
|
||||
@test fun subscript() {
|
||||
val list = arrayListOf("foo", "bar")
|
||||
assertEquals("foo", list[0])
|
||||
assertEquals("bar", list[1])
|
||||
@@ -454,7 +454,7 @@ class CollectionTest {
|
||||
assertEquals(listOf("new", "thing", "works"), list)
|
||||
}
|
||||
|
||||
test fun indices() {
|
||||
@test fun indices() {
|
||||
val data = listOf("foo", "bar")
|
||||
val indices = data.indices
|
||||
assertEquals(0, indices.start)
|
||||
@@ -462,14 +462,14 @@ class CollectionTest {
|
||||
assertEquals(0..data.size() - 1, indices)
|
||||
}
|
||||
|
||||
test fun contains() {
|
||||
@test fun contains() {
|
||||
assertFalse(hashSetOf<Int>().contains(12))
|
||||
assertTrue(listOf(15, 19, 20).contains(15))
|
||||
|
||||
assertTrue(IterableWrapper(hashSetOf(45, 14, 13)).contains(14))
|
||||
}
|
||||
|
||||
test fun min() {
|
||||
@test fun min() {
|
||||
expect(null, { listOf<Int>().min() })
|
||||
expect(1, { listOf(1).min() })
|
||||
expect(2, { listOf(2, 3).min() })
|
||||
@@ -480,7 +480,7 @@ class CollectionTest {
|
||||
expect(2, { listOf(2, 3).asSequence().min() })
|
||||
}
|
||||
|
||||
test fun max() {
|
||||
@test fun max() {
|
||||
expect(null, { listOf<Int>().max() })
|
||||
expect(1, { listOf(1).max() })
|
||||
expect(3, { listOf(2, 3).max() })
|
||||
@@ -491,7 +491,7 @@ class CollectionTest {
|
||||
expect(3, { listOf(2, 3).asSequence().max() })
|
||||
}
|
||||
|
||||
test fun minBy() {
|
||||
@test fun minBy() {
|
||||
expect(null, { listOf<Int>().minBy { it } })
|
||||
expect(1, { listOf(1).minBy { it } })
|
||||
expect(3, { listOf(2, 3).minBy { -it } })
|
||||
@@ -501,7 +501,7 @@ class CollectionTest {
|
||||
expect(3, { listOf(2, 3).asSequence().minBy { -it } })
|
||||
}
|
||||
|
||||
test fun maxBy() {
|
||||
@test fun maxBy() {
|
||||
expect(null, { listOf<Int>().maxBy { it } })
|
||||
expect(1, { listOf(1).maxBy { it } })
|
||||
expect(2, { listOf(2, 3).maxBy { -it } })
|
||||
@@ -511,7 +511,7 @@ class CollectionTest {
|
||||
expect(2, { listOf(2, 3).asSequence().maxBy { -it } })
|
||||
}
|
||||
|
||||
test fun minByEvaluateOnce() {
|
||||
@test fun minByEvaluateOnce() {
|
||||
var c = 0
|
||||
expect(1, { listOf(5, 4, 3, 2, 1).minBy { c++; it * it } })
|
||||
assertEquals(5, c)
|
||||
@@ -520,7 +520,7 @@ class CollectionTest {
|
||||
assertEquals(5, c)
|
||||
}
|
||||
|
||||
test fun maxByEvaluateOnce() {
|
||||
@test fun maxByEvaluateOnce() {
|
||||
var c = 0
|
||||
expect(5, { listOf(5, 4, 3, 2, 1).maxBy { c++; it * it } })
|
||||
assertEquals(5, c)
|
||||
@@ -529,7 +529,7 @@ class CollectionTest {
|
||||
assertEquals(5, c)
|
||||
}
|
||||
|
||||
test fun sum() {
|
||||
@test fun sum() {
|
||||
expect(0) { arrayListOf<Int>().sum() }
|
||||
expect(14) { listOf(2, 3, 9).sum() }
|
||||
expect(3.0) { listOf(1.0, 2.0).sum() }
|
||||
@@ -538,7 +538,7 @@ class CollectionTest {
|
||||
expect(3.0.toFloat()) { sequenceOf<Float>(1.0.toFloat(), 2.0.toFloat()).sum() }
|
||||
}
|
||||
|
||||
test fun average() {
|
||||
@test fun average() {
|
||||
expect(0.0) { arrayListOf<Int>().average() }
|
||||
expect(3.8) { listOf(1, 2, 5, 8, 3).average() }
|
||||
expect(2.1) { sequenceOf(1.6, 2.6, 3.6, 0.6).average() }
|
||||
@@ -548,7 +548,7 @@ class CollectionTest {
|
||||
expect(n.toDouble()/2) { range.average() }
|
||||
}
|
||||
|
||||
test fun takeReturnsFirstNElements() {
|
||||
@test fun takeReturnsFirstNElements() {
|
||||
expect(listOf(1, 2, 3, 4, 5)) { (1..10) take 5 }
|
||||
expect(listOf(1, 2, 3, 4, 5)) { (1..10).toList().take(5) }
|
||||
expect(listOf(1, 2)) { (1..10) take 2 }
|
||||
@@ -559,18 +559,18 @@ class CollectionTest {
|
||||
expect(listOf(1)) { listOf(1) take 10 }
|
||||
}
|
||||
|
||||
test fun sorted() {
|
||||
@test fun sorted() {
|
||||
assertEquals(listOf(1, 3, 7), listOf(3, 7, 1).sorted())
|
||||
assertEquals(listOf(7, 3, 1), listOf(3, 7, 1).sortedDescending())
|
||||
}
|
||||
|
||||
test fun sortedBy() {
|
||||
@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").sortedByDescending { it.length() })
|
||||
}
|
||||
|
||||
test fun sortedNullableBy() {
|
||||
@test fun sortedNullableBy() {
|
||||
fun String.nullIfEmpty() = if (isEmpty()) null else this
|
||||
listOf(null, "", "a").let {
|
||||
expect(listOf(null, "", "a")) { it.sortedWith(nullsFirst(compareBy { it })) }
|
||||
@@ -579,7 +579,7 @@ class CollectionTest {
|
||||
}
|
||||
}
|
||||
|
||||
test fun sortedByNullable() {
|
||||
@test fun sortedByNullable() {
|
||||
fun String.nonEmptyLength() = if (isEmpty()) null else length()
|
||||
listOf("", "sort", "abc").let {
|
||||
assertEquals(listOf("", "abc", "sort"), it.sortedBy { it.nonEmptyLength() })
|
||||
@@ -588,7 +588,7 @@ class CollectionTest {
|
||||
}
|
||||
}
|
||||
|
||||
test fun sortedWith() {
|
||||
@test fun sortedWith() {
|
||||
val comparator = compareBy<String> { it.toUpperCase().reversed() }
|
||||
val data = listOf("cat", "dad", "BAD")
|
||||
|
||||
@@ -597,18 +597,18 @@ class CollectionTest {
|
||||
expect(listOf("BAD", "dad", "cat")) { data.sortedWith(comparator.reversed().reversed()) }
|
||||
}
|
||||
|
||||
test fun decomposeFirst() {
|
||||
@test fun decomposeFirst() {
|
||||
val (first) = listOf(1, 2)
|
||||
assertEquals(first, 1)
|
||||
}
|
||||
|
||||
test fun decomposeSplit() {
|
||||
@test fun decomposeSplit() {
|
||||
val (key, value) = "key = value".split("=").map { it.trim() }
|
||||
assertEquals(key, "key")
|
||||
assertEquals(value, "value")
|
||||
}
|
||||
|
||||
test fun decomposeList() {
|
||||
@test fun decomposeList() {
|
||||
val (a, b, c, d, e) = listOf(1, 2, 3, 4, 5)
|
||||
assertEquals(a, 1)
|
||||
assertEquals(b, 2)
|
||||
@@ -617,7 +617,7 @@ class CollectionTest {
|
||||
assertEquals(e, 5)
|
||||
}
|
||||
|
||||
test fun decomposeArray() {
|
||||
@test fun decomposeArray() {
|
||||
val (a, b, c, d, e) = arrayOf(1, 2, 3, 4, 5)
|
||||
assertEquals(a, 1)
|
||||
assertEquals(b, 2)
|
||||
@@ -626,7 +626,7 @@ class CollectionTest {
|
||||
assertEquals(e, 5)
|
||||
}
|
||||
|
||||
test fun decomposeIntArray() {
|
||||
@test fun decomposeIntArray() {
|
||||
val (a, b, c, d, e) = intArrayOf(1, 2, 3, 4, 5)
|
||||
assertEquals(a, 1)
|
||||
assertEquals(b, 2)
|
||||
@@ -635,39 +635,39 @@ class CollectionTest {
|
||||
assertEquals(e, 5)
|
||||
}
|
||||
|
||||
test fun unzipList() {
|
||||
@test fun unzipList() {
|
||||
val list = listOf(1 to 'a', 2 to 'b', 3 to 'c')
|
||||
val (ints, chars) = list.unzip()
|
||||
assertEquals(listOf(1, 2, 3), ints)
|
||||
assertEquals(listOf('a', 'b', 'c'), chars)
|
||||
}
|
||||
|
||||
test fun unzipArray() {
|
||||
@test fun unzipArray() {
|
||||
val array = arrayOf(1 to 'a', 2 to 'b', 3 to 'c')
|
||||
val (ints, chars) = array.unzip()
|
||||
assertEquals(listOf(1, 2, 3), ints)
|
||||
assertEquals(listOf('a', 'b', 'c'), chars)
|
||||
}
|
||||
|
||||
test fun specialLists() {
|
||||
@test fun specialLists() {
|
||||
compare(arrayListOf<Int>(), listOf<Int>()) { listBehavior() }
|
||||
compare(arrayListOf<Double>(), emptyList<Double>()) { listBehavior() }
|
||||
compare(arrayListOf("value"), listOf("value")) { listBehavior() }
|
||||
}
|
||||
|
||||
test fun specialSets() {
|
||||
@test fun specialSets() {
|
||||
compare(linkedSetOf<Int>(), setOf<Int>()) { setBehavior() }
|
||||
compare(hashSetOf<Double>(), emptySet<Double>()) { setBehavior() }
|
||||
compare(listOf("value").toMutableSet(), setOf("value")) { setBehavior() }
|
||||
}
|
||||
|
||||
test fun specialMaps() {
|
||||
@test fun specialMaps() {
|
||||
compare(hashMapOf<String, Int>(), mapOf<String, Int>()) { mapBehavior() }
|
||||
compare(linkedMapOf<Int, String>(), emptyMap<Int, String>()) { mapBehavior() }
|
||||
compare(linkedMapOf(2 to 3), mapOf(2 to 3)) { mapBehavior() }
|
||||
}
|
||||
|
||||
test fun toStringTest() {
|
||||
@test fun toStringTest() {
|
||||
// we need toString() inside pattern because of KT-8666
|
||||
assertEquals("[1, a, null, ${Long.MAX_VALUE.toString()}]", listOf(1, "a", null, Long.MAX_VALUE).toString())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user