diff --git a/libraries/kotlin.test/jvm/src/main/kotlin/AsserterLookup.kt b/libraries/kotlin.test/jvm/src/main/kotlin/AsserterLookup.kt index 0c270b5fd29..cd6af8a599b 100644 --- a/libraries/kotlin.test/jvm/src/main/kotlin/AsserterLookup.kt +++ b/libraries/kotlin.test/jvm/src/main/kotlin/AsserterLookup.kt @@ -3,6 +3,7 @@ package kotlin.test import java.util.* import java.util.concurrent.atomic.* import java.util.concurrent.locks.* +import kotlin.concurrent.withLock private val inited = AtomicBoolean() private val lock = ReentrantLock() @@ -43,12 +44,3 @@ private fun initContributorsIfNeeded() { } } } - -private inline fun Lock.withLock(block: () -> Unit) { - lockInterruptibly() - try { - block() - } finally { - unlock() - } -} \ No newline at end of file diff --git a/libraries/kotlin.test/jvm/src/main/kotlin/CollectionAssertions.kt b/libraries/kotlin.test/jvm/src/main/kotlin/CollectionAssertions.kt index 3357f773a30..7d2348413d8 100644 --- a/libraries/kotlin.test/jvm/src/main/kotlin/CollectionAssertions.kt +++ b/libraries/kotlin.test/jvm/src/main/kotlin/CollectionAssertions.kt @@ -19,6 +19,8 @@ package kotlin.test import java.util.* +// TODO: Drop in 1.2 + @Deprecated("This is an experimental part of the API. It may be changed or removed in newer releases.") class CollectionAssertionSession>(val collection: C) @@ -95,60 +97,6 @@ fun > CollectionAssertionSession.shouldBeSet(vararg other: T) shouldBeSet(otherSet) } -private operator fun Iterable.contains(e: T): Boolean { - if (this is Set) { - return contains(e) - } - for (it in this) { - if (it == e) { - return true - } - } - return false -} - -private fun Iterable.last(): T { - if (this is List) { - if (this.isEmpty()) { - throw NoSuchElementException() - } - - return this[size - 1] - } - - val it = iterator() - var result: T = iterator().next() - - while (it.hasNext()) { - result = it.next() - } - - return result -} - -private fun Iterable.elementAt(position: Int): T { - if (position < 0) { - throw IllegalArgumentException("position shouldn't be negative: $position") - } - if (this is List) { - return this[position] - } - - val iterator = iterator() - var idx = 0 - do { - if (!iterator.hasNext()) { - throw IndexOutOfBoundsException("index $position is out of the collection bounds [0; $idx)") - } - val result = iterator.next() - if (idx == position) { - return result - } - - idx++ - } while (true) -} - private fun Iterator.remaining(): List { val result = ArrayList() while (hasNext()) {