diff --git a/libraries/kotlin.test/shared/src/main/kotlin/kotlin/test/CollectionAssertions.kt b/libraries/kotlin.test/shared/src/main/kotlin/kotlin/test/CollectionAssertions.kt index 12aba09dcd2..28fda34bd5b 100644 --- a/libraries/kotlin.test/shared/src/main/kotlin/kotlin/test/CollectionAssertions.kt +++ b/libraries/kotlin.test/shared/src/main/kotlin/kotlin/test/CollectionAssertions.kt @@ -1,35 +1,45 @@ +@file:Suppress("DEPRECATION") + package kotlin.test import java.util.* +@Deprecated("This is an experimental part of API. It may be changed or removed in next releases.") class CollectionAssertionSession>(val collection: C) +@Deprecated("This is an experimental part of API. It may be changed or removed in next releases.") inline fun > assert(collection: C, block: CollectionAssertionSession.() -> Unit) { CollectionAssertionSession(collection).block() } +@Deprecated("This is an experimental part of API. It may be changed or removed in next releases.") fun > 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 API. It may be changed or removed in next releases.") fun CollectionAssertionSession.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 API. It may be changed or removed in next releases.") fun > CollectionAssertionSession.elementAtShouldComply(position: Int, message: String? = null, predicate: (T) -> Boolean) { assertTrue(message) { predicate(collection.elementAt(position)) } } +@Deprecated("This is an experimental part of API. It may be changed or removed in next releases.") fun CollectionAssertionSession.lastElementShouldBe(expected: T, message: String? = null) { 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.") fun CollectionAssertionSession.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 API. It may be changed or removed in next releases.") fun > CollectionAssertionSession.shouldBe(expectedElements: Iterable, message: String? = null) { val actual = collection.iterator() val expected = expectedElements.iterator() @@ -46,6 +56,7 @@ fun > CollectionAssertionSession.shouldBe(expectedElemen } } +@Deprecated("This is an experimental part of API. It may be changed or removed in next releases.") fun > CollectionAssertionSession.shouldBeSet(other: Set, message: String? = null) { for (e in other) { if (e !in collection) { @@ -59,6 +70,7 @@ fun > CollectionAssertionSession.shouldBeSet(other: Set, m } } +@Deprecated("This is an experimental part of API. It may be changed or removed in next releases.") fun > CollectionAssertionSession.shouldBeSet(vararg other: T) { val otherSet = HashSet() for (e in other) { diff --git a/libraries/kotlin.test/shared/src/test/kotlin/kotlin/test/tests/CollectionAssertionTest.kt b/libraries/kotlin.test/shared/src/test/kotlin/kotlin/test/tests/CollectionAssertionTest.kt index c0f55ed772c..a93c5a3d711 100644 --- a/libraries/kotlin.test/shared/src/test/kotlin/kotlin/test/tests/CollectionAssertionTest.kt +++ b/libraries/kotlin.test/shared/src/test/kotlin/kotlin/test/tests/CollectionAssertionTest.kt @@ -1,3 +1,4 @@ +@file:Suppress("DEPRECATION") package kotlin.test.tests import org.junit.*