Raise deprecation level for kotlin.test collection assertions

#KT-21703
This commit is contained in:
Ilya Gorbunov
2018-09-06 05:09:59 +03:00
parent ad76edd7b7
commit f1c3d8b860
2 changed files with 13 additions and 13 deletions
@@ -3,49 +3,49 @@
* that can be found in the license/LICENSE.txt file.
*/
@file:Suppress("DEPRECATION")
@file:Suppress("DEPRECATION_ERROR")
package kotlin.test
import java.util.*
// TODO: Drop in 1.2
// TODO: Drop entirely in 1.4
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.")
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.", level = DeprecationLevel.ERROR)
class CollectionAssertionSession<E, C: Iterable<E>>(val collection: C)
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.")
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.", level = DeprecationLevel.ERROR)
inline fun <E, C: Iterable<E>> assert(collection: C, block: CollectionAssertionSession<E, C>.() -> Unit) {
CollectionAssertionSession(collection).block()
}
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.")
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.", level = DeprecationLevel.ERROR)
fun <C: Collection<*>> CollectionAssertionSession<*, C>.sizeShouldBe(expectedSize: Int, message: String? = null) {
assertEquals(expectedSize, collection.size, message ?: "collection should have size $expectedSize but it is ${collection.size}")
}
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.")
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.", level = DeprecationLevel.ERROR)
fun <T> CollectionAssertionSession<T, *>.elementAtShouldBe(position: Int, expected: T, message: String? = null) {
assertEquals(expected, collection.elementAt(position), message ?: "element at $position should be $expected")
}
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.")
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.", level = DeprecationLevel.ERROR)
fun <T, C: Iterable<T>> CollectionAssertionSession<T, C>.elementAtShouldComply(position: Int, message: String? = null, predicate: (T) -> Boolean) {
assertTrue(message) { predicate(collection.elementAt(position)) }
}
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.")
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.", level = DeprecationLevel.ERROR)
fun <T> CollectionAssertionSession<T, *>.lastElementShouldBe(expected: T, message: String? = null) {
assertEquals(expected, collection.last(), message ?: "the last element should be $expected")
}
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.")
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.", level = DeprecationLevel.ERROR)
fun <T> CollectionAssertionSession<T, *>.containsAll(vararg elements: T) {
for (e in elements) {
assertTrue(message = "Element $e is missing in the collection") { e in collection }
}
}
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.")
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.", level = DeprecationLevel.ERROR)
fun <T, C: Iterable<T>> CollectionAssertionSession<T, C>.shouldBe(expectedElements: Iterable<T>, message: String? = null) {
val actual = collection.iterator()
val expected = expectedElements.iterator()
@@ -62,7 +62,7 @@ fun <T, C: Iterable<T>> CollectionAssertionSession<T, C>.shouldBe(expectedElemen
}
}
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.")
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.", level = DeprecationLevel.ERROR)
fun <T, C: Set<T>> CollectionAssertionSession<T, C>.shouldBeSet(other: Set<T>, message: String? = null) {
for (e in other) {
if (e !in collection) {
@@ -76,7 +76,7 @@ fun <T, C: Set<T>> CollectionAssertionSession<T, C>.shouldBeSet(other: Set<T>, m
}
}
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.")
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.", level = DeprecationLevel.ERROR)
fun <T, C: Set<T>> CollectionAssertionSession<T, C>.shouldBeSet(vararg other: T) {
val otherSet = HashSet<T>()
for (e in other) {
@@ -3,7 +3,7 @@
* that can be found in the license/LICENSE.txt file.
*/
@file:Suppress("DEPRECATION")
@file:Suppress("DEPRECATION_ERROR")
package kotlin.test.tests