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
@@ -5,7 +5,7 @@ import org.junit.Test as test
class ArraysJVMTest {
test fun orEmptyNull() {
@test fun orEmptyNull() {
val x: Array<String>? = null
val y: Array<out String>? = null
val xArray = x.orEmpty()
@@ -14,7 +14,7 @@ class ArraysJVMTest {
expect(0) { yArray.size() }
}
test fun orEmptyNotNull() {
@test fun orEmptyNotNull() {
val x: Array<String>? = arrayOf("1", "2")
val xArray = x.orEmpty()
expect(2) { xArray.size() }
+67 -67
View File
@@ -17,7 +17,7 @@ fun assertArrayNotSameButEquals(expected: BooleanArray, actual: BooleanArray, me
class ArraysTest {
test fun emptyArrayLastIndex() {
@test fun emptyArrayLastIndex() {
val arr1 = IntArray(0)
assertEquals(-1, arr1.lastIndex)
@@ -25,7 +25,7 @@ class ArraysTest {
assertEquals(-1, arr2.lastIndex)
}
test fun arrayLastIndex() {
@test fun arrayLastIndex() {
val arr1 = intArrayOf(0, 1, 2, 3, 4)
assertEquals(4, arr1.lastIndex)
assertEquals(4, arr1[arr1.lastIndex])
@@ -35,7 +35,7 @@ class ArraysTest {
assertEquals("4", arr2[arr2.lastIndex])
}
test fun byteArray() {
@test fun byteArray() {
val arr = ByteArray(2)
val expected: Byte = 0
@@ -44,7 +44,7 @@ class ArraysTest {
assertEquals(expected, arr[1])
}
test fun shortArray() {
@test fun shortArray() {
val arr = ShortArray(2)
val expected: Short = 0
@@ -53,7 +53,7 @@ class ArraysTest {
assertEquals(expected, arr[1])
}
test fun intArray() {
@test fun intArray() {
val arr = IntArray(2)
assertEquals(arr.size(), 2)
@@ -61,7 +61,7 @@ class ArraysTest {
assertEquals(0, arr[1])
}
test fun longArray() {
@test fun longArray() {
val arr = LongArray(2)
val expected: Long = 0
@@ -70,7 +70,7 @@ class ArraysTest {
assertEquals(expected, arr[1])
}
test fun floatArray() {
@test fun floatArray() {
val arr = FloatArray(2)
val expected: Float = 0.0F
@@ -79,7 +79,7 @@ class ArraysTest {
assertEquals(expected, arr[1])
}
test fun doubleArray() {
@test fun doubleArray() {
val arr = DoubleArray(2)
assertEquals(arr.size(), 2)
@@ -87,7 +87,7 @@ class ArraysTest {
assertEquals(0.0, arr[1])
}
test fun charArray() {
@test fun charArray() {
val arr = CharArray(2)
val expected: Char = '\u0000'
@@ -96,14 +96,14 @@ class ArraysTest {
assertEquals(expected, arr[1])
}
test fun booleanArray() {
@test fun booleanArray() {
val arr = BooleanArray(2)
assertEquals(arr.size(), 2)
assertEquals(false, arr[0])
assertEquals(false, arr[1])
}
test fun min() {
@test fun min() {
expect(null, { arrayOf<Int>().min() })
expect(1, { arrayOf(1).min() })
expect(2, { arrayOf(2, 3).min() })
@@ -112,7 +112,7 @@ class ArraysTest {
expect("a", { arrayOf("a", "b").min() })
}
test fun minInPrimitiveArrays() {
@test fun minInPrimitiveArrays() {
expect(null, { intArrayOf().min() })
expect(1, { intArrayOf(1).min() })
expect(2, { intArrayOf(2, 3).min() })
@@ -124,7 +124,7 @@ class ArraysTest {
expect('a', { charArrayOf('a', 'b').min() })
}
test fun max() {
@test fun max() {
expect(null, { arrayOf<Int>().max() })
expect(1, { arrayOf(1).max() })
expect(3, { arrayOf(2, 3).max() })
@@ -133,7 +133,7 @@ class ArraysTest {
expect("b", { arrayOf("a", "b").max() })
}
test fun maxInPrimitiveArrays() {
@test fun maxInPrimitiveArrays() {
expect(null, { intArrayOf().max() })
expect(1, { intArrayOf(1).max() })
expect(3, { intArrayOf(2, 3).max() })
@@ -145,7 +145,7 @@ class ArraysTest {
expect('b', { charArrayOf('a', 'b').max() })
}
test fun minBy() {
@test fun minBy() {
expect(null, { arrayOf<Int>().minBy { it } })
expect(1, { arrayOf(1).minBy { it } })
expect(3, { arrayOf(2, 3).minBy { -it } })
@@ -153,7 +153,7 @@ class ArraysTest {
expect("b", { arrayOf("b", "abc").minBy { it.length() } })
}
test fun minByInPrimitiveArrays() {
@test fun minByInPrimitiveArrays() {
expect(null, { intArrayOf().minBy { it } })
expect(1, { intArrayOf(1).minBy { it } })
expect(3, { intArrayOf(2, 3).minBy { -it } })
@@ -164,7 +164,7 @@ class ArraysTest {
expect(2.0, { doubleArrayOf(2.0, 3.0).minBy { Math.sqrt(it) } })
}
test fun maxBy() {
@test fun maxBy() {
expect(null, { arrayOf<Int>().maxBy { it } })
expect(1, { arrayOf(1).maxBy { it } })
expect(2, { arrayOf(2, 3).maxBy { -it } })
@@ -172,7 +172,7 @@ class ArraysTest {
expect("abc", { arrayOf("b", "abc").maxBy { it.length() } })
}
test fun maxByInPrimitiveArrays() {
@test fun maxByInPrimitiveArrays() {
expect(null, { intArrayOf().maxBy { it } })
expect(1, { intArrayOf(1).maxBy { it } })
expect(2, { intArrayOf(2, 3).maxBy { -it } })
@@ -183,29 +183,29 @@ class ArraysTest {
expect(3.0, { doubleArrayOf(2.0, 3.0).maxBy { Math.sqrt(it) } })
}
test fun minIndex() {
@test fun minIndex() {
val a = intArrayOf(1, 7, 9, -42, 54, 93)
expect(3, { a.indices.minBy { a[it] } })
}
test fun maxIndex() {
@test fun maxIndex() {
val a = intArrayOf(1, 7, 9, 239, 54, 93)
expect(3, { a.indices.maxBy { a[it] } })
}
test fun minByEvaluateOnce() {
@test fun minByEvaluateOnce() {
var c = 0
expect(1, { arrayOf(5, 4, 3, 2, 1).minBy { c++; it * it } })
assertEquals(5, c)
}
test fun maxByEvaluateOnce() {
@test fun maxByEvaluateOnce() {
var c = 0
expect(5, { arrayOf(5, 4, 3, 2, 1).maxBy { c++; it * it } })
assertEquals(5, c)
}
test fun sum() {
@test fun sum() {
expect(0) { arrayOf<Int>().sum() }
expect(14) { arrayOf(2, 3, 9).sum() }
expect(3.0) { arrayOf(1.0, 2.0).sum() }
@@ -215,7 +215,7 @@ class ArraysTest {
expect(3.0F) { arrayOf<Float>(1.0F, 2.0F).sum() }
}
test fun sumInPrimitiveArrays() {
@test fun sumInPrimitiveArrays() {
expect(0) { intArrayOf().sum() }
expect(14) { intArrayOf(2, 3, 9).sum() }
expect(3.0) { doubleArrayOf(1.0, 2.0).sum() }
@@ -225,7 +225,7 @@ class ArraysTest {
expect(3.0F) { floatArrayOf(1.0F, 2.0F).sum() }
}
test fun average() {
@test fun average() {
expect(0.0) { arrayOf<Int>().average() }
expect(3.8) { arrayOf(1, 2, 5, 8, 3).average() }
expect(2.1) { arrayOf(1.6, 2.6, 3.6, 0.6).average() }
@@ -236,7 +236,7 @@ class ArraysTest {
// for each arr with size > 0 arr.average() = arr.sum().toDouble() / arr.size()
}
test fun indexOfInPrimitiveArrays() {
@test fun indexOfInPrimitiveArrays() {
expect(-1) { byteArrayOf(1, 2, 3) indexOf 0 }
expect(0) { byteArrayOf(1, 2, 3) indexOf 1 }
expect(1) { byteArrayOf(1, 2, 3) indexOf 2 }
@@ -277,7 +277,7 @@ class ArraysTest {
expect(-1) { booleanArrayOf(true) indexOf false }
}
test fun indexOf() {
@test fun indexOf() {
expect(-1) { arrayOf("cat", "dog", "bird").indexOf("mouse") }
expect(0) { arrayOf("cat", "dog", "bird").indexOf("cat") }
expect(1) { arrayOf("cat", "dog", "bird").indexOf("dog") }
@@ -295,7 +295,7 @@ class ArraysTest {
expect(2) { sequenceOf("cat", "dog", "bird").indexOfFirst { it.endsWith('d') } }
}
test fun lastIndexOf() {
@test fun lastIndexOf() {
expect(-1) { arrayOf("cat", "dog", "bird").lastIndexOf("mouse") }
expect(0) { arrayOf("cat", "dog", "bird").lastIndexOf("cat") }
expect(1) { arrayOf("cat", "dog", "bird").lastIndexOf("dog") }
@@ -315,7 +315,7 @@ class ArraysTest {
expect(3) { sequenceOf("cat", "dog", "bird", "red").indexOfLast { it.endsWith('d') } }
}
test fun isEmpty() {
@test fun isEmpty() {
assertTrue(emptyArray<String>().isEmpty())
assertFalse(arrayOf("").isEmpty())
assertTrue(intArrayOf().isEmpty())
@@ -336,12 +336,12 @@ class ArraysTest {
assertFalse(booleanArrayOf(false).isEmpty())
}
test fun isNotEmpty() {
@test fun isNotEmpty() {
assertFalse(intArrayOf().isNotEmpty())
assertTrue(intArrayOf(1).isNotEmpty())
}
test fun plus() {
@test fun plus() {
assertEquals(listOf("1", "2", "3", "4"), listOf("1", "2") + arrayOf("3", "4"))
assertArrayNotSameButEquals(arrayOf("1", "2", "3"), arrayOf("1", "2") + "3")
assertArrayNotSameButEquals(arrayOf("1", "2", "3", "4"), arrayOf("1", "2") + arrayOf("3", "4"))
@@ -351,7 +351,7 @@ class ArraysTest {
assertArrayNotSameButEquals(intArrayOf(1, 2, 3, 4), intArrayOf(1, 2) + intArrayOf(3, 4))
}
test fun plusVararg() {
@test fun plusVararg() {
fun stringOnePlus(vararg a: String) = arrayOf("1") + a
fun longOnePlus(vararg a: Long) = longArrayOf(1) + a
fun intOnePlus(vararg a: Int) = intArrayOf(1) + a
@@ -361,7 +361,7 @@ class ArraysTest {
assertArrayNotSameButEquals(longArrayOf(1, 2), longOnePlus(2), "LongArray.plus")
}
test fun plusAssign() {
@test fun plusAssign() {
// lets use a mutable variable
var result = arrayOf("a")
result += "foo"
@@ -370,23 +370,23 @@ class ArraysTest {
assertArrayNotSameButEquals(arrayOf("a", "foo", "beer", "cheese", "wine"), result)
}
test fun first() {
@test fun first() {
expect(1) { arrayOf(1, 2, 3).first() }
expect(2) { arrayOf(1, 2, 3).first { it % 2 == 0 } }
}
test fun last() {
@test fun last() {
expect(3) { arrayOf(1, 2, 3).last() }
expect(2) { arrayOf(1, 2, 3).last { it % 2 == 0 } }
}
test fun contains() {
@test fun contains() {
assertTrue(arrayOf("1", "2", "3", "4").contains("2"))
assertTrue("3" in arrayOf("1", "2", "3", "4"))
assertTrue("0" !in arrayOf("1", "2", "3", "4"))
}
test fun slice() {
@test fun slice() {
val iter: Iterable<Int> = listOf(3, 1, 2)
assertEquals(listOf("B"), arrayOf("A", "B", "C").slice(1..1))
@@ -403,7 +403,7 @@ class ArraysTest {
assertEquals(listOf(true, false, true), booleanArrayOf(true, false, true, true).slice(iter))
}
test fun sliceArray() {
@test fun sliceArray() {
val coll: Collection<Int> = listOf(3, 1, 2)
assertArrayNotSameButEquals(arrayOf("B"), arrayOf("A", "B", "C").sliceArray(1..1))
@@ -420,7 +420,7 @@ class ArraysTest {
assertArrayNotSameButEquals(booleanArrayOf(true, false, true), booleanArrayOf(true, false, true, true).sliceArray(coll))
}
test fun asIterable() {
@test fun asIterable() {
val arr1 = intArrayOf(1, 2, 3, 4, 5)
val iter1 = arr1.asIterable()
assertEquals(arr1.toList(), iter1.toList())
@@ -442,7 +442,7 @@ class ArraysTest {
assertEquals(iter4.toList(), emptyList<String>())
}
test fun asList() {
@test fun asList() {
assertEquals(listOf(1, 2, 3), intArrayOf(1, 2, 3).asList())
assertEquals(listOf<Byte>(1, 2, 3), byteArrayOf(1, 2, 3).asList())
assertEquals(listOf(true, false), booleanArrayOf(true, false).asList())
@@ -457,7 +457,7 @@ class ArraysTest {
assertEquals(10, intsAsList[1], "Should reflect changes in original array")
}
test fun toPrimitiveArray() {
@test fun toPrimitiveArray() {
val genericArray: Array<Int> = arrayOf(1, 2, 3)
val primitiveArray: IntArray = genericArray.toIntArray()
expect(3) { primitiveArray.size() }
@@ -469,14 +469,14 @@ class ArraysTest {
assertEquals(charList, charArray.asList())
}
test fun toTypedArray() {
@test fun toTypedArray() {
val primitiveArray: LongArray = longArrayOf(1, 2, Long.MAX_VALUE)
val genericArray: Array<Long> = primitiveArray.toTypedArray()
expect(3) { genericArray.size() }
assertEquals(primitiveArray.asList(), genericArray.asList())
}
test fun copyOf() {
@test fun copyOf() {
booleanArrayOf(true, false, true).let { assertArrayNotSameButEquals(it, it.copyOf()) }
byteArrayOf(0, 1, 2, 3, 4, 5).let { assertArrayNotSameButEquals(it, it.copyOf()) }
shortArrayOf(0, 1, 2, 3, 4, 5).let { assertArrayNotSameButEquals(it, it.copyOf()) }
@@ -487,7 +487,7 @@ class ArraysTest {
charArrayOf('0', '1', '2', '3', '4', '5').let { assertArrayNotSameButEquals(it, it.copyOf()) }
}
test fun copyAndResize() {
@test fun copyAndResize() {
assertArrayNotSameButEquals(arrayOf("1", "2"), arrayOf("1", "2", "3").copyOf(2))
assertArrayNotSameButEquals(arrayOf("1", "2", null), arrayOf("1", "2").copyOf(3))
@@ -501,7 +501,7 @@ class ArraysTest {
assertArrayNotSameButEquals(charArrayOf('A', 'B', '\u0000'), charArrayOf('A', 'B').copyOf(3))
}
test fun copyOfRange() {
@test fun copyOfRange() {
assertArrayNotSameButEquals(booleanArrayOf(true, false, true), booleanArrayOf(true, false, true, true).copyOfRange(0, 3))
assertArrayNotSameButEquals(byteArrayOf(0, 1, 2), byteArrayOf(0, 1, 2, 3, 4, 5).copyOfRange(0, 3))
assertArrayNotSameButEquals(shortArrayOf(0, 1, 2), shortArrayOf(0, 1, 2, 3, 4, 5).copyOfRange(0, 3))
@@ -514,7 +514,7 @@ class ArraysTest {
test fun reduce() {
@test fun reduce() {
expect(-4) { intArrayOf(1, 2, 3) reduce { a, b -> a - b } }
expect(-4.toLong()) { longArrayOf(1, 2, 3) reduce { a, b -> a - b } }
expect(-4F) { floatArrayOf(1F, 2F, 3F) reduce { a, b -> a - b } }
@@ -530,7 +530,7 @@ class ArraysTest {
} is UnsupportedOperationException)
}
test fun reduceRight() {
@test fun reduceRight() {
expect(2) { intArrayOf(1, 2, 3) reduceRight { a, b -> a - b } }
expect(2.toLong()) { longArrayOf(1, 2, 3) reduceRight { a, b -> a - b } }
expect(2F) { floatArrayOf(1F, 2F, 3F) reduceRight { a, b -> a - b } }
@@ -546,7 +546,7 @@ class ArraysTest {
} is UnsupportedOperationException)
}
test fun reversed() {
@test fun reversed() {
expect(listOf(3, 2, 1)) { intArrayOf(1, 2, 3).reversed() }
expect(listOf<Byte>(3, 2, 1)) { byteArrayOf(1, 2, 3).reversed() }
expect(listOf<Short>(3, 2, 1)) { shortArrayOf(1, 2, 3).reversed() }
@@ -557,7 +557,7 @@ class ArraysTest {
expect(listOf(false, false, true)) { booleanArrayOf(true, false, false).reversed() }
}
test fun reversedArray() {
@test fun reversedArray() {
assertArrayNotSameButEquals(intArrayOf(3, 2, 1), intArrayOf(1, 2, 3).reversedArray())
assertArrayNotSameButEquals(byteArrayOf(3, 2, 1), byteArrayOf(1, 2, 3).reversedArray())
assertArrayNotSameButEquals(shortArrayOf(3, 2, 1), shortArrayOf(1, 2, 3).reversedArray())
@@ -568,7 +568,7 @@ class ArraysTest {
assertArrayNotSameButEquals(booleanArrayOf(false, false, true), booleanArrayOf(true, false, false).reversedArray())
}
test fun drop() {
@test fun drop() {
expect(listOf(1), { intArrayOf(1).drop(0) })
expect(listOf(), { intArrayOf().drop(1) })
expect(listOf(), { intArrayOf(1).drop(1) })
@@ -586,7 +586,7 @@ class ArraysTest {
}
}
test fun dropLast() {
@test fun dropLast() {
expect(listOf(), { intArrayOf().dropLast(1) })
expect(listOf(), { intArrayOf(1).dropLast(1) })
expect(listOf(1), { intArrayOf(1).dropLast(0) })
@@ -604,7 +604,7 @@ class ArraysTest {
}
}
test fun dropWhile() {
@test fun dropWhile() {
expect(listOf(), { intArrayOf().dropWhile { it < 3 } })
expect(listOf(), { intArrayOf(1).dropWhile { it < 3 } })
expect(listOf(3, 1), { intArrayOf(2, 3, 1).dropWhile { it < 3 } })
@@ -618,7 +618,7 @@ class ArraysTest {
expect(listOf("b", "a"), { arrayOf("a", "b", "a").dropWhile { it < "b" } })
}
test fun dropLastWhile() {
@test fun dropLastWhile() {
expect(listOf(), { intArrayOf().dropLastWhile { it < 3 } })
expect(listOf(), { intArrayOf(1).dropLastWhile { it < 3 } })
expect(listOf(2, 3), { intArrayOf(2, 3, 1).dropLastWhile { it < 3 } })
@@ -632,7 +632,7 @@ class ArraysTest {
expect(listOf("a", "b"), { arrayOf("a", "b", "a").dropLastWhile { it < "b" } })
}
test fun take() {
@test fun take() {
expect(listOf(), { intArrayOf().take(1) })
expect(listOf(), { intArrayOf(1).take(0) })
expect(listOf(1), { intArrayOf(1).take(1) })
@@ -650,7 +650,7 @@ class ArraysTest {
}
}
test fun takeLast() {
@test fun takeLast() {
expect(listOf(), { intArrayOf().takeLast(1) })
expect(listOf(), { intArrayOf(1).takeLast(0) })
expect(listOf(1), { intArrayOf(1).takeLast(1) })
@@ -668,7 +668,7 @@ class ArraysTest {
}
}
test fun takeWhile() {
@test fun takeWhile() {
expect(listOf(), { intArrayOf().takeWhile { it < 3 } })
expect(listOf(1), { intArrayOf(1).takeWhile { it < 3 } })
expect(listOf(2), { intArrayOf(2, 3, 1).takeWhile { it < 3 } })
@@ -682,7 +682,7 @@ class ArraysTest {
expect(listOf("a"), { arrayOf("a", "c", "b").takeWhile { it < "c" } })
}
test fun takeLastWhile() {
@test fun takeLastWhile() {
expect(listOf(), { intArrayOf().takeLastWhile { it < 3 } })
expect(listOf(1), { intArrayOf(1).takeLastWhile { it < 3 } })
expect(listOf(1), { intArrayOf(2, 3, 1).takeLastWhile { it < 3 } })
@@ -696,7 +696,7 @@ class ArraysTest {
expect(listOf("b"), { arrayOf("a", "c", "b").takeLastWhile { it < "c" } })
}
test fun filter() {
@test fun filter() {
expect(listOf(), { intArrayOf().filter { it > 2 } })
expect(listOf(), { intArrayOf(1).filter { it > 2 } })
expect(listOf(3), { intArrayOf(2, 3).filter { it > 2 } })
@@ -710,7 +710,7 @@ class ArraysTest {
expect(listOf("b"), { arrayOf("a", "b").filter { it > "a" } })
}
test fun filterNot() {
@test fun filterNot() {
expect(listOf(), { intArrayOf().filterNot { it > 2 } })
expect(listOf(1), { intArrayOf(1).filterNot { it > 2 } })
expect(listOf(2), { intArrayOf(2, 3).filterNot { it > 2 } })
@@ -724,11 +724,11 @@ class ArraysTest {
expect(listOf("a"), { arrayOf("a", "b").filterNot { it > "a" } })
}
test fun filterNotNull() {
@test fun filterNotNull() {
expect(listOf("a"), { arrayOf("a", null).filterNotNull() })
}
test fun asListPrimitives() {
@test fun asListPrimitives() {
// Array of primitives
val arr = intArrayOf(1, 2, 3, 4, 2, 5)
val list = arr.asList()
@@ -760,7 +760,7 @@ class ArraysTest {
assertEquals(IntArray(0).asList(), emptyList<Int>())
}
test fun asListObjects() {
@test fun asListObjects() {
val arr = arrayOf("a", "b", "c", "d", "b", "e")
val list = arr.asList()
@@ -793,7 +793,7 @@ class ArraysTest {
assertEquals(Array(0, { "" }).asList(), emptyList<String>())
}
test fun sort() {
@test fun sort() {
val intArr = intArrayOf(5, 2, 1, 9, 80, Int.MIN_VALUE, Int.MAX_VALUE)
intArr.sort()
assertArrayNotSameButEquals(intArrayOf(Int.MIN_VALUE, 1, 2, 5, 9, 80, Int.MAX_VALUE), intArr)
@@ -811,7 +811,7 @@ class ArraysTest {
assertArrayNotSameButEquals(arrayOf("80", "9", "Foo", "all"), strArr)
}
test fun sorted() {
@test fun sorted() {
assertTrue(arrayOf<Long>().sorted().none())
assertEquals(listOf(1), arrayOf(1).sorted())
@@ -849,14 +849,14 @@ class ArraysTest {
}
}
test fun sortedBy() {
@test fun sortedBy() {
val values = arrayOf("ac", "aD", "aba")
val indices = values.indices.toList().toIntArray()
assertEquals(listOf(1, 2, 0), indices.sortedBy { values[it] })
}
test fun sortedNullableBy() {
@test fun sortedNullableBy() {
fun String.nullIfEmpty() = if (isEmpty()) null else this
arrayOf(null, "").let {
expect(listOf(null, "")) { it.sortedWith(nullsFirst(compareBy { it })) }
@@ -865,7 +865,7 @@ class ArraysTest {
}
}
test fun sortedWith() {
@test fun sortedWith() {
val comparator = compareBy { it: Int -> it % 3 }.thenByDescending { it }
fun arrayData<A, T>(array: A, comparator: Comparator<T>) = ArraySortedChecker<A, T>(array, comparator)
@@ -20,7 +20,7 @@ class CollectionJVMTest {
private data class IdentityData(public val value: Int)
test fun removeAllWithDifferentEquality() {
@test fun removeAllWithDifferentEquality() {
val data = listOf(IdentityData(1), IdentityData(1))
val list = data.toArrayList()
list -= identitySetOf(data[0]) as Iterable<IdentityData>
@@ -35,7 +35,7 @@ class CollectionJVMTest {
assertTrue(set3.isEmpty(), "Array doesn't have contains, equality contains is used instead")
}
test fun flatMap() {
@test fun flatMap() {
val data = listOf("", "foo", "bar", "x", "")
val characters = data.flatMap { it.toCharList() }
println("Got list of characters ${characters}")
@@ -45,7 +45,7 @@ class CollectionJVMTest {
}
test fun filterIntoLinkedList() {
@test fun filterIntoLinkedList() {
val data = listOf("foo", "bar")
val foo = data.filterTo(linkedListOf<String>()) { it.startsWith("f") }
@@ -60,7 +60,7 @@ class CollectionJVMTest {
}
}
test fun filterNotIntoLinkedListOf() {
@test fun filterNotIntoLinkedListOf() {
val data = listOf("foo", "bar")
val foo = data.filterNotTo(linkedListOf<String>()) { it.startsWith("f") }
@@ -75,7 +75,7 @@ class CollectionJVMTest {
}
}
test fun filterNotNullIntoLinkedListOf() {
@test fun filterNotNullIntoLinkedListOf() {
val data = listOf(null, "foo", null, "bar")
val foo = data.filterNotNullTo(linkedListOf<String>())
@@ -87,7 +87,7 @@ class CollectionJVMTest {
}
}
test fun filterIntoSortedSet() {
@test fun filterIntoSortedSet() {
val data = listOf("foo", "bar")
val sorted = data.filterTo(sortedSetOf<String>()) { it.length() == 3 }
assertEquals(2, sorted.size())
@@ -97,26 +97,26 @@ class CollectionJVMTest {
}
}
test fun first() {
@test fun first() {
assertEquals(19, TreeSet(listOf(90, 47, 19)).first())
}
test fun last() {
@test fun last() {
val data = listOf("foo", "bar")
assertEquals("bar", data.last())
assertEquals(25, listOf(15, 19, 20, 25).last())
assertEquals('a', linkedListOf('a').last())
}
test fun lastException() {
@test fun lastException() {
fails { linkedListOf<String>().last() }
}
test fun contains() {
@test fun contains() {
assertTrue(linkedListOf(15, 19, 20).contains(15))
}
test fun toArray() {
@test fun toArray() {
val data = listOf("foo", "bar")
val arr = data.toTypedArray()
println("Got array ${arr}")
@@ -128,11 +128,11 @@ class CollectionJVMTest {
}
}
test fun takeReturnsFirstNElements() {
@test fun takeReturnsFirstNElements() {
expect(setOf(1, 2)) { sortedSetOf(1, 2, 3, 4, 5).take(2).toSet() }
}
test fun filterIsInstanceList() {
@test fun filterIsInstanceList() {
val values: List<Any> = listOf(1, 2, 3.toDouble(), "abc", "cde")
val intValues: List<Int> = values.filterIsInstance<Int>()
@@ -151,7 +151,7 @@ class CollectionJVMTest {
assertEquals(0, charValues.size())
}
test fun filterIsInstanceArray() {
@test fun filterIsInstanceArray() {
val src: Array<Any> = arrayOf(1, 2, 3.toDouble(), "abc", "cde")
val intValues: List<Int> = src.filterIsInstance<Int>()
@@ -170,11 +170,11 @@ class CollectionJVMTest {
assertEquals(0, charValues.size())
}
test fun emptyListIsSerializable() = testSingletonSerialization(emptyList<Any>())
@test fun emptyListIsSerializable() = testSingletonSerialization(emptyList<Any>())
test fun emptySetIsSerializable() = testSingletonSerialization(emptySet<Any>())
@test fun emptySetIsSerializable() = testSingletonSerialization(emptySet<Any>())
test fun emptyMapIsSerializable() = testSingletonSerialization(emptyMap<Any, Any>())
@test fun emptyMapIsSerializable() = testSingletonSerialization(emptyMap<Any, Any>())
private fun testSingletonSerialization(value: Any) {
val result = serializeAndDeserialize(value)
@@ -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())
}
@@ -22,33 +22,38 @@ class ListTest : OrderedIterableTests<List<String>>(listOf("foo", "bar"), listOf
class ArrayListTest : OrderedIterableTests<ArrayList<String>>(arrayListOf("foo", "bar"), arrayListOf<String>())
abstract class OrderedIterableTests<T : Iterable<String>>(data: T, empty: T) : IterableTests<T>(data, empty) {
Test fun indexOf() {
@Test
fun indexOf() {
expect(0) { data.indexOf("foo") }
expect(-1) { empty.indexOf("foo") }
expect(1) { data.indexOf("bar") }
expect(-1) { data.indexOf("zap") }
}
Test fun lastIndexOf() {
@Test
fun lastIndexOf() {
expect(0) { data.lastIndexOf("foo") }
expect(-1) { empty.lastIndexOf("foo") }
expect(1) { data.lastIndexOf("bar") }
expect(-1) { data.lastIndexOf("zap") }
}
Test fun indexOfFirst() {
@Test
fun indexOfFirst() {
expect(-1) { data.indexOfFirst { it.contains("p") } }
expect(0) { data.indexOfFirst { it.startsWith('f') } }
expect(-1) { empty.indexOfFirst { it.startsWith('f') } }
}
Test fun indexOfLast() {
@Test
fun indexOfLast() {
expect(-1) { data.indexOfLast { it.contains("p") } }
expect(1) { data.indexOfLast { it.length() == 3 } }
expect(-1) { empty.indexOfLast { it.startsWith('f') } }
}
Test fun elementAt() {
@Test
fun elementAt() {
expect("foo") { data.elementAt(0) }
expect("bar") { data.elementAt(1) }
fails { data.elementAt(2) }
@@ -64,7 +69,8 @@ abstract class OrderedIterableTests<T : Iterable<String>>(data: T, empty: T) : I
}
Test fun first() {
@Test
fun first() {
expect("foo") { data.first() }
fails {
data.first { it.startsWith("x") }
@@ -75,7 +81,8 @@ abstract class OrderedIterableTests<T : Iterable<String>>(data: T, empty: T) : I
expect("foo") { data.first { it.startsWith("f") } }
}
Test fun firstOrNull() {
@Test
fun firstOrNull() {
expect(null) { data.firstOrNull { it.startsWith("x") } }
expect(null) { empty.firstOrNull() }
@@ -83,7 +90,8 @@ abstract class OrderedIterableTests<T : Iterable<String>>(data: T, empty: T) : I
assertEquals("foo", f)
}
Test fun last() {
@Test
fun last() {
assertEquals("bar", data.last())
fails {
data.last { it.startsWith("x") }
@@ -94,7 +102,8 @@ abstract class OrderedIterableTests<T : Iterable<String>>(data: T, empty: T) : I
expect("foo") { data.last { it.startsWith("f") } }
}
Test fun lastOrNull() {
@Test
fun lastOrNull() {
expect(null) { data.lastOrNull { it.startsWith("x") } }
expect(null) { empty.lastOrNull() }
expect("foo") { data.lastOrNull { it.startsWith("f") } }
@@ -102,7 +111,8 @@ abstract class OrderedIterableTests<T : Iterable<String>>(data: T, empty: T) : I
}
abstract class IterableTests<T : Iterable<String>>(val data: T, val empty: T) {
Test fun any() {
@Test
fun any() {
expect(true) { data.any() }
expect(false) { empty.any() }
expect(true) { data.any { it.startsWith("f") } }
@@ -110,13 +120,15 @@ abstract class IterableTests<T : Iterable<String>>(val data: T, val empty: T) {
expect(false) { empty.any { it.startsWith("x") } }
}
Test fun all() {
@Test
fun all() {
expect(true) { data.all { it.length() == 3 } }
expect(false) { data.all { it.startsWith("b") } }
expect(true) { empty.all { it.startsWith("b") } }
}
Test fun none() {
@Test
fun none() {
expect(false) { data.none() }
expect(true) { empty.none() }
expect(false) { data.none { it.length() == 3 } }
@@ -125,7 +137,8 @@ abstract class IterableTests<T : Iterable<String>>(val data: T, val empty: T) {
expect(true) { empty.none { it.startsWith("b") } }
}
Test fun filter() {
@Test
fun filter() {
val foo = data.filter { it.startsWith("f") }
expect(true) { foo is List<String> }
expect(true) { foo.all { it.startsWith("f") } }
@@ -133,7 +146,8 @@ abstract class IterableTests<T : Iterable<String>>(val data: T, val empty: T) {
assertEquals(listOf("foo"), foo)
}
Test fun drop() {
@Test
fun drop() {
val foo = data.drop(1)
expect(true) { foo is List<String> }
expect(true) { foo.all { it.startsWith("b") } }
@@ -141,7 +155,8 @@ abstract class IterableTests<T : Iterable<String>>(val data: T, val empty: T) {
assertEquals(listOf("bar"), foo)
}
Test fun dropWhile() {
@Test
fun dropWhile() {
val foo = data.dropWhile { it[0] == 'f' }
expect(true) { foo is List<String> }
expect(true) { foo.all { it.startsWith("b") } }
@@ -149,7 +164,8 @@ abstract class IterableTests<T : Iterable<String>>(val data: T, val empty: T) {
assertEquals(listOf("bar"), foo)
}
Test fun filterNot() {
@Test
fun filterNot() {
val notFoo = data.filterNot { it.startsWith("f") }
expect(true) { notFoo is List<String> }
expect(true) { notFoo.none { it.startsWith("f") } }
@@ -157,20 +173,23 @@ abstract class IterableTests<T : Iterable<String>>(val data: T, val empty: T) {
assertEquals(listOf("bar"), notFoo)
}
Test fun forEach() {
@Test
fun forEach() {
var count = 0
data.forEach { count += it.length() }
assertEquals(6, count)
}
Test fun contains() {
@Test
fun contains() {
assertTrue(data.contains("foo"))
assertTrue("bar" in data)
assertTrue("baz" !in data)
assertFalse("baz" in empty)
}
Test fun single() {
@Test
fun single() {
fails { data.single() }
fails { empty.single() }
expect("foo") { data.single { it.startsWith("f") } }
@@ -180,7 +199,7 @@ abstract class IterableTests<T : Iterable<String>>(val data: T, val empty: T) {
}
}
Test
@Test
fun singleOrNull() {
expect(null) { data.singleOrNull() }
expect(null) { empty.singleOrNull() }
@@ -191,7 +210,7 @@ abstract class IterableTests<T : Iterable<String>>(val data: T, val empty: T) {
}
}
Test
@Test
fun map() {
val lengths = data.map { it.length() }
assertTrue {
@@ -201,38 +220,38 @@ abstract class IterableTests<T : Iterable<String>>(val data: T, val empty: T) {
assertEquals(listOf(3, 3), lengths)
}
Test
@Test
fun flatten() {
assertEquals(listOf(0, 1, 2, 3, 0, 1, 2, 3), data.map { 0..it.length() }.flatten())
}
Test
@Test
fun mapIndexed() {
val shortened = data.mapIndexed { index, value -> value.substring(0..index) }
assertEquals(2, shortened.size())
assertEquals(listOf("f", "ba"), shortened)
}
Test
@Test
fun withIndex() {
val indexed = data.withIndex().map { it.value.substring(0..it.index) }
assertEquals(2, indexed.size())
assertEquals(listOf("f", "ba"), indexed)
}
Test
@Test
fun max() {
expect("foo") { data.max() }
expect("bar") { data.maxBy { it.last() } }
}
Test
@Test
fun min() {
expect("bar") { data.min() }
expect("foo") { data.minBy { it.last() } }
}
Test
@Test
fun count() {
expect(2) { data.count() }
expect(0) { empty.count() }
@@ -244,7 +263,7 @@ abstract class IterableTests<T : Iterable<String>>(val data: T, val empty: T) {
expect(0) { empty.count { it.startsWith("x") } }
}
Test
@Test
fun sumBy() {
expect(6) { data.sumBy { it.length() } }
expect(0) { empty.sumBy { it.length() } }
@@ -253,7 +272,7 @@ abstract class IterableTests<T : Iterable<String>>(val data: T, val empty: T) {
expect(0.0) { empty.sumByDouble { it.length().toDouble() / 2 } }
}
Test
@Test
fun withIndices() {
var index = 0
for ((i, d) in data.withIndex()) {
@@ -264,19 +283,19 @@ abstract class IterableTests<T : Iterable<String>>(val data: T, val empty: T) {
assertEquals(data.count(), index)
}
Test
@Test
fun fold() {
expect(231) { data.fold(1, { a, b -> a + if (b == "foo") 200 else 30 }) }
}
Test
@Test
fun reduce() {
val reduced = data.reduce { a, b -> a + b }
assertEquals(6, reduced.length())
assertTrue(reduced == "foobar" || reduced == "barfoo")
}
Test
@Test
fun mapAndJoinToString() {
val result = data.joinToString(separator = "-") { it.toUpperCase() }
assertEquals("FOO-BAR", result)
@@ -288,16 +307,16 @@ abstract class IterableTests<T : Iterable<String>>(val data: T, val empty: T) {
assertFalse(result === data)
}
Test
@Test
fun plusElement() = testPlus { it + "zoo" + "g" }
Test
@Test
fun plusCollection() = testPlus { it + listOf("zoo", "g") }
Test
@Test
fun plusArray() = testPlus { it + arrayOf("zoo", "g") }
Test
@Test
fun plusSequence() = testPlus { it + sequenceOf("zoo", "g") }
Test
@Test
fun plusAssign() {
// lets use a mutable variable
var result: Iterable<String> = data
@@ -308,31 +327,31 @@ abstract class IterableTests<T : Iterable<String>>(val data: T, val empty: T) {
assertEquals(listOf("foo", "bar", "foo", "beer", "cheese", "wine", "zoo", "g"), result)
}
Test
@Test
fun minusElement() {
val result = data - "foo" - "g"
assertEquals(listOf("bar"), result)
}
Test
@Test
fun minusCollection() {
val result = data - listOf("foo", "g")
assertEquals(listOf("bar"), result)
}
Test
@Test
fun minusArray() {
val result = data - arrayOf("foo", "g")
assertEquals(listOf("bar"), result)
}
Test
@Test
fun minusSequence() {
val result = data - sequenceOf("foo", "g")
assertEquals(listOf("bar"), result)
}
Test
@Test
fun minusAssign() {
// lets use a mutable variable
var result: Iterable<String> = data
@@ -6,7 +6,7 @@ import java.util.*
class IteratorsJVMTest {
test fun testEnumeration() {
@test fun testEnumeration() {
val v = Vector<Int>()
for (i in 1..5)
v.add(i)
@@ -4,7 +4,7 @@ import kotlin.test.*
import org.junit.Test as test
class IteratorsTest {
test fun iterationOverIterator() {
@test fun iterationOverIterator() {
val c = listOf(0, 1, 2, 3, 4, 5)
var s = ""
for (i in c.iterator()) {
@@ -11,7 +11,8 @@ class ListBinarySearchTest {
val comparator = compareBy<IncomparableDataItem<Int>?> { it?.value }
Test fun binarySearchByElement() {
@Test
fun binarySearchByElement() {
val list = values
list.forEachIndexed { index, item ->
assertEquals(index, list.binarySearch(item))
@@ -25,7 +26,8 @@ class ListBinarySearchTest {
}
}
Test fun binarySearchByElementNullable() {
@Test
fun binarySearchByElementNullable() {
val list = listOf(null) + values
list.forEachIndexed { index, item ->
assertEquals(index, list.binarySearch(item))
@@ -37,7 +39,8 @@ class ListBinarySearchTest {
}
}
Test fun binarySearchWithComparator() {
@Test
fun binarySearchWithComparator() {
val list = values map { IncomparableDataItem(it) }
list.forEachIndexed { index, item ->
@@ -52,7 +55,8 @@ class ListBinarySearchTest {
}
}
Test fun binarySearchByKey() {
@Test
fun binarySearchByKey() {
val list = values map { IncomparableDataItem(it) }
list.forEachIndexed { index, item ->
@@ -68,7 +72,8 @@ class ListBinarySearchTest {
}
Test fun binarySearchByKeyWithComparator() {
@Test
fun binarySearchByKeyWithComparator() {
val list = values map { IncomparableDataItem(IncomparableDataItem(it)) }
list.forEachIndexed { index, item ->
@@ -87,7 +92,8 @@ class ListBinarySearchTest {
}
}
Test fun binarySearchByMultipleKeys() {
@Test
fun binarySearchByMultipleKeys() {
val list = values.flatMap { v1 -> values.map { v2 -> Pair(v1, v2) } }
list.forEachIndexed { index, item ->
@@ -7,17 +7,20 @@ class ListSpecificTest {
val data = listOf("foo", "bar")
val empty = listOf<String>()
Test fun _toString() {
@Test
fun _toString() {
assertEquals("[foo, bar]", data.toString())
}
Test fun tail() {
@Test
fun tail() {
val data = listOf("foo", "bar", "whatnot")
val actual = data.drop(1)
assertEquals(listOf("bar", "whatnot"), actual)
}
Test fun slice() {
@Test
fun slice() {
val list = listOf('A', 'B', 'C', 'D')
// ABCD
// 0123
@@ -28,7 +31,8 @@ class ListSpecificTest {
assertEquals(listOf('C', 'A', 'D'), list.slice(iter))
}
Test fun getOr() {
@Test
fun getOr() {
expect("foo") { data.get(0) }
expect("bar") { data.get(1) }
fails { data.get(2) }
@@ -44,12 +48,14 @@ class ListSpecificTest {
}
Test fun lastIndex() {
@Test
fun lastIndex() {
assertEquals(-1, empty.lastIndex)
assertEquals(1, data.lastIndex)
}
Test fun mutableList() {
@Test
fun mutableList() {
val items = listOf("beverage", "location", "name")
var list = listOf<String>()
@@ -61,7 +67,8 @@ class ListSpecificTest {
assertEquals("beverage,location,name", list.join(","))
}
Test fun testNullToString() {
@Test
fun testNullToString() {
assertEquals("[null]", listOf<String?>(null).toString())
}
}
@@ -6,7 +6,7 @@ import kotlin.test.*
import org.junit.Test as test
class MapJVMTest {
test fun createSortedMap() {
@test fun createSortedMap() {
val map = sortedMapOf(Pair("c", 3), Pair("b", 2), Pair("a", 1))
assertEquals(1, map["a"])
assertEquals(2, map["b"])
@@ -14,7 +14,7 @@ class MapJVMTest {
assertEquals(listOf("a", "b", "c"), map.keySet().toList())
}
test fun toSortedMap() {
@test fun toSortedMap() {
val map = mapOf(Pair("c", 3), Pair("b", 2), Pair("a", 1))
val sorted = map.toSortedMap()
assertEquals(1, sorted["a"])
@@ -23,7 +23,7 @@ class MapJVMTest {
assertEquals(listOf("a", "b", "c"), sorted.keySet().toList())
}
test fun toSortedMapWithComparator() {
@test fun toSortedMapWithComparator() {
val map = mapOf(Pair("c", 3), Pair("bc", 2), Pair("bd", 4), Pair("abc", 1))
val sorted = map.toSortedMap(compareBy<String> { it.length() } thenBy { it })
assertEquals(listOf("c", "bc", "bd", "abc"), sorted.keySet().toList())
@@ -32,7 +32,7 @@ class MapJVMTest {
assertEquals(3, sorted["c"])
}
test fun toProperties() {
@test fun toProperties() {
val map = mapOf("a" to "A", "b" to "B")
val prop = map.toProperties()
assertEquals(2, prop.size())
@@ -40,7 +40,7 @@ class MapJVMTest {
assertEquals("B", prop.getProperty("b", "fail"))
}
test fun getOrPutFailsOnConcurrentMap() {
@test fun getOrPutFailsOnConcurrentMap() {
val map = ConcurrentHashMap<String, Int>()
fails {
+52 -52
View File
@@ -9,7 +9,7 @@ import org.junit.Test as test
class MapTest {
test fun getOrElse() {
@test fun getOrElse() {
val data = mapOf<String, Int>()
val a = data.getOrElse("foo") { 2 }
assertEquals(2, a)
@@ -23,7 +23,7 @@ class MapTest {
assertEquals(null, c)
}
test fun getOrImplicitDefault() {
@test fun getOrImplicitDefault() {
val data: MutableMap<String, Int> = hashMapOf("bar" to 1)
assertTrue(fails { data.getOrImplicitDefault("foo") } is NoSuchElementException)
assertEquals(1, data.getOrImplicitDefault("bar"))
@@ -44,7 +44,7 @@ class MapTest {
assertEquals(42, withReplacedDefault.getOrImplicitDefault("loop"))
}
test fun getOrPut() {
@test fun getOrPut() {
val data = hashMapOf<String, Int>()
val a = data.getOrPut("foo") { 2 }
assertEquals(2, a)
@@ -59,13 +59,13 @@ class MapTest {
assertEquals(null, c)
}
test fun sizeAndEmpty() {
@test fun sizeAndEmpty() {
val data = hashMapOf<String, Int>()
assertTrue { data.none() }
assertEquals(data.size(), 0)
}
test fun setViaIndexOperators() {
@test fun setViaIndexOperators() {
val map = hashMapOf<String, String>()
assertTrue { map.none() }
assertEquals(map.size(), 0)
@@ -77,7 +77,7 @@ class MapTest {
assertEquals("James", map["name"])
}
test fun iterate() {
@test fun iterate() {
val map = mapOf("beverage" to "beer", "location" to "Mells", "name" to "James")
val list = arrayListOf<String>()
for (e in map) {
@@ -89,13 +89,13 @@ class MapTest {
assertEquals("beverage,beer,location,Mells,name,James", list.join(","))
}
test fun stream() {
@test fun stream() {
val map = mapOf("beverage" to "beer", "location" to "Mells", "name" to "James")
val named = map.asSequence().filter { it.key == "name" }.single()
assertEquals("James", named.value)
}
test fun iterateWithProperties() {
@test fun iterateWithProperties() {
val map = mapOf("beverage" to "beer", "location" to "Mells", "name" to "James")
val list = arrayListOf<String>()
for (e in map) {
@@ -107,7 +107,7 @@ class MapTest {
assertEquals("beverage,beer,location,Mells,name,James", list.join(","))
}
test fun iterateWithExtraction() {
@test fun iterateWithExtraction() {
val map = mapOf("beverage" to "beer", "location" to "Mells", "name" to "James")
val list = arrayListOf<String>()
for ((key, value) in map) {
@@ -119,20 +119,20 @@ class MapTest {
assertEquals("beverage,beer,location,Mells,name,James", list.join(","))
}
test fun contains() {
@test fun contains() {
val map = mapOf("a" to 1, "b" to 2)
assertTrue("a" in map)
assertTrue("c" !in map)
}
test fun map() {
@test fun map() {
val m1 = mapOf("beverage" to "beer", "location" to "Mells")
val list = m1.map { it.value + " rocks" }
assertEquals(listOf("beer rocks", "Mells rocks"), list)
}
test fun mapValues() {
@test fun mapValues() {
val m1 = mapOf("beverage" to "beer", "location" to "Mells")
val m2 = m1.mapValues { it.value + "2" }
@@ -140,7 +140,7 @@ class MapTest {
assertEquals("Mells2", m2["location"])
}
test fun mapKeys() {
@test fun mapKeys() {
val m1 = mapOf("beverage" to "beer", "location" to "Mells")
val m2 = m1.mapKeys { it.key + "2" }
@@ -148,21 +148,21 @@ class MapTest {
assertEquals("Mells", m2["location2"])
}
test fun createUsingPairs() {
@test fun createUsingPairs() {
val map = mapOf(Pair("a", 1), Pair("b", 2))
assertEquals(2, map.size())
assertEquals(1, map["a"])
assertEquals(2, map["b"])
}
test fun createFromIterable() {
@test fun createFromIterable() {
val map = listOf(Pair("a", 1), Pair("b", 2)).toMap()
assertEquals(2, map.size())
assertEquals(1, map.get("a"))
assertEquals(2, map.get("b"))
}
test fun createWithSelector() {
@test fun createWithSelector() {
val map = listOf("a", "bb", "ccc").toMap { it.length() }
assertEquals(3, map.size())
assertEquals("a", map.get(1))
@@ -170,14 +170,14 @@ class MapTest {
assertEquals("ccc", map.get(3))
}
test fun createWithSelectorAndOverwrite() {
@test fun createWithSelectorAndOverwrite() {
val map = listOf("aa", "bb", "ccc").toMap { it.length() }
assertEquals(2, map.size())
assertEquals("bb", map.get(2))
assertEquals("ccc", map.get(3))
}
test fun createWithSelectorForKeyAndValue() {
@test fun createWithSelectorForKeyAndValue() {
val map = listOf("a", "bb", "ccc").toMap({ it.length() }, { it.toUpperCase() })
assertEquals(3, map.size())
assertEquals("A", map.get(1))
@@ -185,14 +185,14 @@ class MapTest {
assertEquals("CCC", map.get(3))
}
test fun createUsingTo() {
@test fun createUsingTo() {
val map = mapOf("a" to 1, "b" to 2)
assertEquals(2, map.size())
assertEquals(1, map["a"])
assertEquals(2, map["b"])
}
test fun createLinkedMap() {
@test fun createLinkedMap() {
val map = linkedMapOf(Pair("c", 3), Pair("b", 2), Pair("a", 1))
assertEquals(1, map["a"])
assertEquals(2, map["b"])
@@ -200,7 +200,7 @@ class MapTest {
assertEquals(listOf("c", "b", "a"), map.keySet().toList())
}
test fun filter() {
@test fun filter() {
val map = mapOf(Pair("b", 3), Pair("c", 2), Pair("a", 2))
val filteredByKey = map.filter { it.key == "b" }
assertEquals(1, filteredByKey.size())
@@ -223,7 +223,7 @@ class MapTest {
assertEquals(2, filteredByValue2["a"])
}
test fun any() {
@test fun any() {
val map = mapOf(Pair("b", 3), Pair("c", 2), Pair("a", 2))
assertTrue(map.any())
assertFalse(emptyMap<String, Int>().any())
@@ -235,7 +235,7 @@ class MapTest {
assertFalse(map.any { it.value == 5 })
}
test fun all() {
@test fun all() {
val map = mapOf(Pair("b", 3), Pair("c", 2), Pair("a", 2))
assertTrue(map.all { it.key != "d" })
assertTrue(emptyMap<String, Int>().all { it.key == "d" })
@@ -244,7 +244,7 @@ class MapTest {
assertFalse(map.all { it.value == 2 })
}
test fun countBy() {
@test fun countBy() {
val map = mapOf(Pair("b", 3), Pair("c", 2), Pair("a", 2))
assertEquals(3, map.count())
@@ -255,7 +255,7 @@ class MapTest {
assertEquals(2, filteredByValue)
}
test fun filterNot() {
@test fun filterNot() {
val map = mapOf(Pair("b", 3), Pair("c", 2), Pair("a", 2))
val filteredByKey = map.filterNot { it.key == "b" }
assertEquals(2, filteredByKey.size())
@@ -277,18 +277,18 @@ class MapTest {
assertEquals(3, map["c"])
}
test fun plusAssign() = testPlusAssign {
@test fun plusAssign() = testPlusAssign {
it += "b" to 4
it += "c" to 3
}
test fun plusAssignList() = testPlusAssign { it += listOf("c" to 3, "b" to 4) }
@test fun plusAssignList() = testPlusAssign { it += listOf("c" to 3, "b" to 4) }
test fun plusAssignArray() = testPlusAssign { it += arrayOf("c" to 3, "b" to 4) }
@test fun plusAssignArray() = testPlusAssign { it += arrayOf("c" to 3, "b" to 4) }
test fun plusAssignSequence() = testPlusAssign { it += sequenceOf("c" to 3, "b" to 4) }
@test fun plusAssignSequence() = testPlusAssign { it += sequenceOf("c" to 3, "b" to 4) }
test fun plusAssignMap() = testPlusAssign { it += mapOf("c" to 3, "b" to 4) }
@test fun plusAssignMap() = testPlusAssign { it += mapOf("c" to 3, "b" to 4) }
fun testPlus(doPlus: (Map<String, Int>) -> Map<String, Int>) {
val original = mapOf("A" to 1, "B" to 2)
@@ -299,15 +299,15 @@ class MapTest {
assertEquals(3, extended["C"])
}
test fun plus() = testPlus { it + ("C" to 3) + ("B" to 4) }
@test fun plus() = testPlus { it + ("C" to 3) + ("B" to 4) }
test fun plusList() = testPlus { it + listOf("C" to 3, "B" to 4) }
@test fun plusList() = testPlus { it + listOf("C" to 3, "B" to 4) }
test fun plusArray() = testPlus { it + arrayOf("C" to 3, "B" to 4) }
@test fun plusArray() = testPlus { it + arrayOf("C" to 3, "B" to 4) }
test fun plusSequence() = testPlus { it + sequenceOf("C" to 3, "B" to 4) }
@test fun plusSequence() = testPlus { it + sequenceOf("C" to 3, "B" to 4) }
test fun plusMap() = testPlus { it + mapOf("C" to 3, "B" to 4) }
@test fun plusMap() = testPlus { it + mapOf("C" to 3, "B" to 4) }
fun testMinus(doMinus: (Map<String, Int>) -> Map<String, Int>) {
@@ -316,15 +316,15 @@ class MapTest {
assertEquals("A" to 1, shortened.entrySet().single().toPair())
}
test fun minus() = testMinus { it - "B" - "C" }
@test fun minus() = testMinus { it - "B" - "C" }
test fun minusList() = testMinus { it - listOf("B", "C") }
@test fun minusList() = testMinus { it - listOf("B", "C") }
test fun minusArray() = testMinus { it - arrayOf("B", "C") }
@test fun minusArray() = testMinus { it - arrayOf("B", "C") }
test fun minusSequence() = testMinus { it - sequenceOf("B", "C") }
@test fun minusSequence() = testMinus { it - sequenceOf("B", "C") }
test fun minusSet() = testMinus { it - setOf("B", "C") }
@test fun minusSet() = testMinus { it - setOf("B", "C") }
@@ -334,16 +334,16 @@ class MapTest {
assertEquals("A" to 1, original.entrySet().single().toPair())
}
test fun minusAssign() = testMinusAssign {
@test fun minusAssign() = testMinusAssign {
it -= "B"
it -= "C"
}
test fun minusAssignList() = testMinusAssign { it -= listOf("B", "C") }
@test fun minusAssignList() = testMinusAssign { it -= listOf("B", "C") }
test fun minusAssignArray() = testMinusAssign { it -= arrayOf("B", "C") }
@test fun minusAssignArray() = testMinusAssign { it -= arrayOf("B", "C") }
test fun minusAssignSequence() = testMinusAssign { it -= sequenceOf("B", "C") }
@test fun minusAssignSequence() = testMinusAssign { it -= sequenceOf("B", "C") }
fun testIdempotent(operation: (Map<String, Int>) -> Map<String, Int>) {
@@ -359,17 +359,17 @@ class MapTest {
}
test fun plusEmptyList() = testIdempotent { it + listOf() }
test fun minusEmptyList() = testIdempotent { it - listOf() }
@test fun plusEmptyList() = testIdempotent { it + listOf() }
@test fun minusEmptyList() = testIdempotent { it - listOf() }
test fun plusEmptySet() = testIdempotent { it + setOf() }
test fun minusEmptySet() = testIdempotent { it - setOf() }
@test fun plusEmptySet() = testIdempotent { it + setOf() }
@test fun minusEmptySet() = testIdempotent { it - setOf() }
test fun plusAssignEmptyList() = testIdempotentAssign { it += listOf() }
test fun minusAssignEmptyList() = testIdempotentAssign { it -= listOf() }
@test fun plusAssignEmptyList() = testIdempotentAssign { it += listOf() }
@test fun minusAssignEmptyList() = testIdempotentAssign { it -= listOf() }
test fun plusAssignEmptySet() = testIdempotentAssign { it += setOf() }
test fun minusAssignEmptySet() = testIdempotentAssign { it -= setOf() }
@test fun plusAssignEmptySet() = testIdempotentAssign { it += setOf() }
@test fun minusAssignEmptySet() = testIdempotentAssign { it -= setOf() }
}
@@ -10,7 +10,7 @@ class MutableCollectionTest {
// TODO: Use apply scope function
test fun addAll() {
@test fun addAll() {
val data = listOf("foo", "bar")
fun assertAdd(f: MutableList<String>.() -> Unit) = assertEquals(data, arrayListOf<String>().let { it.f(); it })
@@ -21,7 +21,7 @@ class MutableCollectionTest {
assertAdd { addAll(data.asSequence()) }
}
test fun removeAll() {
@test fun removeAll() {
val content = arrayOf("foo", "bar", "bar")
val data = listOf("bar")
val expected = listOf("foo")
@@ -35,7 +35,7 @@ class MutableCollectionTest {
}
test fun retainAll() {
@test fun retainAll() {
val content = arrayOf("foo", "bar", "bar")
val data = listOf("bar")
val expected = listOf("bar", "bar")
@@ -25,7 +25,7 @@ import org.junit.Test as test
*/
class ReversedViewsJVMTest {
test fun testMutableSubList() {
@test fun testMutableSubList() {
val original = arrayListOf(1, 2, 3, 4)
val reversedSubList = original.asReversed().subList(1, 3)
@@ -26,11 +26,11 @@ import org.junit.Test as test
class ReversedViewsTest {
test fun testNullToString() {
@test fun testNullToString() {
assertEquals("[null]", listOf<String?>(null).asReversed().toString())
}
test fun testBehavior() {
@test fun testBehavior() {
val original = listOf(2L, 3L, Long.MAX_VALUE)
val reversed = original.reversed()
compare(reversed, original.asReversed()) {
@@ -38,12 +38,12 @@ class ReversedViewsTest {
}
}
test fun testSimple() {
@test fun testSimple() {
assertEquals(listOf(3, 2, 1), listOf(1, 2, 3).asReversed())
assertEquals(listOf(3, 2, 1), listOf(1, 2, 3).asReversed().toList())
}
test fun testRandomAccess() {
@test fun testRandomAccess() {
val reversed = listOf(1, 2, 3).asReversed()
assertEquals(3, reversed[0])
@@ -51,40 +51,40 @@ class ReversedViewsTest {
assertEquals(1, reversed[2])
}
test fun testDoubleReverse() {
@test fun testDoubleReverse() {
assertEquals(listOf(1, 2, 3), listOf(1, 2, 3).asReversed().asReversed())
assertEquals(listOf(2, 3), listOf(1, 2, 3, 4).asReversed().subList(1, 3).asReversed())
}
test fun testEmpty() {
@test fun testEmpty() {
assertEquals(emptyList<Int>(), emptyList<Int>().asReversed())
}
test fun testReversedSubList() {
@test fun testReversedSubList() {
val reversed = (1..10).toList().asReversed()
assertEquals(listOf(9, 8, 7), reversed.subList(1, 4))
}
test fun testMutableSimple() {
@test fun testMutableSimple() {
assertEquals(listOf(3, 2, 1), arrayListOf(1, 2, 3).asReversed())
assertEquals(listOf(3, 2, 1), arrayListOf(1, 2, 3).asReversed().toList())
}
test fun testMutableDoubleReverse() {
@test fun testMutableDoubleReverse() {
assertEquals(listOf(1, 2, 3), arrayListOf(1, 2, 3).asReversed().asReversed())
assertEquals(listOf(2, 3), arrayListOf(1, 2, 3, 4).asReversed().subList(1, 3).asReversed())
}
test fun testMutableEmpty() {
@test fun testMutableEmpty() {
assertEquals(emptyList<Int>(), arrayListOf<Int>().asReversed())
}
test fun testMutableReversedSubList() {
@test fun testMutableReversedSubList() {
val reversed = (1..10).toArrayList().asReversed()
assertEquals(listOf(9, 8, 7), reversed.subList(1, 4))
}
test fun testMutableAdd() {
@test fun testMutableAdd() {
val original = arrayListOf(1, 2, 3)
val reversed = original.asReversed()
@@ -97,7 +97,7 @@ class ReversedViewsTest {
assertEquals(listOf(0, 1, 2, 3, 4), original)
}
test fun testMutableSet() {
@test fun testMutableSet() {
val original = arrayListOf(1, 2, 3)
val reversed = original.asReversed()
@@ -109,7 +109,7 @@ class ReversedViewsTest {
assertEquals(listOf(300, 200, 100), reversed)
}
test fun testMutableRemove() {
@test fun testMutableRemove() {
val original = arrayListOf("a", "b", "c")
val reversed = original.asReversed()
@@ -124,7 +124,7 @@ class ReversedViewsTest {
assertEquals(emptyList<String>(), original)
}
test fun testMutableRemoveByObj() {
@test fun testMutableRemoveByObj() {
val original = arrayListOf("a", "b", "c")
val reversed = original.asReversed()
@@ -133,7 +133,7 @@ class ReversedViewsTest {
assertEquals(listOf("b", "a"), reversed)
}
test fun testMutableClear() {
@test fun testMutableClear() {
val original = arrayListOf(1, 2, 3)
val reversed = original.asReversed()
@@ -143,17 +143,17 @@ class ReversedViewsTest {
assertEquals(emptyList<Int>(), original)
}
test fun testContains() {
@test fun testContains() {
assertTrue { 1 in listOf(1, 2, 3).asReversed() }
assertTrue { 1 in arrayListOf(1, 2, 3).asReversed() }
}
test fun testIndexOf() {
@test fun testIndexOf() {
assertEquals(2, listOf(1, 2, 3).asReversed().indexOf(1))
assertEquals(2, arrayListOf(1, 2, 3).asReversed().indexOf(1))
}
test fun testBidirectionalModifications() {
@test fun testBidirectionalModifications() {
val original = arrayListOf(1, 2, 3, 4)
val reversed = original.asReversed()
@@ -166,7 +166,7 @@ class ReversedViewsTest {
assertEquals(listOf(3, 2), reversed)
}
test fun testGetIOOB() {
@test fun testGetIOOB() {
val success = try {
listOf(1, 2, 3).asReversed().get(3)
true
@@ -177,7 +177,7 @@ class ReversedViewsTest {
assertFalse(success)
}
test fun testSetIOOB() {
@test fun testSetIOOB() {
val success = try {
arrayListOf(1, 2, 3).asReversed().set(3, 0)
true
@@ -188,7 +188,7 @@ class ReversedViewsTest {
assertFalse(success)
}
test fun testAddIOOB() {
@test fun testAddIOOB() {
val success = try {
arrayListOf(1, 2, 3).asReversed().add(4, 0)
true
@@ -199,7 +199,7 @@ class ReversedViewsTest {
assertFalse(success)
}
test fun testRemoveIOOB() {
@test fun testRemoveIOOB() {
val success = try {
arrayListOf(1, 2, 3).asReversed().remove(3)
true
@@ -5,7 +5,7 @@ import kotlin.test.assertEquals
class SequenceJVMTest {
test fun filterIsInstance() {
@test fun filterIsInstance() {
val src: Sequence<Any> = listOf(1, 2, 3.toDouble(), "abc", "cde").asSequence()
val intValues: Sequence<Int> = src.filterIsInstance<Int>()
@@ -19,20 +19,20 @@ fun fibonacci(): Sequence<Int> {
public class SequenceTest {
test fun filterEmptySequence() {
@test fun filterEmptySequence() {
for (sequence in listOf(emptySequence<String>(), sequenceOf<String>())) {
assertEquals(0, sequence.filter { false }.count())
assertEquals(0, sequence.filter { true }.count())
}
}
test fun mapEmptySequence() {
@test fun mapEmptySequence() {
for (sequence in listOf(emptySequence<String>(), sequenceOf<String>())) {
assertEquals(0, sequence.map { true }.count())
}
}
test fun requireNoNulls() {
@test fun requireNoNulls() {
val sequence = sequenceOf<String?>("foo", "bar")
val notNull = sequence.requireNoNulls()
assertEquals(listOf("foo", "bar"), notNull.toList())
@@ -45,25 +45,25 @@ public class SequenceTest {
}
}
test fun filterNullable() {
@test fun filterNullable() {
val data = sequenceOf(null, "foo", null, "bar")
val filtered = data.filter { it == null || it == "foo" }
assertEquals(listOf(null, "foo", null), filtered.toList())
}
test fun filterNot() {
@test fun filterNot() {
val data = sequenceOf(null, "foo", null, "bar")
val filtered = data.filterNot { it == null }
assertEquals(listOf("foo", "bar"), filtered.toList())
}
test fun filterNotNull() {
@test fun filterNotNull() {
val data = sequenceOf(null, "foo", null, "bar")
val filtered = data.filterNotNull()
assertEquals(listOf("foo", "bar"), filtered.toList())
}
test fun mapNotNull() {
@test fun mapNotNull() {
val data = sequenceOf(null, "foo", null, "bar")
val foo = data.mapNotNull { it.length() }
assertEquals(listOf(3, 3), foo.toList())
@@ -73,60 +73,60 @@ public class SequenceTest {
}
}
test fun mapAndJoinToString() {
@test fun mapAndJoinToString() {
assertEquals("3, 5, 8", fibonacci().withIndex().filter { it.index > 3 }.take(3).joinToString { it.value.toString() })
}
test fun withIndex() {
@test fun withIndex() {
val data = sequenceOf("foo", "bar")
val indexed = data.withIndex().map { it.value.substring(0..it.index) }.toList()
assertEquals(2, indexed.size())
assertEquals(listOf("f", "ba"), indexed)
}
test fun filterAndTakeWhileExtractTheElementsWithinRange() {
@test fun filterAndTakeWhileExtractTheElementsWithinRange() {
assertEquals(listOf(144, 233, 377, 610, 987), fibonacci().filter { it > 100 }.takeWhile { it < 1000 }.toList())
}
test fun foldReducesTheFirstNElements() {
@test fun foldReducesTheFirstNElements() {
val sum = { a: Int, b: Int -> a + b }
assertEquals(listOf(13, 21, 34, 55, 89).fold(0, sum), fibonacci().filter { it > 10 }.take(5).fold(0, sum))
}
test fun takeExtractsTheFirstNElements() {
@test fun takeExtractsTheFirstNElements() {
assertEquals(listOf(0, 1, 1, 2, 3, 5, 8, 13, 21, 34), fibonacci().take(10).toList())
}
test fun mapAndTakeWhileExtractTheTransformedElements() {
@test fun mapAndTakeWhileExtractTheTransformedElements() {
assertEquals(listOf(0, 3, 3, 6, 9, 15), fibonacci().map { it * 3 }.takeWhile { i: Int -> i < 20 }.toList())
}
test fun joinConcatenatesTheFirstNElementsAboveAThreshold() {
@test fun joinConcatenatesTheFirstNElementsAboveAThreshold() {
assertEquals("13, 21, 34, 55, 89, ...", fibonacci().filter { it > 10 }.joinToString(separator = ", ", limit = 5))
}
test fun drop() {
@test fun drop() {
assertEquals("13, 21, 34, 55, 89, 144, 233, 377, 610, 987, ...", fibonacci().drop(7).joinToString(limit = 10))
assertEquals("13, 21, 34, 55, 89, 144, 233, 377, 610, 987, ...", fibonacci().drop(3).drop(4).joinToString(limit = 10))
}
test fun take() {
@test fun take() {
assertEquals("0, 1, 1, 2, 3, 5, 8", fibonacci().take(7).joinToString())
assertEquals("2, 3, 5, 8", fibonacci().drop(3).take(4).joinToString())
}
test fun dropWhile() {
@test fun dropWhile() {
assertEquals("233, 377, 610", fibonacci().dropWhile { it < 200 }.take(3).joinToString(limit = 10))
assertEquals("", sequenceOf(1).dropWhile { it < 200 }.joinToString(limit = 10))
}
test fun merge() {
@test fun merge() {
expect(listOf("ab", "bc", "cd")) {
sequenceOf("a", "b", "c").merge(sequenceOf("b", "c", "d")) { a, b -> a + b }.toList()
}
}
test fun toStringJoinsNoMoreThanTheFirstTenElements() {
@test fun toStringJoinsNoMoreThanTheFirstTenElements() {
assertEquals("0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...", fibonacci().joinToString(limit = 10))
assertEquals("13, 21, 34, 55, 89, 144, 233, 377, 610, 987, ...", fibonacci().filter { it > 10 }.joinToString(limit = 10))
assertEquals("144, 233, 377, 610, 987", fibonacci().filter { it > 100 }.takeWhile { it < 1000 }.joinToString())
@@ -141,12 +141,12 @@ public class SequenceTest {
}
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 plusAssign() {
@test fun plusAssign() {
// lets use a mutable variable
var seq = sequenceOf("a")
seq += "foo"
@@ -163,12 +163,12 @@ public class SequenceTest {
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 minusIsLazyIterated() {
@test fun minusIsLazyIterated() {
val seq = sequenceOf("foo", "bar")
val list = arrayListOf<String>()
val result = seq - list
@@ -179,7 +179,7 @@ public class SequenceTest {
assertEquals(emptyList<String>(), result.toList())
}
test fun minusAssign() {
@test fun minusAssign() {
// lets use a mutable variable of readonly list
val data = sequenceOf("cheese", "foo", "beer", "cheese", "wine")
var l = data
@@ -194,7 +194,7 @@ public class SequenceTest {
test fun iterationOverSequence() {
@test fun iterationOverSequence() {
var s = ""
for (i in sequenceOf(0, 1, 2, 3, 4, 5)) {
s += i.toString()
@@ -202,7 +202,7 @@ public class SequenceTest {
assertEquals("012345", s)
}
test fun sequenceFromFunction() {
@test fun sequenceFromFunction() {
var count = 3
val sequence = sequence {
@@ -218,7 +218,7 @@ public class SequenceTest {
}
}
test fun sequenceFromFunctionWithInitialValue() {
@test fun sequenceFromFunctionWithInitialValue() {
val values = sequence(3) { n -> if (n > 0) n - 1 else null }
val expected = listOf(3, 2, 1, 0)
assertEquals(expected, values.toList())
@@ -226,7 +226,7 @@ public class SequenceTest {
}
test fun sequenceFromIterator() {
@test fun sequenceFromIterator() {
val list = listOf(3, 2, 1, 0)
val iterator = list.iterator()
val sequence = iterator.asSequence()
@@ -236,7 +236,7 @@ public class SequenceTest {
}
}
test fun makeSequenceOneTimeConstrained() {
@test fun makeSequenceOneTimeConstrained() {
val sequence = sequenceOf(1, 2, 3, 4)
sequence.toList()
sequence.toList()
@@ -256,13 +256,13 @@ public class SequenceTest {
return result
}
test fun sequenceExtensions() {
@test fun sequenceExtensions() {
val d = ArrayList<Int>()
sequenceOf(0, 1, 2, 3, 4, 5).takeWhileTo(d, { i -> i < 4 })
assertEquals(4, d.size())
}
test fun flatMapAndTakeExtractTheTransformedElements() {
@test fun flatMapAndTakeExtractTheTransformedElements() {
val expected = listOf(
'3', // fibonacci(4) = 3
'5', // fibonacci(5) = 5
@@ -276,51 +276,51 @@ public class SequenceTest {
assertEquals(expected, fibonacci().drop(4).flatMap { it.toString().asSequence() }.take(10).toList())
}
test fun flatMap() {
@test fun flatMap() {
val result = sequenceOf(1, 2).flatMap { sequenceOf(0..it) }
assertEquals(listOf(0, 1, 0, 1, 2), result.toList())
}
test fun flatMapOnEmpty() {
@test fun flatMapOnEmpty() {
val result = sequenceOf<Int>().flatMap { sequenceOf(0..it) }
assertTrue(result.none())
}
test fun flatMapWithEmptyItems() {
@test fun flatMapWithEmptyItems() {
val result = sequenceOf(1, 2, 4).flatMap { if (it == 2) sequenceOf<Int>() else sequenceOf(it - 1..it) }
assertEquals(listOf(0, 1, 3, 4), result.toList())
}
test fun flatten() {
@test fun flatten() {
val data = sequenceOf(1, 2).map { sequenceOf(0..it) }
assertEquals(listOf(0, 1, 0, 1, 2), data.flatten().toList())
}
test fun distinct() {
@test fun distinct() {
val sequence = fibonacci().dropWhile { it < 10 }.take(20)
assertEquals(listOf(1, 2, 3, 0), sequence.map { it % 4 }.distinct().toList())
}
test fun distinctBy() {
@test fun distinctBy() {
val sequence = fibonacci().dropWhile { it < 10 }.take(20)
assertEquals(listOf(13, 34, 55, 144), sequence.distinctBy { it % 4 }.toList())
}
test fun unzip() {
@test fun unzip() {
val seq = sequenceOf(1 to 'a', 2 to 'b', 3 to 'c')
val (ints, chars) = seq.unzip()
assertEquals(listOf(1, 2, 3), ints)
assertEquals(listOf('a', 'b', 'c'), chars)
}
test fun sorted() {
@test fun sorted() {
sequenceOf(3, 7, 5).let {
it.sorted().iterator().assertSorted { a, b -> a <= b }
it.sortedDescending().iterator().assertSorted { a, b -> a >= b }
}
}
test fun sortedBy() {
@test fun sortedBy() {
sequenceOf("it", "greater", "less").let {
it.sortedBy { 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 }
@@ -332,7 +332,7 @@ public class SequenceTest {
}
}
test fun sortedWith() {
@test fun sortedWith() {
val comparator = compareBy { s: String -> s.reversed() }
assertEquals(listOf("act", "wast", "test"), sequenceOf("act", "test", "wast").sortedWith(comparator).toList())
}
@@ -4,29 +4,29 @@ import kotlin.test.*
import org.junit.Test as test
class SetOperationsTest {
test fun distinct() {
@test fun distinct() {
assertEquals(listOf(1, 3, 5), listOf(1, 3, 3, 1, 5, 1, 3).distinct())
assertTrue(listOf<Int>().distinct().isEmpty())
}
test fun distinctBy() {
@test fun distinctBy() {
assertEquals(listOf("some", "cat", "do"), arrayOf("some", "case", "cat", "do", "dog", "it").distinctBy { it.length() })
assertTrue(charArrayOf().distinctBy { it }.isEmpty())
}
test fun union() {
@test fun union() {
assertEquals(listOf(1, 3, 5), listOf(1, 3).union(listOf(5)).toList())
assertEquals(listOf(1), listOf<Int>().union(listOf(1)).toList())
}
test fun subtract() {
@test fun subtract() {
assertEquals(listOf(1, 3), listOf(1, 3).subtract(listOf(5)).toList())
assertEquals(listOf(1, 3), listOf(1, 3, 5).subtract(listOf(5)).toList())
assertTrue(listOf(1, 3, 5).subtract(listOf(1, 3, 5)).none())
assertTrue(listOf<Int>().subtract(listOf(1)).none())
}
test fun intersect() {
@test fun intersect() {
assertTrue(listOf(1, 3).intersect(listOf(5)).none())
assertEquals(listOf(5), listOf(1, 3, 5).intersect(listOf(5)).toList())
assertEquals(listOf(1, 3, 5), listOf(1, 3, 5).intersect(listOf(1, 3, 5)).toList())
@@ -40,12 +40,12 @@ class SetOperationsTest {
assertEquals(setOf("foo", "bar", "cheese", "wine"), set2)
}
test fun plusElement() = testPlus { it + "bar" + "cheese" + "wine" }
test fun plusCollection() = testPlus { it + listOf("bar", "cheese", "wine") }
test fun plusArray() = testPlus { it + arrayOf("bar", "cheese", "wine") }
test fun plusSequence() = testPlus { it + sequenceOf("bar", "cheese", "wine") }
@test fun plusElement() = testPlus { it + "bar" + "cheese" + "wine" }
@test fun plusCollection() = testPlus { it + listOf("bar", "cheese", "wine") }
@test fun plusArray() = testPlus { it + arrayOf("bar", "cheese", "wine") }
@test fun plusSequence() = testPlus { it + sequenceOf("bar", "cheese", "wine") }
test fun plusAssign() {
@test fun plusAssign() {
// lets use a mutable variable
var set = setOf("a")
val setOriginal = set
@@ -70,9 +70,9 @@ class SetOperationsTest {
assertEquals(setOf("foo"), b)
}
test fun minusElement() = testMinus { 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 { 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") }
}