@@ -11,13 +11,13 @@ import kotlin.coroutines.*
11
11
* A scope which provides detailed control over the execution of coroutines for tests.
12
12
*/
13
13
@ExperimentalCoroutinesApi
14
- public interface TestCoroutineScope : CoroutineScope , UncaughtExceptionCaptor {
14
+ public sealed interface TestCoroutineScope : CoroutineScope , UncaughtExceptionCaptor {
15
15
/* *
16
16
* Call after the test completes.
17
17
* Calls [UncaughtExceptionCaptor.cleanupTestCoroutinesCaptor] and [DelayController.cleanupTestCoroutines].
18
18
*
19
19
* @throws Throwable the first uncaught exception, if there are any uncaught exceptions.
20
- * @throws UncompletedCoroutinesError if any pending tasks are active, however it will not throw for suspended
20
+ * @throws AssertionError if any pending tasks are active, however it will not throw for suspended
21
21
* coroutines.
22
22
*/
23
23
@ExperimentalCoroutinesApi
@@ -28,8 +28,6 @@ public interface TestCoroutineScope: CoroutineScope, UncaughtExceptionCaptor {
28
28
*/
29
29
@ExperimentalCoroutinesApi
30
30
public val testScheduler: TestCoroutineScheduler
31
- get() = coroutineContext[TestCoroutineScheduler ]
32
- ? : throw UnsupportedOperationException (" This scope does not have a TestCoroutineScheduler linked to it" )
33
31
}
34
32
35
33
private class TestCoroutineScopeImpl (
@@ -158,3 +156,9 @@ public fun TestCoroutineScope.resumeDispatcher() {
158
156
private val TestCoroutineScope .delayControllerForPausing: DelayController
159
157
get() = coroutineContext.delayController
160
158
? : throw IllegalStateException (" This scope isn't able to pause its dispatchers" )
159
+
160
+ /* *
161
+ * Thrown when a test has completed and there are tasks that are not completed or cancelled.
162
+ */
163
+ @ExperimentalCoroutinesApi
164
+ internal class UncompletedCoroutinesError (message : String ): AssertionError(message)
0 commit comments