Skip to content

Commit

Permalink
Restore the ExperimentalCoroutinesApi markers
Browse files Browse the repository at this point in the history
  • Loading branch information
dkhalanskyjb committed Feb 13, 2023
1 parent 579ab0f commit 9fd86bb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions kotlinx-coroutines-test/common/src/TestBuilders.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import kotlin.time.Duration.Companion.seconds
* * Don't nest functions returning a [TestResult].
*/
@Suppress("NO_ACTUAL_FOR_EXPECT")
@ExperimentalCoroutinesApi
public expect class TestResult

/**
Expand Down Expand Up @@ -152,6 +153,7 @@ public expect class TestResult
*
* @throws IllegalArgumentException if the [context] is invalid. See the [TestScope] constructor docs for details.
*/
@ExperimentalCoroutinesApi
public fun runTest(
context: CoroutineContext = EmptyCoroutineContext,
timeout: Duration = DEFAULT_TIMEOUT,
Expand Down Expand Up @@ -296,6 +298,7 @@ public fun runTest(
/**
* Performs [runTest] on an existing [TestScope]. See the documentation for [runTest] for details.
*/
@ExperimentalCoroutinesApi
public fun TestScope.runTest(
timeout: Duration = DEFAULT_TIMEOUT,
testBody: suspend TestScope.() -> Unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ private class UnconfinedTestDispatcherImpl(
*
* @see UnconfinedTestDispatcher for a dispatcher that is not confined to any particular thread.
*/
@ExperimentalCoroutinesApi
@Suppress("FunctionName")
public fun StandardTestDispatcher(
scheduler: TestCoroutineScheduler? = null,
Expand Down
5 changes: 5 additions & 0 deletions kotlinx-coroutines-test/common/src/TestCoroutineScheduler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import kotlin.time.Duration.Companion.milliseconds
* virtual time as needed (via [advanceUntilIdle]), or run the tasks that are scheduled to run as soon as possible but
* haven't yet been dispatched (via [runCurrent]).
*/
@ExperimentalCoroutinesApi
public class TestCoroutineScheduler : AbstractCoroutineContextElement(TestCoroutineScheduler),
CoroutineContext.Element {

Expand Down Expand Up @@ -112,6 +113,7 @@ public class TestCoroutineScheduler : AbstractCoroutineContextElement(TestCorout
* milliseconds by which the execution of this method has advanced the virtual time. If you want to recreate that
* functionality, query [currentTime] before and after the execution to achieve the same result.
*/
@ExperimentalCoroutinesApi
public fun advanceUntilIdle(): Unit = advanceUntilIdleOr { events.none(TestDispatchEvent<*>::isForeground) }

/**
Expand All @@ -127,6 +129,7 @@ public class TestCoroutineScheduler : AbstractCoroutineContextElement(TestCorout
/**
* Runs the tasks that are scheduled to execute at this moment of virtual time.
*/
@ExperimentalCoroutinesApi
public fun runCurrent() {
val timeMark = synchronized(lock) { currentTime }
while (true) {
Expand Down Expand Up @@ -162,6 +165,7 @@ public class TestCoroutineScheduler : AbstractCoroutineContextElement(TestCorout
*
* @throws IllegalArgumentException if passed a negative [delay][delayTime].
*/
@ExperimentalCoroutinesApi
public fun advanceTimeBy(delayTime: Duration) {
require(!delayTime.isNegative()) { "Can not advance time by a negative delay: $delayTime" }
val startingTime = currentTime
Expand Down Expand Up @@ -218,6 +222,7 @@ public class TestCoroutineScheduler : AbstractCoroutineContextElement(TestCorout
/**
* Returns the [TimeSource] representation of the virtual time of this scheduler.
*/
@ExperimentalCoroutinesApi
@ExperimentalTime
public val timeSource: TimeSource = object : AbstractLongTimeSource(DurationUnit.MILLISECONDS) {
override fun read(): Long = currentTime
Expand Down
2 changes: 2 additions & 0 deletions kotlinx-coroutines-test/common/src/TestDispatcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ import kotlin.jvm.*
* * [UnconfinedTestDispatcher] is a dispatcher that behaves like [Dispatchers.Unconfined] while allowing to control
* the virtual time.
*/
@ExperimentalCoroutinesApi
public abstract class TestDispatcher internal constructor() : CoroutineDispatcher(), Delay {
/** The scheduler that this dispatcher is linked to. */
@ExperimentalCoroutinesApi
public abstract val scheduler: TestCoroutineScheduler

/** Notifies the dispatcher that it should process a single event marked with [marker] happening at time [time]. */
Expand Down
4 changes: 4 additions & 0 deletions kotlinx-coroutines-test/common/src/TestScope.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ import kotlin.time.*
* paused by default, like [StandardTestDispatcher].
* * No access to the list of unhandled exceptions.
*/
@ExperimentalCoroutinesApi
public sealed interface TestScope : CoroutineScope {
/**
* The delay-skipping scheduler used by the test dispatchers running the code in this scope.
*/
@ExperimentalCoroutinesApi
public val testScheduler: TestCoroutineScheduler

/**
Expand Down Expand Up @@ -80,6 +82,7 @@ public sealed interface TestScope : CoroutineScope {
* }
* ```
*/
@ExperimentalCoroutinesApi
public val backgroundScope: CoroutineScope
}

Expand Down Expand Up @@ -163,6 +166,7 @@ public val TestScope.testTimeSource: TimeSource get() = testScheduler.timeSource
* @throws IllegalArgumentException if [context] has an [CoroutineExceptionHandler] that is not an
* [UncaughtExceptionCaptor].
*/
@ExperimentalCoroutinesApi
@Suppress("FunctionName")
public fun TestScope(context: CoroutineContext = EmptyCoroutineContext): TestScope {
val ctxWithDispatcher = context.withDelaySkipping()
Expand Down

0 comments on commit 9fd86bb

Please sign in to comment.