Minor: improve wording in the deprecation message.
This commit is contained in:
@@ -4,42 +4,42 @@ package kotlin.test
|
|||||||
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@Deprecated("This is an experimental part of API. It may be changed or removed in next releases.")
|
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.")
|
||||||
class CollectionAssertionSession<E, C: Iterable<E>>(val collection: C)
|
class CollectionAssertionSession<E, C: Iterable<E>>(val collection: C)
|
||||||
|
|
||||||
@Deprecated("This is an experimental part of API. It may be changed or removed in next releases.")
|
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.")
|
||||||
inline fun <E, C: Iterable<E>> assert(collection: C, block: CollectionAssertionSession<E, C>.() -> Unit) {
|
inline fun <E, C: Iterable<E>> assert(collection: C, block: CollectionAssertionSession<E, C>.() -> Unit) {
|
||||||
CollectionAssertionSession(collection).block()
|
CollectionAssertionSession(collection).block()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("This is an experimental part of API. It may be changed or removed in next releases.")
|
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.")
|
||||||
fun <C: Collection<*>> CollectionAssertionSession<*, C>.sizeShouldBe(expectedSize: Int, message: String? = null) {
|
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}")
|
assertEquals(expectedSize, collection.size, message ?: "collection should have size $expectedSize but it is ${collection.size}")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("This is an experimental part of API. It may be changed or removed in next releases.")
|
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.")
|
||||||
fun <T> CollectionAssertionSession<T, *>.elementAtShouldBe(position: Int, expected: T, message: String? = null) {
|
fun <T> CollectionAssertionSession<T, *>.elementAtShouldBe(position: Int, expected: T, message: String? = null) {
|
||||||
assertEquals(expected, collection.elementAt(position), message ?: "element at $position should be $expected")
|
assertEquals(expected, collection.elementAt(position), message ?: "element at $position should be $expected")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("This is an experimental part of API. It may be changed or removed in next releases.")
|
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.")
|
||||||
fun <T, C: Iterable<T>> CollectionAssertionSession<T, C>.elementAtShouldComply(position: Int, message: String? = null, predicate: (T) -> Boolean) {
|
fun <T, C: Iterable<T>> CollectionAssertionSession<T, C>.elementAtShouldComply(position: Int, message: String? = null, predicate: (T) -> Boolean) {
|
||||||
assertTrue(message) { predicate(collection.elementAt(position)) }
|
assertTrue(message) { predicate(collection.elementAt(position)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("This is an experimental part of API. It may be changed or removed in next releases.")
|
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.")
|
||||||
fun <T> CollectionAssertionSession<T, *>.lastElementShouldBe(expected: T, message: String? = null) {
|
fun <T> CollectionAssertionSession<T, *>.lastElementShouldBe(expected: T, message: String? = null) {
|
||||||
assertEquals(expected, collection.last(), message ?: "the last element should be $expected")
|
assertEquals(expected, collection.last(), message ?: "the last element should be $expected")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("This is an experimental part of API. It may be changed or removed in next releases.")
|
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.")
|
||||||
fun <T> CollectionAssertionSession<T, *>.containsAll(vararg elements: T) {
|
fun <T> CollectionAssertionSession<T, *>.containsAll(vararg elements: T) {
|
||||||
for (e in elements) {
|
for (e in elements) {
|
||||||
assertTrue(message = "Element $e is missing in the collection") { e in collection }
|
assertTrue(message = "Element $e is missing in the collection") { e in collection }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("This is an experimental part of API. It may be changed or removed in next releases.")
|
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.")
|
||||||
fun <T, C: Iterable<T>> CollectionAssertionSession<T, C>.shouldBe(expectedElements: Iterable<T>, message: String? = null) {
|
fun <T, C: Iterable<T>> CollectionAssertionSession<T, C>.shouldBe(expectedElements: Iterable<T>, message: String? = null) {
|
||||||
val actual = collection.iterator()
|
val actual = collection.iterator()
|
||||||
val expected = expectedElements.iterator()
|
val expected = expectedElements.iterator()
|
||||||
@@ -56,7 +56,7 @@ fun <T, C: Iterable<T>> CollectionAssertionSession<T, C>.shouldBe(expectedElemen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("This is an experimental part of API. It may be changed or removed in next releases.")
|
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.")
|
||||||
fun <T, C: Set<T>> CollectionAssertionSession<T, C>.shouldBeSet(other: Set<T>, message: String? = null) {
|
fun <T, C: Set<T>> CollectionAssertionSession<T, C>.shouldBeSet(other: Set<T>, message: String? = null) {
|
||||||
for (e in other) {
|
for (e in other) {
|
||||||
if (e !in collection) {
|
if (e !in collection) {
|
||||||
@@ -70,7 +70,7 @@ fun <T, C: Set<T>> CollectionAssertionSession<T, C>.shouldBeSet(other: Set<T>, m
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("This is an experimental part of API. It may be changed or removed in next releases.")
|
@Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.")
|
||||||
fun <T, C: Set<T>> CollectionAssertionSession<T, C>.shouldBeSet(vararg other: T) {
|
fun <T, C: Set<T>> CollectionAssertionSession<T, C>.shouldBeSet(vararg other: T) {
|
||||||
val otherSet = HashSet<T>()
|
val otherSet = HashSet<T>()
|
||||||
for (e in other) {
|
for (e in other) {
|
||||||
|
|||||||
Reference in New Issue
Block a user