aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Khalanskiy <Dmitry.Khalanskiy@jetbrains.com>2024-01-05 14:41:26 +0100
committerDmitry Khalanskiy <Dmitry.Khalanskiy@jetbrains.com>2024-01-30 10:31:40 +0100
commit555c65fd77d691c04c04460da756adcc0a9839c9 (patch)
treef70ee01adbbb9debec12782ac5644cb855ab5539
parent08491dc9ac75d148c336a62aaf49ff90aec7b34f (diff)
downloadkotlinx.coroutines-555c65fd77d691c04c04460da756adcc0a9839c9.tar.gz
Separate test facilities into a separate module and clean up
Move the test facilities lying around `kotlinx-coroutines-core` and their reimplementation in `kotlinx-coroutines-test` into a separate module, on which the other modules now depend. This allows us to have internal testing facilities in common code. After the migration, the test facilities were also refactored a bit: * Removed many SUPPRESS directives, * Extracted a lot of code to multiplatform, * Fixed a couple of bugs in TestBase, * etc. Finally, the tests were cleaned up automatically a bit, most notably by replacing `assertTrue(a is T)` with `assertIs`.
-rw-r--r--build.gradle.kts32
-rw-r--r--buildSrc/src/main/kotlin/Projects.kt6
-rw-r--r--buildSrc/src/main/kotlin/configure-compilation-conventions.gradle.kts2
-rw-r--r--integration/kotlinx-coroutines-guava/test/FutureAsDeferredUnhandledCompletionExceptionTest.kt1
-rw-r--r--integration/kotlinx-coroutines-guava/test/ListenableFutureExceptionsTest.kt1
-rw-r--r--integration/kotlinx-coroutines-guava/test/ListenableFutureTest.kt29
-rw-r--r--integration/kotlinx-coroutines-guava/test/ListenableFutureToStringTest.kt1
-rw-r--r--integration/kotlinx-coroutines-play-services/test/TaskTest.kt30
-rw-r--r--integration/kotlinx-coroutines-slf4j/test/MDCContextTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/AbstractCoroutineTest.kt9
-rw-r--r--kotlinx-coroutines-core/common/test/AsyncLazyTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/AsyncTest.kt9
-rw-r--r--kotlinx-coroutines-core/common/test/AtomicCancellationCommonTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/AwaitCancellationTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/AwaitTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/BuilderContractsTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/CancellableContinuationHandlersTest.kt5
-rw-r--r--kotlinx-coroutines-core/common/test/CancellableContinuationTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/CancellableResumeTest.kt17
-rw-r--r--kotlinx-coroutines-core/common/test/CancelledParentAttachTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/CompletableDeferredTest.kt21
-rw-r--r--kotlinx-coroutines-core/common/test/CompletableJobTest.kt9
-rw-r--r--kotlinx-coroutines-core/common/test/CoroutineDispatcherOperatorFunInvokeTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/CoroutineExceptionHandlerTest.kt5
-rw-r--r--kotlinx-coroutines-core/common/test/CoroutineScopeTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/CoroutinesTest.kt5
-rw-r--r--kotlinx-coroutines-core/common/test/DelayDurationTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/DelayTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/DispatchedContinuationTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/ExperimentalDispatchModeTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/FailedJobTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/ImmediateYieldTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/JobExtensionsTest.kt5
-rw-r--r--kotlinx-coroutines-core/common/test/JobStatesTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/JobTest.kt5
-rw-r--r--kotlinx-coroutines-core/common/test/LaunchLazyTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/LimitedParallelismSharedTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/NonCancellableTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/ParentCancellationTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/SupervisorTest.kt3
-rw-r--r--kotlinx-coroutines-core/common/test/TestBase.common.kt105
-rw-r--r--kotlinx-coroutines-core/common/test/UnconfinedTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/UndispatchedResultTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/WithContextTest.kt5
-rw-r--r--kotlinx-coroutines-core/common/test/WithTimeoutDurationTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/WithTimeoutOrNullDurationTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/WithTimeoutOrNullTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/WithTimeoutTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/channels/BasicOperationsTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/channels/BroadcastChannelFactoryTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/channels/BroadcastTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/channels/BufferedBroadcastChannelTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/channels/BufferedChannelTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/channels/ChannelBufferOverflowTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/channels/ChannelFactoryTest.kt21
-rw-r--r--kotlinx-coroutines-core/common/test/channels/ChannelReceiveCatchingTest.kt11
-rw-r--r--kotlinx-coroutines-core/common/test/channels/ChannelUndeliveredElementFailureTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/channels/ChannelUndeliveredElementTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/channels/ChannelsTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/channels/ConflatedBroadcastChannelTest.kt9
-rw-r--r--kotlinx-coroutines-core/common/test/channels/ConflatedChannelTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/channels/ConsumeTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/channels/ProduceConsumeTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/channels/ProduceTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/channels/RendezvousChannelTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/channels/SendReceiveStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/channels/UnlimitedChannelTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/BuildersTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/FlowInvariantsTest.kt2
-rw-r--r--kotlinx-coroutines-core/common/test/flow/IdFlowTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/SafeFlowTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/VirtualTime.kt3
-rw-r--r--kotlinx-coroutines-core/common/test/flow/channels/ChannelBuildersFlowTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/channels/ChannelFlowTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/channels/FlowCallbackTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/internal/FlowScopeTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/BufferConflationTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/BufferTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/CancellableTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/CatchTest.kt11
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/CombineParametersTest.kt (renamed from kotlinx-coroutines-core/common/test/flow/operators/CombineParametersTestBase.kt)7
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/CombineTest.kt18
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/ConflateTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/DebounceTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/DistinctUntilChangedTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/DropTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/DropWhileTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/FilterTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/FilterTrivialTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/FlatMapBaseTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/FlatMapLatestTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/FlatMapMergeBaseTest.kt3
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/FlatMapMergeFastPathTest.kt2
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/FlatMapMergeTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/FlattenConcatTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/FlowContextOptimizationsTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/FlowOnTest.kt2
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/IndexedTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/LintTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/MapNotNullTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/MapTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/MergeTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/OnCompletionTest.kt23
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/OnEachTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/OnEmptyTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/OnStartTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/RetryTest.kt5
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/SampleTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/ScanTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/TakeTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/TakeWhileTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/TimeoutTest.kt3
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/TransformLatestTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/TransformTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/TransformWhileTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/operators/ZipTest.kt26
-rw-r--r--kotlinx-coroutines-core/common/test/flow/sharing/ShareInBufferTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/sharing/ShareInConflationTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/sharing/ShareInFusionTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/sharing/ShareInTest.kt3
-rw-r--r--kotlinx-coroutines-core/common/test/flow/sharing/SharedFlowScenarioTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/sharing/SharedFlowTest.kt3
-rw-r--r--kotlinx-coroutines-core/common/test/flow/sharing/SharingStartedTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/sharing/SharingStartedWhileSubscribedTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/sharing/StateFlowTest.kt3
-rw-r--r--kotlinx-coroutines-core/common/test/flow/sharing/StateInTest.kt3
-rw-r--r--kotlinx-coroutines-core/common/test/flow/terminal/CollectLatestTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/terminal/CountTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/terminal/FirstTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/terminal/FoldTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/terminal/LastTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/terminal/LaunchInTest.kt3
-rw-r--r--kotlinx-coroutines-core/common/test/flow/terminal/ReduceTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/terminal/SingleTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/flow/terminal/ToCollectionTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/selects/SelectBiasTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/selects/SelectBufferedChannelTest.kt3
-rw-r--r--kotlinx-coroutines-core/common/test/selects/SelectDeferredTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/selects/SelectJobTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/selects/SelectLoopTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/selects/SelectMutexTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/selects/SelectOldTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/selects/SelectRendezvousChannelTest.kt3
-rw-r--r--kotlinx-coroutines-core/common/test/selects/SelectTimeoutDurationTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/selects/SelectTimeoutTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/selects/SelectUnlimitedChannelTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/sync/MutexTest.kt1
-rw-r--r--kotlinx-coroutines-core/common/test/sync/SemaphoreTest.kt6
-rw-r--r--kotlinx-coroutines-core/concurrent/test/AbstractDispatcherConcurrencyTest.kt1
-rw-r--r--kotlinx-coroutines-core/concurrent/test/AtomicCancellationTest.kt1
-rw-r--r--kotlinx-coroutines-core/concurrent/test/CommonThreadLocalTest.kt1
-rw-r--r--kotlinx-coroutines-core/concurrent/test/ConcurrentExceptionsStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/concurrent/test/JobStructuredJoinStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/concurrent/test/LimitedParallelismConcurrentTest.kt1
-rw-r--r--kotlinx-coroutines-core/concurrent/test/RunBlockingTest.kt3
-rw-r--r--kotlinx-coroutines-core/concurrent/test/channels/BroadcastChannelSubStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/concurrent/test/channels/ChannelCancelUndeliveredElementStressTest.kt3
-rw-r--r--kotlinx-coroutines-core/concurrent/test/channels/ConflatedBroadcastChannelNotifyStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/concurrent/test/channels/TrySendBlockingTest.kt7
-rw-r--r--kotlinx-coroutines-core/concurrent/test/flow/CombineStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/concurrent/test/flow/FlowCancellationTest.kt1
-rw-r--r--kotlinx-coroutines-core/concurrent/test/flow/StateFlowCommonStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/concurrent/test/flow/StateFlowUpdateCommonTest.kt1
-rw-r--r--kotlinx-coroutines-core/concurrent/test/selects/SelectChannelStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/concurrent/test/selects/SelectMutexStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/concurrent/test/sync/MutexStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/concurrent/test/sync/SemaphoreStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/js/test/PromiseTest.kt3
-rw-r--r--kotlinx-coroutines-core/js/test/TestBase.kt141
-rw-r--r--kotlinx-coroutines-core/jsAndWasmShared/test/ImmediateDispatcherTest.kt2
-rw-r--r--kotlinx-coroutines-core/jsAndWasmShared/test/SetTimeoutDispatcherTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/src/AbstractTimeSource.kt7
-rw-r--r--kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testOfferFromScope.txt4
-rw-r--r--kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testOfferWithContextWrapped.txt4
-rw-r--r--kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testOfferWithCurrentContext.txt4
-rw-r--r--kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testReceiveFromChannel.txt4
-rw-r--r--kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testReceiveFromClosedChannel.txt4
-rw-r--r--kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testSendFromScope.txt4
-rw-r--r--kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testSendToChannel.txt2
-rw-r--r--kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testSendToClosedChannel.txt4
-rw-r--r--kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testEventLoopDispatcher.txt4
-rw-r--r--kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testEventLoopDispatcherSuspending.txt4
-rw-r--r--kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedEventLoopChangedContext.txt4
-rw-r--r--kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedEventLoopChangedContextSuspending.txt4
-rw-r--r--kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedEventLoopDispatcher.txt4
-rw-r--r--kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedEventLoopDispatcherSuspending.txt4
-rw-r--r--kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedUnconfined.txt4
-rw-r--r--kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedUnconfinedChangedContext.txt4
-rw-r--r--kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedUnconfinedChangedContextSuspending.txt4
-rw-r--r--kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedUnconfinedSuspending.txt4
-rw-r--r--kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testUnconfined.txt4
-rw-r--r--kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testUnconfinedSuspending.txt4
-rw-r--r--kotlinx-coroutines-core/jvm/test-resources/stacktraces/select/testSelectCompletedAwait.txt4
-rw-r--r--kotlinx-coroutines-core/jvm/test-resources/stacktraces/select/testSelectJoin.txt4
-rw-r--r--kotlinx-coroutines-core/jvm/test/AbstractLincheckTest.kt2
-rw-r--r--kotlinx-coroutines-core/jvm/test/AsyncJvmTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/AwaitJvmTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/AwaitStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/CancellableContinuationJvmTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/CancellableContinuationResumeCloseStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/CancelledAwaitStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/CoroutinesJvmTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/DebugThreadNameTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/DefaultExecutorStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/DelayJvmTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/DispatcherKeyTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/EventLoopsTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/ExecutorAsCoroutineDispatcherDelayTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/ExecutorsTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/FailFastOnStartTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/FailingCoroutinesMachineryTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/IODispatcherTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/JobActivationStressTest.kt7
-rw-r--r--kotlinx-coroutines-core/jvm/test/JobCancellationExceptionSerializerTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/JobChildStressTest.kt5
-rw-r--r--kotlinx-coroutines-core/jvm/test/JobDisposeStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/JobHandlersUpgradeStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/JobStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/JoinStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/LimitedParallelismStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/LimitedParallelismUnhandledExceptionTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/MemoryFootprintTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/MutexCancellationStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/NoParamAssertionsTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/RejectedExecutionTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/ReusableCancellableContinuationInvariantStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/ReusableCancellableContinuationLeakStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/ReusableCancellableContinuationTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/ReusableContinuationStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/RunBlockingJvmTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/RunInterruptibleStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/RunInterruptibleTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/TestBaseTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/ThreadContextElementRestoreTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/ThreadContextElementTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/ThreadContextMutableCopiesTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/ThreadContextOrderTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/ThreadLocalStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/ThreadLocalTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/UnconfinedConcurrentStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/VirtualTimeSource.kt4
-rw-r--r--kotlinx-coroutines-core/jvm/test/WithDefaultContextTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/WithTimeoutChildDipspatchStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/WithTimeoutOrNullJvmTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/WithTimeoutOrNullThreadDispatchTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/WithTimeoutThreadDispatchTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/channels/ActorLazyTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/channels/ActorTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/channels/BroadcastChannelLeakTest.kt4
-rw-r--r--kotlinx-coroutines-core/jvm/test/channels/BroadcastChannelMultiReceiveStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/channels/BufferedChannelStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/channels/ChannelMemoryLeakStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/channels/ChannelSelectStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/channels/ChannelSendReceiveStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/channels/ChannelUndeliveredElementSelectOldStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/channels/ChannelUndeliveredElementStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/channels/ConflatedChannelCloseStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/channels/DoubleChannelCloseStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/channels/InvokeOnCloseStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/channels/ProduceConsumeJvmTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/channels/SendReceiveJvmStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/channels/SimpleSendReceiveJvmTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/channels/TickerChannelCommonTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/channels/TickerChannelTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/exceptions/CoroutineExceptionHandlerJvmTest.kt9
-rw-r--r--kotlinx-coroutines-core/jvm/test/exceptions/FlowSuppressionTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/exceptions/JobBasicCancellationTest.kt3
-rw-r--r--kotlinx-coroutines-core/jvm/test/exceptions/JobExceptionHandlingTest.kt19
-rw-r--r--kotlinx-coroutines-core/jvm/test/exceptions/JobExceptionsStressTest.kt2
-rw-r--r--kotlinx-coroutines-core/jvm/test/exceptions/JobNestedExceptionsTest.kt14
-rw-r--r--kotlinx-coroutines-core/jvm/test/exceptions/ProduceExceptionsTest.kt5
-rw-r--r--kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryChannelsTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryCustomExceptionsTest.kt11
-rw-r--r--kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryNestedScopesTest.kt9
-rw-r--r--kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryNestedTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryResumeModeTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoverySelectTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryTest.kt18
-rw-r--r--kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryWithTimeoutTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/exceptions/SuppressionTests.kt10
-rw-r--r--kotlinx-coroutines-core/jvm/test/exceptions/WithContextCancellationStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/exceptions/WithContextExceptionHandlingTest.kt9
-rw-r--r--kotlinx-coroutines-core/jvm/test/flow/CallbackFlowTest.kt2
-rw-r--r--kotlinx-coroutines-core/jvm/test/flow/ExceptionTransparencyTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/flow/FirstJvmTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/flow/FlatMapStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/flow/OnCompletionInterceptedReleaseTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/flow/SafeCollectorMemoryLeakTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/flow/SharedFlowStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/flow/SharingReferenceTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/flow/SharingStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/flow/StateFlowCancellabilityTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/flow/StateFlowStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/flow/StateFlowUpdateStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/internal/ConcurrentWeakMapCollectionStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/internal/ConcurrentWeakMapOperationStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/internal/ConcurrentWeakMapTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/internal/FastServiceLoaderTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/internal/LockFreeLinkedListLongStressTest.kt3
-rw-r--r--kotlinx-coroutines-core/jvm/test/internal/LockFreeTaskQueueStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/internal/LockFreeTaskQueueTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/internal/ThreadSafeHeapStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/internal/ThreadSafeHeapTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/jdk8/future/AsFutureTest.kt7
-rw-r--r--kotlinx-coroutines-core/jvm/test/jdk8/future/FutureAsDeferredUnhandledCompletionExceptionTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/jdk8/future/FutureExceptionsTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/jdk8/future/FutureTest.kt9
-rw-r--r--kotlinx-coroutines-core/jvm/test/jdk8/stream/ConsumeAsFlowTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/jdk8/time/DurationOverflowTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/jdk8/time/FlowDebounceTest.kt3
-rw-r--r--kotlinx-coroutines-core/jvm/test/jdk8/time/FlowSampleTest.kt3
-rw-r--r--kotlinx-coroutines-core/jvm/test/jdk8/time/WithTimeoutTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/knit/ClosedAfterGuideTestExecutor.kt10
-rw-r--r--kotlinx-coroutines-core/jvm/test/knit/TestUtil.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/lincheck/ChannelsLincheckTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/lincheck/SemaphoreLincheckTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherLivenessStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherMixedStealingStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherTerminationStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherThreadLimitStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherWorkSignallingStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/scheduling/CoroutineDispatcherTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerCloseStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerInternalApiStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerLivenessStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerOversubscriptionTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/scheduling/DefaultDispatchersTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/scheduling/LimitingCoroutineDispatcherStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/scheduling/LimitingDispatcherTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/scheduling/SchedulerTestBase.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/scheduling/SharingWorkerClassTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/scheduling/WorkQueueStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/scheduling/WorkQueueTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/selects/SelectDeadlockStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/selects/SelectMemoryLeakStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/jvm/test/selects/SelectPhilosophersStressTest.kt1
-rw-r--r--kotlinx-coroutines-core/native/test/DelayExceptionTest.kt1
-rw-r--r--kotlinx-coroutines-core/native/test/TestBase.kt110
-rw-r--r--kotlinx-coroutines-core/native/test/WorkerTest.kt1
-rw-r--r--kotlinx-coroutines-core/nativeDarwin/test/MainDispatcherTest.kt2
-rw-r--r--kotlinx-coroutines-core/wasmJs/test/PromiseTest.kt3
-rw-r--r--kotlinx-coroutines-core/wasmJs/test/TestBase.kt139
-rw-r--r--kotlinx-coroutines-debug/test/BlockHoundTest.kt1
-rw-r--r--kotlinx-coroutines-debug/test/CoroutinesDumpTest.kt1
-rw-r--r--kotlinx-coroutines-debug/test/DebugLeaksTest.kt3
-rw-r--r--kotlinx-coroutines-debug/test/DebugProbesTest.kt5
-rw-r--r--kotlinx-coroutines-debug/test/DebugTestBase.kt1
-rw-r--r--kotlinx-coroutines-debug/test/DumpCoroutineInfoAsJsonAndReferencesTest.kt14
-rw-r--r--kotlinx-coroutines-debug/test/DumpWithoutCreationStackTraceTest.kt1
-rw-r--r--kotlinx-coroutines-debug/test/EnhanceStackTraceWithTreadDumpAsJsonTest.kt1
-rw-r--r--kotlinx-coroutines-debug/test/LazyCoroutineTest.kt1
-rw-r--r--kotlinx-coroutines-debug/test/RunningThreadStackMergeTest.kt1
-rw-r--r--kotlinx-coroutines-debug/test/SanitizedProbesTest.kt9
-rw-r--r--kotlinx-coroutines-debug/test/ScopedBuildersTest.kt1
-rw-r--r--kotlinx-coroutines-debug/test/StandardBuildersDebugTest.kt1
-rw-r--r--kotlinx-coroutines-debug/test/StartModeProbesTest.kt1
-rw-r--r--kotlinx-coroutines-debug/test/ToStringTest.kt1
-rw-r--r--kotlinx-coroutines-debug/test/WithContextUndispatchedTest.kt1
-rw-r--r--kotlinx-coroutines-debug/test/junit4/CoroutinesTimeoutDisabledTracesTest.kt1
-rw-r--r--kotlinx-coroutines-debug/test/junit4/CoroutinesTimeoutEagerTest.kt1
-rw-r--r--kotlinx-coroutines-debug/test/junit4/CoroutinesTimeoutTest.kt1
-rw-r--r--kotlinx-coroutines-debug/test/junit5/CoroutinesTimeoutInheritanceTest.kt1
-rw-r--r--kotlinx-coroutines-test/build.gradle.kts6
-rw-r--r--kotlinx-coroutines-test/common/test/Helpers.kt65
-rw-r--r--kotlinx-coroutines-test/common/test/RunTestTest.kt2
-rw-r--r--kotlinx-coroutines-test/common/test/StandardTestDispatcherTest.kt1
-rw-r--r--kotlinx-coroutines-test/common/test/TestCoroutineSchedulerTest.kt2
-rw-r--r--kotlinx-coroutines-test/common/test/TestDispatchersTest.kt1
-rw-r--r--kotlinx-coroutines-test/common/test/TestScopeTest.kt2
-rw-r--r--kotlinx-coroutines-test/js/test/Helpers.kt4
-rw-r--r--kotlinx-coroutines-test/jvm/test/MemoryLeakTest.kt1
-rw-r--r--kotlinx-coroutines-test/jvm/test/RunTestStressTest.kt3
-rw-r--r--kotlinx-coroutines-test/jvm/test/UncaughtExceptionsTest.kt2
-rw-r--r--kotlinx-coroutines-test/jvm/test/migration/RunBlockingTestOnTestScopeTest.kt2
-rw-r--r--kotlinx-coroutines-test/jvm/test/migration/RunTestLegacyScopeTest.kt2
-rw-r--r--kotlinx-coroutines-test/jvm/test/migration/TestBuildersTest.kt1
-rw-r--r--kotlinx-coroutines-test/jvm/test/migration/TestCoroutineDispatcherOrderTest.kt1
-rw-r--r--kotlinx-coroutines-test/jvm/test/migration/TestCoroutineScopeTest.kt4
-rw-r--r--kotlinx-coroutines-test/jvm/test/migration/TestRunBlockingOrderTest.kt1
-rw-r--r--kotlinx-coroutines-test/jvm/test/migration/TestRunBlockingTest.kt2
-rw-r--r--kotlinx-coroutines-test/native/test/Helpers.kt4
-rw-r--r--kotlinx-coroutines-test/wasmJs/test/Helpers.kt4
-rw-r--r--reactive/knit.test.include1
-rw-r--r--reactive/kotlinx-coroutines-jdk9/test/AwaitTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-jdk9/test/FlowAsPublisherTest.kt3
-rw-r--r--reactive/kotlinx-coroutines-jdk9/test/IntegrationTest.kt19
-rw-r--r--reactive/kotlinx-coroutines-jdk9/test/PublishTest.kt19
-rw-r--r--reactive/kotlinx-coroutines-jdk9/test/PublisherAsFlowTest.kt2
-rw-r--r--reactive/kotlinx-coroutines-jdk9/test/PublisherBackpressureTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-jdk9/test/PublisherCollectTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-jdk9/test/PublisherCompletionStressTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-jdk9/test/PublisherMultiTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-reactive/test/AwaitCancellationStressTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-reactive/test/AwaitTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-reactive/test/CancelledParentAttachTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-reactive/test/FlowAsPublisherTest.kt3
-rw-r--r--reactive/kotlinx-coroutines-reactive/test/IntegrationTest.kt19
-rw-r--r--reactive/kotlinx-coroutines-reactive/test/PublishTest.kt19
-rw-r--r--reactive/kotlinx-coroutines-reactive/test/PublisherAsFlowTest.kt2
-rw-r--r--reactive/kotlinx-coroutines-reactive/test/PublisherBackpressureTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-reactive/test/PublisherCollectTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-reactive/test/PublisherCompletionStressTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-reactive/test/PublisherMultiTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-reactive/test/PublisherRequestStressTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-reactive/test/PublisherSubscriptionSelectTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-reactive/test/ReactiveStreamTckTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-reactor/test/BackpressureTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-reactor/test/ConvertTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-reactor/test/FlowAsFluxTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-reactor/test/FluxCompletionStressTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-reactor/test/FluxContextTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-reactor/test/FluxMultiTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-reactor/test/FluxSingleTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-reactor/test/FluxTest.kt3
-rw-r--r--reactive/kotlinx-coroutines-reactor/test/MonoAwaitStressTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-reactor/test/MonoTest.kt7
-rw-r--r--reactive/kotlinx-coroutines-reactor/test/ReactorContextTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-reactor/test/SchedulerTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/BackpressureTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/CompletableTest.kt7
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/ConvertTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/FlowAsFlowableTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/FlowAsObservableTest.kt3
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/FlowableContextTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/FlowableExceptionHandlingTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/FlowableTest.kt5
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/IntegrationTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/LeakedExceptionTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/MaybeTest.kt7
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/ObservableAsFlowTest.kt4
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/ObservableCollectTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/ObservableCompletionStressTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/ObservableExceptionHandlingTest.kt5
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/ObservableMultiTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/ObservableSingleTest.kt5
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/ObservableSourceAsFlowStressTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/ObservableSubscriptionSelectTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/ObservableTest.kt5
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/SchedulerStressTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/SchedulerTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx2/test/SingleTest.kt7
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/BackpressureTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/CompletableTest.kt7
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/ConvertTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/FlowAsFlowableTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/FlowAsObservableTest.kt3
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/FlowableContextTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/FlowableExceptionHandlingTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/FlowableTest.kt3
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/IntegrationTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/LeakedExceptionTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/MaybeTest.kt7
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/ObservableAsFlowTest.kt2
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/ObservableCollectTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/ObservableCompletionStressTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/ObservableExceptionHandlingTest.kt5
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/ObservableMultiTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/ObservableSingleTest.kt5
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/ObservableSourceAsFlowStressTest.kt2
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/ObservableSubscriptionSelectTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/ObservableTest.kt3
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/SchedulerStressTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/SchedulerTest.kt1
-rw-r--r--reactive/kotlinx-coroutines-rx3/test/SingleTest.kt7
-rw-r--r--settings.gradle.kts1
-rw-r--r--test-utils/build.gradle.kts28
-rw-r--r--test-utils/common/src/LaunchFlow.kt (renamed from kotlinx-coroutines-core/common/test/flow/terminal/LaunchFlow.kt)5
-rw-r--r--test-utils/common/src/MainDispatcherTestBase.kt (renamed from kotlinx-coroutines-core/common/test/MainDispatcherTestBase.kt)10
-rw-r--r--test-utils/common/src/TestBase.common.kt284
-rw-r--r--test-utils/js/src/TestBase.kt97
-rw-r--r--test-utils/jvm/src/Exceptions.kt (renamed from kotlinx-coroutines-core/jvm/test/exceptions/Exceptions.kt)32
-rw-r--r--test-utils/jvm/src/ExecutorRule.kt (renamed from kotlinx-coroutines-core/jvm/test/ExecutorRule.kt)4
-rw-r--r--test-utils/jvm/src/FieldWalker.kt (renamed from kotlinx-coroutines-core/jvm/test/FieldWalker.kt)2
-rw-r--r--test-utils/jvm/src/TestBase.kt (renamed from kotlinx-coroutines-core/jvm/test/TestBase.kt)170
-rw-r--r--test-utils/jvm/src/Threads.kt (renamed from kotlinx-coroutines-core/jvm/test/Threads.kt)14
-rw-r--r--test-utils/native/src/TestBase.kt63
-rw-r--r--test-utils/wasmJs/src/TestBase.kt98
-rw-r--r--ui/kotlinx-coroutines-android/android-unit-tests/test/ordered/tests/CustomizedRobolectricTest.kt1
-rw-r--r--ui/kotlinx-coroutines-android/android-unit-tests/test/ordered/tests/FirstMockedMainTest.kt1
-rw-r--r--ui/kotlinx-coroutines-android/test/AndroidExceptionPreHandlerTest.kt1
-rw-r--r--ui/kotlinx-coroutines-android/test/DisabledHandlerTest.kt1
-rw-r--r--ui/kotlinx-coroutines-android/test/HandlerDispatcherAsyncTest.kt1
-rw-r--r--ui/kotlinx-coroutines-android/test/HandlerDispatcherTest.kt5
-rw-r--r--ui/kotlinx-coroutines-android/test/R8ServiceLoaderOptimizationTest.kt1
-rw-r--r--ui/kotlinx-coroutines-javafx/build.gradle.kts12
-rw-r--r--ui/kotlinx-coroutines-javafx/test/JavaFxDispatcherTest.kt2
-rw-r--r--ui/kotlinx-coroutines-javafx/test/JavaFxObservableAsFlowTest.kt3
-rw-r--r--ui/kotlinx-coroutines-javafx/test/JavaFxStressTest.kt1
-rw-r--r--ui/kotlinx-coroutines-swing/test/SwingTest.kt2
492 files changed, 1493 insertions, 1141 deletions
diff --git a/build.gradle.kts b/build.gradle.kts
index 3def4337..002a1d89 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -108,33 +108,25 @@ configure(subprojects.filter { !sourceless.contains(it.name) }) {
}
}
+configure(subprojects.filter { !sourceless.contains(it.name) && it.name != testUtilsModule }) {
+ if (isMultiplatform) {
+ configure<KotlinMultiplatformExtension> {
+ sourceSets.commonTest.dependencies { implementation(project(":$testUtilsModule")) }
+ }
+ } else {
+ dependencies { add("testImplementation", project(":$testUtilsModule")) }
+ }
+}
+
// Add dependency to the core module in all the other subprojects.
configure(subprojects.filter { !sourceless.contains(it.name) && it.name != coreModule }) {
evaluationDependsOn(":$coreModule")
- val jvmTestDependency = project(":$coreModule")
- .extensions.getByType(KotlinMultiplatformExtension::class)
- .targets["jvm"].compilations["test"].output.allOutputs
if (isMultiplatform) {
configure<KotlinMultiplatformExtension> {
- sourceSets {
- commonMain {
- dependencies {
- api(project(":$coreModule"))
- }
- }
- jvmTest {
- dependencies {
- implementation(jvmTestDependency)
- }
- }
- }
+ sourceSets.commonMain.dependencies { api(project(":$coreModule")) }
}
} else {
- dependencies {
- add("api", project(":$coreModule"))
- // the only way IDEA can resolve test classes
- add("testImplementation", jvmTestDependency)
- }
+ dependencies { add("api", project(":$coreModule")) }
}
}
diff --git a/buildSrc/src/main/kotlin/Projects.kt b/buildSrc/src/main/kotlin/Projects.kt
index 011851ff..48bb938d 100644
--- a/buildSrc/src/main/kotlin/Projects.kt
+++ b/buildSrc/src/main/kotlin/Projects.kt
@@ -24,15 +24,15 @@ val Project.sourceSets: SourceSetContainer
val coreModule = "kotlinx-coroutines-core"
val jdk8ObsoleteModule = "kotlinx-coroutines-jdk8"
-val testModule = "kotlinx-coroutines-test"
+val testUtilsModule = "test-utils"
// Not applicable for Kotlin plugin
val sourceless = setOf("kotlinx.coroutines", "kotlinx-coroutines-bom")
// Not published
-val unpublished = setOf("kotlinx.coroutines", "benchmarks", "android-unit-tests")
+val unpublished = setOf("kotlinx.coroutines", "benchmarks", "android-unit-tests", testUtilsModule)
-val Project.isMultiplatform: Boolean get() = name in setOf(coreModule, testModule)
+val Project.isMultiplatform: Boolean get() = name in setOf(coreModule, "kotlinx-coroutines-test", testUtilsModule)
val Project.isBom: Boolean get() = name == "kotlinx-coroutines-bom"
// Projects that we do not check for Android API level 14 check due to various limitations
diff --git a/buildSrc/src/main/kotlin/configure-compilation-conventions.gradle.kts b/buildSrc/src/main/kotlin/configure-compilation-conventions.gradle.kts
index f9427527..26ffe113 100644
--- a/buildSrc/src/main/kotlin/configure-compilation-conventions.gradle.kts
+++ b/buildSrc/src/main/kotlin/configure-compilation-conventions.gradle.kts
@@ -19,7 +19,7 @@ configure(subprojects) {
apiVersion = it
versionsAreNotOverridden = false
}
- if (isMainTaskName && versionsAreNotOverridden) {
+ if (isMainTaskName && versionsAreNotOverridden && !unpublished.contains(project.name)) {
allWarningsAsErrors = true
freeCompilerArgs.add("-Xexplicit-api=strict")
}
diff --git a/integration/kotlinx-coroutines-guava/test/FutureAsDeferredUnhandledCompletionExceptionTest.kt b/integration/kotlinx-coroutines-guava/test/FutureAsDeferredUnhandledCompletionExceptionTest.kt
index ca3ce281..5637493d 100644
--- a/integration/kotlinx-coroutines-guava/test/FutureAsDeferredUnhandledCompletionExceptionTest.kt
+++ b/integration/kotlinx-coroutines-guava/test/FutureAsDeferredUnhandledCompletionExceptionTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.guava
+import kotlinx.coroutines.testing.*
import com.google.common.util.concurrent.*
import kotlinx.coroutines.*
import org.junit.*
diff --git a/integration/kotlinx-coroutines-guava/test/ListenableFutureExceptionsTest.kt b/integration/kotlinx-coroutines-guava/test/ListenableFutureExceptionsTest.kt
index 44b06e83..374f6989 100644
--- a/integration/kotlinx-coroutines-guava/test/ListenableFutureExceptionsTest.kt
+++ b/integration/kotlinx-coroutines-guava/test/ListenableFutureExceptionsTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.guava
+import kotlinx.coroutines.testing.*
import com.google.common.base.*
import com.google.common.util.concurrent.*
import kotlinx.coroutines.*
diff --git a/integration/kotlinx-coroutines-guava/test/ListenableFutureTest.kt b/integration/kotlinx-coroutines-guava/test/ListenableFutureTest.kt
index 3feed7bb..a873206d 100644
--- a/integration/kotlinx-coroutines-guava/test/ListenableFutureTest.kt
+++ b/integration/kotlinx-coroutines-guava/test/ListenableFutureTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.guava
+import kotlinx.coroutines.testing.*
import com.google.common.util.concurrent.*
import kotlinx.coroutines.*
import org.junit.*
@@ -83,7 +84,7 @@ class ListenableFutureTest : TestBase() {
try {
toAwait.await()
} catch (e: RuntimeException) {
- assertTrue(e is IllegalArgumentException)
+ assertIs<IllegalArgumentException>(e)
e.message!!
} + "K"
}
@@ -97,7 +98,7 @@ class ListenableFutureTest : TestBase() {
try {
toAwait.await()
} catch (e: RuntimeException) {
- assertTrue(e is IllegalArgumentException)
+ assertIs<IllegalArgumentException>(e)
e.message!!
} + "K"
}
@@ -119,7 +120,7 @@ class ListenableFutureTest : TestBase() {
future.get()
fail("'get' should've throw an exception")
} catch (e: ExecutionException) {
- assertTrue(e.cause is IllegalStateException)
+ assertIs<IllegalStateException>(e.cause)
assertEquals("OK", e.cause!!.message)
}
}
@@ -172,7 +173,7 @@ class ListenableFutureTest : TestBase() {
future.get()
} catch (e: ExecutionException) {
assertTrue(future.isDone)
- assertTrue(e.cause is OutOfMemoryError)
+ assertIs<OutOfMemoryError>(e.cause)
}
}
@@ -352,11 +353,11 @@ class ListenableFutureTest : TestBase() {
val asFuture = deferred.asListenableFuture()
val outputCancellationException =
- assertFailsWith<CancellationException> { asFuture.get() }
+ assertFailsWith<CancellationException> { asFuture.get() }
val cause = outputCancellationException.cause
assertNotNull(cause)
assertEquals(cause.message, "Foobar")
- assertTrue(cause.cause is OutOfMemoryError)
+ assertIs<OutOfMemoryError>(cause.cause)
assertEquals(cause.cause?.message, "Foobaz")
}
@@ -392,7 +393,7 @@ class ListenableFutureTest : TestBase() {
assertTrue(asFutureAsDeferred.isCompleted)
// By documentation, join() shouldn't throw when asDeferred is already complete.
asFutureAsDeferred.join()
- assertTrue(asFutureAsDeferred.getCompletionExceptionOrNull() is CancellationException)
+ assertIs<CancellationException>(asFutureAsDeferred.getCompletionExceptionOrNull())
}
@Test
@@ -415,7 +416,7 @@ class ListenableFutureTest : TestBase() {
assertTrue(asDeferred.isCompleted)
// By documentation, join() shouldn't throw when asDeferred is already complete.
asDeferred.join()
- assertTrue(asDeferred.getCompletionExceptionOrNull() is CancellationException)
+ assertIs<CancellationException>(asDeferred.getCompletionExceptionOrNull())
}
@Test
@@ -443,13 +444,13 @@ class ListenableFutureTest : TestBase() {
val deferred = future.asDeferred()
assertTrue(deferred.isCancelled && deferred.isCompleted)
val completionException = deferred.getCompletionExceptionOrNull()!!
- assertTrue(completionException is TestException)
+ assertIs<TestException>(completionException)
try {
deferred.await()
expectUnreached()
} catch (e: Throwable) {
- assertTrue(e is TestException)
+ assertIs<TestException>(e)
}
}
@@ -489,7 +490,7 @@ class ListenableFutureTest : TestBase() {
future.asDeferred().await()
expectUnreached()
} catch (e: Throwable) {
- assertTrue(e is TestException)
+ assertIs<TestException>(e)
}
}
@@ -606,9 +607,9 @@ class ListenableFutureTest : TestBase() {
val thrown = assertFailsWith<CancellationException> { future.get() }
val cause = thrown.cause
assertNotNull(cause)
- assertTrue(cause is CancellationException)
+ assertIs<CancellationException>(cause)
assertEquals("Parent cancelled", cause.message)
- assertTrue(cause.cause is TestException)
+ assertIs<TestException>(cause.cause)
finish(5)
}
@@ -703,7 +704,7 @@ class ListenableFutureTest : TestBase() {
private inline fun <reified T: Throwable> ListenableFuture<*>.checkFutureException() {
val e = assertFailsWith<ExecutionException> { get() }
val cause = e.cause!!
- assertTrue(cause is T)
+ assertIs<T>(cause)
}
@Suppress("SuspendFunctionOnCoroutineScope")
diff --git a/integration/kotlinx-coroutines-guava/test/ListenableFutureToStringTest.kt b/integration/kotlinx-coroutines-guava/test/ListenableFutureToStringTest.kt
index 1a8afe87..c70c7608 100644
--- a/integration/kotlinx-coroutines-guava/test/ListenableFutureToStringTest.kt
+++ b/integration/kotlinx-coroutines-guava/test/ListenableFutureToStringTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.guava
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import kotlin.test.*
diff --git a/integration/kotlinx-coroutines-play-services/test/TaskTest.kt b/integration/kotlinx-coroutines-play-services/test/TaskTest.kt
index 3c6687c1..e3643837 100644
--- a/integration/kotlinx-coroutines-play-services/test/TaskTest.kt
+++ b/integration/kotlinx-coroutines-play-services/test/TaskTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.tasks
+import kotlinx.coroutines.testing.*
import com.google.android.gms.tasks.*
import kotlinx.coroutines.*
import org.junit.*
@@ -50,7 +51,7 @@ class TaskTest : TestBase() {
try {
runTest { task.await() }
} catch (e: Exception) {
- assertTrue(e is CancellationException)
+ assertIs<CancellationException>(e)
assertTrue(task.isCanceled)
}
}
@@ -102,7 +103,7 @@ class TaskTest : TestBase() {
deferred.await()
fail("deferred.await() should be cancelled")
} catch (e: Exception) {
- assertTrue(e is CancellationException)
+ assertIs<CancellationException>(e)
}
}
@@ -112,14 +113,14 @@ class TaskTest : TestBase() {
assertTrue(deferred.isCancelled && deferred.isCompleted)
val completionException = deferred.getCompletionExceptionOrNull()!!
- assertTrue(completionException is TestException)
+ assertIs<TestException>(completionException)
assertEquals("something went wrong", completionException.message)
try {
deferred.await()
fail("deferred.await() should throw an exception")
} catch (e: Exception) {
- assertTrue(e is TestException)
+ assertIs<TestException>(e)
assertEquals("something went wrong", e.message)
}
}
@@ -139,7 +140,7 @@ class TaskTest : TestBase() {
deferred.await()
fail("deferred.await() should throw an exception")
} catch (e: Exception) {
- assertTrue(e is TestException)
+ assertIs<TestException>(e)
assertEquals("something went wrong", e.message)
assertSame(e.cause, deferred.getCompletionExceptionOrNull()) // debug mode stack augmentation
}
@@ -170,7 +171,7 @@ class TaskTest : TestBase() {
deferred.await()
fail("deferred.await() should be cancelled")
} catch (e: Exception) {
- assertTrue(e is CancellationException)
+ assertIs<CancellationException>(e)
}
assertTrue(cancellationTokenSource.token.isCancellationRequested)
}
@@ -186,7 +187,7 @@ class TaskTest : TestBase() {
deferred.await()
fail("deferred.await() should be cancelled")
} catch (e: Exception) {
- assertTrue(e is CancellationException)
+ assertIs<CancellationException>(e)
}
assertTrue(cancellationTokenSource.token.isCancellationRequested)
}
@@ -203,7 +204,7 @@ class TaskTest : TestBase() {
deferred.await()
fail("deferred.await() should be cancelled")
} catch (e: Exception) {
- assertTrue(e is CancellationException)
+ assertIs<CancellationException>(e)
}
assertTrue(cancellationTokenSource.token.isCancellationRequested)
}
@@ -222,18 +223,19 @@ class TaskTest : TestBase() {
@Test
fun testFailedCancellableTaskAsDeferred() = runTest {
val cancellationTokenSource = CancellationTokenSource()
- val deferred = Tasks.forException<Int>(TestException("something went wrong")).asDeferred(cancellationTokenSource)
+ val deferred =
+ Tasks.forException<Int>(TestException("something went wrong")).asDeferred(cancellationTokenSource)
assertTrue(deferred.isCancelled && deferred.isCompleted)
val completionException = deferred.getCompletionExceptionOrNull()!!
- assertTrue(completionException is TestException)
+ assertIs<TestException>(completionException)
assertEquals("something went wrong", completionException.message)
try {
deferred.await()
fail("deferred.await() should throw an exception")
} catch (e: Exception) {
- assertTrue(e is TestException)
+ assertIs<TestException>(e)
assertEquals("something went wrong", e.message)
}
assertTrue(cancellationTokenSource.token.isCancellationRequested)
@@ -255,7 +257,7 @@ class TaskTest : TestBase() {
deferred.await()
fail("deferred.await() should throw an exception")
} catch (e: Exception) {
- assertTrue(e is TestException)
+ assertIs<TestException>(e)
assertEquals("something went wrong", e.message)
assertSame(e.cause, deferred.getCompletionExceptionOrNull()) // debug mode stack augmentation
}
@@ -318,7 +320,7 @@ class TaskTest : TestBase() {
deferred.await()
fail("deferred.await() should be cancelled")
} catch (e: Exception) {
- assertTrue(e is CancellationException)
+ assertIs<CancellationException>(e)
}
assertTrue(cancellationTokenSource.token.isCancellationRequested)
@@ -341,7 +343,7 @@ class TaskTest : TestBase() {
deferred.await()
fail("deferred.await() should be cancelled")
} catch (e: Exception) {
- assertTrue(e is CancellationException)
+ assertIs<CancellationException>(e)
}
assertTrue(cancellationTokenSource.token.isCancellationRequested)
diff --git a/integration/kotlinx-coroutines-slf4j/test/MDCContextTest.kt b/integration/kotlinx-coroutines-slf4j/test/MDCContextTest.kt
index 2732ec71..e1915303 100644
--- a/integration/kotlinx-coroutines-slf4j/test/MDCContextTest.kt
+++ b/integration/kotlinx-coroutines-slf4j/test/MDCContextTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.slf4j
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import org.junit.Test
diff --git a/kotlinx-coroutines-core/common/test/AbstractCoroutineTest.kt b/kotlinx-coroutines-core/common/test/AbstractCoroutineTest.kt
index 0e491c64..ed33729c 100644
--- a/kotlinx-coroutines-core/common/test/AbstractCoroutineTest.kt
+++ b/kotlinx-coroutines-core/common/test/AbstractCoroutineTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.coroutines.*
import kotlin.test.*
@@ -55,7 +56,7 @@ class AbstractCoroutineTest : TestBase() {
}
override fun onCancelling(cause: Throwable?) {
- assertTrue(cause is TestException1)
+ assertIs<TestException1>(cause)
expect(5)
}
@@ -64,18 +65,18 @@ class AbstractCoroutineTest : TestBase() {
}
override fun onCancelled(cause: Throwable, handled: Boolean) {
- assertTrue(cause is TestException1)
+ assertIs<TestException1>(cause)
expect(8)
}
}
coroutine.invokeOnCompletion(onCancelling = true) {
- assertTrue(it is TestException1)
+ assertIs<TestException1>(it)
expect(6)
}
coroutine.invokeOnCompletion {
- assertTrue(it is TestException1)
+ assertIs<TestException1>(it)
expect(9)
}
diff --git a/kotlinx-coroutines-core/common/test/AsyncLazyTest.kt b/kotlinx-coroutines-core/common/test/AsyncLazyTest.kt
index 3a9eb8fd..e87e4615 100644
--- a/kotlinx-coroutines-core/common/test/AsyncLazyTest.kt
+++ b/kotlinx-coroutines-core/common/test/AsyncLazyTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class AsyncLazyTest : TestBase() {
diff --git a/kotlinx-coroutines-core/common/test/AsyncTest.kt b/kotlinx-coroutines-core/common/test/AsyncTest.kt
index 92e2e2a4..b9c47975 100644
--- a/kotlinx-coroutines-core/common/test/AsyncTest.kt
+++ b/kotlinx-coroutines-core/common/test/AsyncTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class AsyncTest : TestBase() {
@@ -236,11 +237,11 @@ class AsyncTest : TestBase() {
@Test
fun testIncompleteAsyncState() = runTest {
val deferred = async {
- coroutineContext[Job]!!.invokeOnCompletion { }
+ coroutineContext[Job]!!.invokeOnCompletion { }
}
deferred.await().dispose()
- assertTrue(deferred.getCompleted() is DisposableHandle)
+ assertIs<DisposableHandle>(deferred.getCompleted())
assertNull(deferred.getCompletionExceptionOrNull())
assertTrue(deferred.isCompleted)
assertFalse(deferred.isActive)
@@ -250,11 +251,11 @@ class AsyncTest : TestBase() {
@Test
fun testIncompleteAsyncFastPath() = runTest {
val deferred = async(Dispatchers.Unconfined) {
- coroutineContext[Job]!!.invokeOnCompletion { }
+ coroutineContext[Job]!!.invokeOnCompletion { }
}
deferred.await().dispose()
- assertTrue(deferred.getCompleted() is DisposableHandle)
+ assertIs<DisposableHandle>(deferred.getCompleted())
assertNull(deferred.getCompletionExceptionOrNull())
assertTrue(deferred.isCompleted)
assertFalse(deferred.isActive)
diff --git a/kotlinx-coroutines-core/common/test/AtomicCancellationCommonTest.kt b/kotlinx-coroutines-core/common/test/AtomicCancellationCommonTest.kt
index c10e8b51..52d3b8e3 100644
--- a/kotlinx-coroutines-core/common/test/AtomicCancellationCommonTest.kt
+++ b/kotlinx-coroutines-core/common/test/AtomicCancellationCommonTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.selects.*
import kotlinx.coroutines.sync.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/AwaitCancellationTest.kt b/kotlinx-coroutines-core/common/test/AwaitCancellationTest.kt
index c32ca117..51376d50 100644
--- a/kotlinx-coroutines-core/common/test/AwaitCancellationTest.kt
+++ b/kotlinx-coroutines-core/common/test/AwaitCancellationTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class AwaitCancellationTest : TestBase() {
diff --git a/kotlinx-coroutines-core/common/test/AwaitTest.kt b/kotlinx-coroutines-core/common/test/AwaitTest.kt
index c7edcd6f..ca427dfd 100644
--- a/kotlinx-coroutines-core/common/test/AwaitTest.kt
+++ b/kotlinx-coroutines-core/common/test/AwaitTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class AwaitTest : TestBase() {
diff --git a/kotlinx-coroutines-core/common/test/BuilderContractsTest.kt b/kotlinx-coroutines-core/common/test/BuilderContractsTest.kt
index 77213d3e..b732819c 100644
--- a/kotlinx-coroutines-core/common/test/BuilderContractsTest.kt
+++ b/kotlinx-coroutines-core/common/test/BuilderContractsTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.selects.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/CancellableContinuationHandlersTest.kt b/kotlinx-coroutines-core/common/test/CancellableContinuationHandlersTest.kt
index 74e731f8..f005c93e 100644
--- a/kotlinx-coroutines-core/common/test/CancellableContinuationHandlersTest.kt
+++ b/kotlinx-coroutines-core/common/test/CancellableContinuationHandlersTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.internal.*
import kotlin.coroutines.*
import kotlin.test.*
@@ -46,7 +47,7 @@ class CancellableContinuationHandlersTest : TestBase() {
suspendCancellableCoroutine<Unit> { c ->
c.cancel()
c.invokeOnCancellation {
- assertTrue(it is CancellationException)
+ assertIs<CancellationException>(it)
expect(1)
}
assertFailsWith<IllegalStateException> { c.invokeOnCancellation { expectUnreached() } }
@@ -86,7 +87,7 @@ class CancellableContinuationHandlersTest : TestBase() {
cont = c
// Set IOC first -- not called (completed)
c.invokeOnCancellation {
- assertTrue(it is CancellationException)
+ assertIs<CancellationException>(it)
expect(4)
}
expect(1)
diff --git a/kotlinx-coroutines-core/common/test/CancellableContinuationTest.kt b/kotlinx-coroutines-core/common/test/CancellableContinuationTest.kt
index cc09517e..43ad996b 100644
--- a/kotlinx-coroutines-core/common/test/CancellableContinuationTest.kt
+++ b/kotlinx-coroutines-core/common/test/CancellableContinuationTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/CancellableResumeTest.kt b/kotlinx-coroutines-core/common/test/CancellableResumeTest.kt
index be2d6ef5..517b0ce0 100644
--- a/kotlinx-coroutines-core/common/test/CancellableResumeTest.kt
+++ b/kotlinx-coroutines-core/common/test/CancellableResumeTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
/**
@@ -33,7 +34,7 @@ class CancellableResumeTest : TestBase() {
expect(4)
cont.resume("OK") { cause ->
expect(5)
- assertTrue(cause is TestException)
+ assertIs<TestException>(cause)
}
finish(6)
}
@@ -59,7 +60,7 @@ class CancellableResumeTest : TestBase() {
expect(4)
cont.resume("OK") { cause ->
expect(5)
- assertTrue(cause is TestException)
+ assertIs<TestException>(cause)
throw TestException3("FAIL") // onCancellation block fails with exception
}
finish(6)
@@ -154,7 +155,7 @@ class CancellableResumeTest : TestBase() {
expect(6)
cc.resume("OK") { cause ->
expect(7)
- assertTrue(cause is TestCancellationException)
+ assertIs<TestCancellationException>(cause)
}
expect(8)
}
@@ -189,7 +190,7 @@ class CancellableResumeTest : TestBase() {
expect(6)
cc.resume("OK") { cause ->
expect(7)
- assertTrue(cause is TestCancellationException)
+ assertIs<TestCancellationException>(cause)
throw TestException3("FAIL") // onCancellation block fails with exception
}
expect(8)
@@ -208,7 +209,7 @@ class CancellableResumeTest : TestBase() {
cont.invokeOnCancellation { cause ->
// Note: invokeOnCancellation is called before cc.resume(value) { ... } handler
expect(7)
- assertTrue(cause is TestCancellationException)
+ assertIs<TestCancellationException>(cause)
}
cc = cont
}
@@ -221,7 +222,7 @@ class CancellableResumeTest : TestBase() {
cc.resume("OK") { cause ->
// Note: this handler is called after invokeOnCancellation handler
expect(8)
- assertTrue(cause is TestCancellationException)
+ assertIs<TestCancellationException>(cause)
}
expect(5)
job.cancel(TestCancellationException()) // cancel while execution is dispatched
@@ -248,7 +249,7 @@ class CancellableResumeTest : TestBase() {
cont.invokeOnCancellation { cause ->
// Note: invokeOnCancellation is called before cc.resume(value) { ... } handler
expect(7)
- assertTrue(cause is TestCancellationException)
+ assertIs<TestCancellationException>(cause)
throw TestException2("FAIL") // invokeOnCancellation handler fails with exception
}
cc = cont
@@ -262,7 +263,7 @@ class CancellableResumeTest : TestBase() {
cc.resume("OK") { cause ->
// Note: this handler is called after invokeOnCancellation handler
expect(8)
- assertTrue(cause is TestCancellationException)
+ assertIs<TestCancellationException>(cause)
throw TestException3("FAIL") // onCancellation block fails with exception
}
expect(5)
diff --git a/kotlinx-coroutines-core/common/test/CancelledParentAttachTest.kt b/kotlinx-coroutines-core/common/test/CancelledParentAttachTest.kt
index f73beac5..e9812484 100644
--- a/kotlinx-coroutines-core/common/test/CancelledParentAttachTest.kt
+++ b/kotlinx-coroutines-core/common/test/CancelledParentAttachTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.flow.internal.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/CompletableDeferredTest.kt b/kotlinx-coroutines-core/common/test/CompletableDeferredTest.kt
index 0d6f9b65..b2a39218 100644
--- a/kotlinx-coroutines-core/common/test/CompletableDeferredTest.kt
+++ b/kotlinx-coroutines-core/common/test/CompletableDeferredTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class CompletableDeferredTest : TestBase() {
@@ -25,11 +26,11 @@ class CompletableDeferredTest : TestBase() {
@Test
fun testCompleteWithIncompleteResult() {
val c = CompletableDeferred<DisposableHandle>()
- assertEquals(true, c.complete(c.invokeOnCompletion { }))
+ assertEquals(true, c.complete(c.invokeOnCompletion { }))
checkCompleteOk(c)
- assertEquals(false, c.complete(c.invokeOnCompletion { }))
+ assertEquals(false, c.complete(c.invokeOnCompletion { }))
checkCompleteOk(c)
- assertTrue(c.getCompleted() is Incomplete)
+ assertIs<Incomplete>(c.getCompleted())
}
private fun checkFresh(c: CompletableDeferred<*>) {
@@ -45,7 +46,7 @@ class CompletableDeferredTest : TestBase() {
assertEquals(false, c.isActive)
assertEquals(false, c.isCancelled)
assertEquals(true, c.isCompleted)
- assertTrue(c.getCancellationException() is JobCancellationException)
+ assertIs<JobCancellationException>(c.getCancellationException())
assertNull(c.getCompletionExceptionOrNull())
}
@@ -54,7 +55,7 @@ class CompletableDeferredTest : TestBase() {
assertEquals(true, c.isCancelled)
assertEquals(true, c.isCompleted)
assertThrows<CancellationException> { c.getCompleted() }
- assertTrue(c.getCompletionExceptionOrNull() is CancellationException)
+ assertIs<CancellationException>(c.getCompletionExceptionOrNull())
}
@Test
@@ -70,9 +71,9 @@ class CompletableDeferredTest : TestBase() {
assertEquals(false, c.isActive)
assertEquals(true, c.isCancelled)
assertEquals(true, c.isCompleted)
- assertTrue(c.getCancellationException() is JobCancellationException)
+ assertIs<JobCancellationException>(c.getCancellationException())
assertThrows<TestException> { c.getCompleted() }
- assertTrue(c.getCompletionExceptionOrNull() is TestException)
+ assertIs<TestException>(c.getCompletionExceptionOrNull())
}
@Test
@@ -107,7 +108,7 @@ class CompletableDeferredTest : TestBase() {
assertEquals(true, c.isCancelled)
assertEquals(true, c.isCompleted)
assertThrows<CancellationException> { c.getCompleted() }
- assertTrue(c.getCompletionExceptionOrNull() is CancellationException)
+ assertIs<CancellationException>(c.getCompletionExceptionOrNull())
}
@Test
@@ -208,7 +209,7 @@ class CompletableDeferredTest : TestBase() {
block()
fail("Should not complete normally")
} catch (e: Throwable) {
- assertTrue(e is T)
+ assertIs<T>(e)
}
}
-} \ No newline at end of file
+}
diff --git a/kotlinx-coroutines-core/common/test/CompletableJobTest.kt b/kotlinx-coroutines-core/common/test/CompletableJobTest.kt
index 0c484f00..697581ae 100644
--- a/kotlinx-coroutines-core/common/test/CompletableJobTest.kt
+++ b/kotlinx-coroutines-core/common/test/CompletableJobTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class CompletableJobTest : TestBase() {
@@ -52,8 +53,8 @@ class CompletableJobTest : TestBase() {
// KT-33840
hang {}
} catch (e: Throwable) {
- assertTrue(e is CancellationException)
- assertTrue((if (RECOVER_STACK_TRACES) e.cause?.cause else e.cause) is TestException)
+ assertIs<CancellationException>(e)
+ assertIs<TestException>(if (RECOVER_STACK_TRACES) e.cause?.cause else e.cause)
expect(4)
throw e
}
@@ -74,8 +75,8 @@ class CompletableJobTest : TestBase() {
// KT-33840
hang {}
} catch (e: Throwable) {
- assertTrue(e is CancellationException)
- assertTrue((if (RECOVER_STACK_TRACES) e.cause?.cause else e.cause) is TestException)
+ assertIs<CancellationException>(e)
+ assertIs<TestException>(if (RECOVER_STACK_TRACES) e.cause?.cause else e.cause)
expect(4)
throw e
}
diff --git a/kotlinx-coroutines-core/common/test/CoroutineDispatcherOperatorFunInvokeTest.kt b/kotlinx-coroutines-core/common/test/CoroutineDispatcherOperatorFunInvokeTest.kt
index d8f9cc73..0a643cb7 100644
--- a/kotlinx-coroutines-core/common/test/CoroutineDispatcherOperatorFunInvokeTest.kt
+++ b/kotlinx-coroutines-core/common/test/CoroutineDispatcherOperatorFunInvokeTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.coroutines.ContinuationInterceptor
import kotlin.coroutines.CoroutineContext
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/CoroutineExceptionHandlerTest.kt b/kotlinx-coroutines-core/common/test/CoroutineExceptionHandlerTest.kt
index 1857eaf3..5549b088 100644
--- a/kotlinx-coroutines-core/common/test/CoroutineExceptionHandlerTest.kt
+++ b/kotlinx-coroutines-core/common/test/CoroutineExceptionHandlerTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class CoroutineExceptionHandlerTest : TestBase() {
@@ -19,7 +20,7 @@ class CoroutineExceptionHandlerTest : TestBase() {
expect(2)
job.join()
finish(4)
- assertTrue(coroutineException is TestException)
+ assertIs<TestException>(coroutineException)
assertTrue(parent.isCancelled)
}
@@ -38,6 +39,6 @@ class CoroutineExceptionHandlerTest : TestBase() {
job.join()
finish(3)
assertTrue(parent.isCancelled)
- assertTrue(parent.getCompletionExceptionOrNull() is TestException)
+ assertIs<TestException>(parent.getCompletionExceptionOrNull())
}
}
diff --git a/kotlinx-coroutines-core/common/test/CoroutineScopeTest.kt b/kotlinx-coroutines-core/common/test/CoroutineScopeTest.kt
index 4c3a3f96..87ab511a 100644
--- a/kotlinx-coroutines-core/common/test/CoroutineScopeTest.kt
+++ b/kotlinx-coroutines-core/common/test/CoroutineScopeTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.internal.*
import kotlin.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/CoroutinesTest.kt b/kotlinx-coroutines-core/common/test/CoroutinesTest.kt
index ebc5843c..8cd149ef 100644
--- a/kotlinx-coroutines-core/common/test/CoroutinesTest.kt
+++ b/kotlinx-coroutines-core/common/test/CoroutinesTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class CoroutinesTest : TestBase() {
@@ -236,7 +237,7 @@ class CoroutinesTest : TestBase() {
job.cancelAndJoin() // join should crash on child's exception but it will be wrapped into CancellationException
} catch (e: Throwable) {
e as CancellationException // type assertion
- assertTrue(e.cause is TestException)
+ assertIs<TestException>(e.cause)
throw e
}
expectUnreached()
@@ -328,4 +329,4 @@ class CoroutinesTest : TestBase() {
}
private fun throwTestException() { throw TestException() }
-} \ No newline at end of file
+}
diff --git a/kotlinx-coroutines-core/common/test/DelayDurationTest.kt b/kotlinx-coroutines-core/common/test/DelayDurationTest.kt
index c52b3619..dad01eb2 100644
--- a/kotlinx-coroutines-core/common/test/DelayDurationTest.kt
+++ b/kotlinx-coroutines-core/common/test/DelayDurationTest.kt
@@ -4,6 +4,7 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
import kotlin.time.*
import kotlin.time.Duration.Companion.seconds
diff --git a/kotlinx-coroutines-core/common/test/DelayTest.kt b/kotlinx-coroutines-core/common/test/DelayTest.kt
index 4e97d7bb..007a272f 100644
--- a/kotlinx-coroutines-core/common/test/DelayTest.kt
+++ b/kotlinx-coroutines-core/common/test/DelayTest.kt
@@ -3,6 +3,7 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class DelayTest : TestBase() {
diff --git a/kotlinx-coroutines-core/common/test/DispatchedContinuationTest.kt b/kotlinx-coroutines-core/common/test/DispatchedContinuationTest.kt
index 6f7672e3..2035ef5b 100644
--- a/kotlinx-coroutines-core/common/test/DispatchedContinuationTest.kt
+++ b/kotlinx-coroutines-core/common/test/DispatchedContinuationTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/ExperimentalDispatchModeTest.kt b/kotlinx-coroutines-core/common/test/ExperimentalDispatchModeTest.kt
index 8e83eec3..98c5e667 100644
--- a/kotlinx-coroutines-core/common/test/ExperimentalDispatchModeTest.kt
+++ b/kotlinx-coroutines-core/common/test/ExperimentalDispatchModeTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class ExperimentalDispatchModeTest : TestBase() {
diff --git a/kotlinx-coroutines-core/common/test/FailedJobTest.kt b/kotlinx-coroutines-core/common/test/FailedJobTest.kt
index 0c7c7b32..77656ee6 100644
--- a/kotlinx-coroutines-core/common/test/FailedJobTest.kt
+++ b/kotlinx-coroutines-core/common/test/FailedJobTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
// see https://github.com/Kotlin/kotlinx.coroutines/issues/585
diff --git a/kotlinx-coroutines-core/common/test/ImmediateYieldTest.kt b/kotlinx-coroutines-core/common/test/ImmediateYieldTest.kt
index 53412bea..c2c21489 100644
--- a/kotlinx-coroutines-core/common/test/ImmediateYieldTest.kt
+++ b/kotlinx-coroutines-core/common/test/ImmediateYieldTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/JobExtensionsTest.kt b/kotlinx-coroutines-core/common/test/JobExtensionsTest.kt
index 57a24ad6..aacb022a 100644
--- a/kotlinx-coroutines-core/common/test/JobExtensionsTest.kt
+++ b/kotlinx-coroutines-core/common/test/JobExtensionsTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.coroutines.*
import kotlin.test.*
@@ -75,8 +76,8 @@ class JobExtensionsTest : TestBase() {
private inline fun checkException(block: () -> Unit) {
val result = runCatching(block)
val exception = result.exceptionOrNull() ?: fail()
- assertTrue(exception is JobCancellationException)
- assertTrue(exception.cause is TestException)
+ assertIs<JobCancellationException>(exception)
+ assertIs<TestException>(exception.cause)
}
@Test
diff --git a/kotlinx-coroutines-core/common/test/JobStatesTest.kt b/kotlinx-coroutines-core/common/test/JobStatesTest.kt
index 9c8f5920..6f18afd3 100644
--- a/kotlinx-coroutines-core/common/test/JobStatesTest.kt
+++ b/kotlinx-coroutines-core/common/test/JobStatesTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
/**
diff --git a/kotlinx-coroutines-core/common/test/JobTest.kt b/kotlinx-coroutines-core/common/test/JobTest.kt
index 3ec83643..b86ac731 100644
--- a/kotlinx-coroutines-core/common/test/JobTest.kt
+++ b/kotlinx-coroutines-core/common/test/JobTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class JobTest : TestBase() {
@@ -102,8 +103,8 @@ class JobTest : TestBase() {
val cancelResult = runCatching { job.cancel() }
assertTrue(!job.isActive)
for (i in 0 until n) assertEquals(1, fireCount[i])
- assertTrue(cancelResult.exceptionOrNull() is CompletionHandlerException)
- assertTrue(cancelResult.exceptionOrNull()!!.cause is TestException)
+ assertIs<CompletionHandlerException>(cancelResult.exceptionOrNull())
+ assertIs<TestException>(cancelResult.exceptionOrNull()!!.cause)
}
@Test
diff --git a/kotlinx-coroutines-core/common/test/LaunchLazyTest.kt b/kotlinx-coroutines-core/common/test/LaunchLazyTest.kt
index 5f48c418..8f200faa 100644
--- a/kotlinx-coroutines-core/common/test/LaunchLazyTest.kt
+++ b/kotlinx-coroutines-core/common/test/LaunchLazyTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class LaunchLazyTest : TestBase() {
diff --git a/kotlinx-coroutines-core/common/test/LimitedParallelismSharedTest.kt b/kotlinx-coroutines-core/common/test/LimitedParallelismSharedTest.kt
index 938bcbd2..d5b84edf 100644
--- a/kotlinx-coroutines-core/common/test/LimitedParallelismSharedTest.kt
+++ b/kotlinx-coroutines-core/common/test/LimitedParallelismSharedTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class LimitedParallelismSharedTest : TestBase() {
diff --git a/kotlinx-coroutines-core/common/test/NonCancellableTest.kt b/kotlinx-coroutines-core/common/test/NonCancellableTest.kt
index f8e2da1f..bede5373 100644
--- a/kotlinx-coroutines-core/common/test/NonCancellableTest.kt
+++ b/kotlinx-coroutines-core/common/test/NonCancellableTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class NonCancellableTest : TestBase() {
diff --git a/kotlinx-coroutines-core/common/test/ParentCancellationTest.kt b/kotlinx-coroutines-core/common/test/ParentCancellationTest.kt
index 4a341fd6..fd07a064 100644
--- a/kotlinx-coroutines-core/common/test/ParentCancellationTest.kt
+++ b/kotlinx-coroutines-core/common/test/ParentCancellationTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.channels.*
import kotlin.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/SupervisorTest.kt b/kotlinx-coroutines-core/common/test/SupervisorTest.kt
index c58e95c5..8866f804 100644
--- a/kotlinx-coroutines-core/common/test/SupervisorTest.kt
+++ b/kotlinx-coroutines-core/common/test/SupervisorTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class SupervisorTest : TestBase() {
@@ -169,7 +170,7 @@ class SupervisorTest : TestBase() {
expectUnreached()
} catch (e: CancellationException) {
val cause = if (RECOVER_STACK_TRACES) e.cause?.cause!! else e.cause
- assertTrue(cause is TestException1)
+ assertIs<TestException1>(cause)
finish(3)
}
}
diff --git a/kotlinx-coroutines-core/common/test/TestBase.common.kt b/kotlinx-coroutines-core/common/test/TestBase.common.kt
deleted file mode 100644
index 6172bb8c..00000000
--- a/kotlinx-coroutines-core/common/test/TestBase.common.kt
+++ /dev/null
@@ -1,105 +0,0 @@
-@file:Suppress("unused")
-
-package kotlinx.coroutines
-
-import kotlinx.coroutines.flow.*
-import kotlinx.coroutines.internal.*
-import kotlin.coroutines.*
-import kotlin.test.*
-
-public expect val isStressTest: Boolean
-public expect val stressTestMultiplier: Int
-public expect val stressTestMultiplierSqrt: Int
-
-/**
- * The result of a multiplatform asynchronous test.
- * Aliases into Unit on K/JVM and K/N, and into Promise on K/JS.
- */
-@Suppress("NO_ACTUAL_FOR_EXPECT")
-public expect class TestResult
-
-public expect val isNative: Boolean
-
-public expect open class TestBase constructor() {
- /*
- * In common tests we emulate parameterized tests
- * by iterating over parameters space in the single @Test method.
- * This kind of tests is too slow for JS and does not fit into
- * the default Mocha timeout, so we're using this flag to bail-out
- * and run such tests only on JVM and K/N.
- */
- public val isBoundByJsTestTimeout: Boolean
- public fun error(message: Any, cause: Throwable? = null): Nothing
- public fun expect(index: Int)
- public fun expectUnreached()
- public fun finish(index: Int)
- public fun ensureFinished() // Ensures that 'finish' was invoked
- public fun reset() // Resets counter and finish flag. Workaround for parametrized tests absence in common
- public fun println(message: Any?)
-
- public fun runTest(
- expected: ((Throwable) -> Boolean)? = null,
- unhandled: List<(Throwable) -> Boolean> = emptyList(),
- block: suspend CoroutineScope.() -> Unit
- ): TestResult
-}
-
-public suspend inline fun hang(onCancellation: () -> Unit) {
- try {
- suspendCancellableCoroutine<Unit> { }
- } finally {
- onCancellation()
- }
-}
-
-public inline fun <reified T : Throwable> assertFailsWith(block: () -> Unit) {
- try {
- block()
- error("Should not be reached")
- } catch (e: Throwable) {
- assertTrue(e is T)
- }
-}
-
-public suspend inline fun <reified T : Throwable> assertFailsWith(flow: Flow<*>) {
- try {
- flow.collect()
- fail("Should be unreached")
- } catch (e: Throwable) {
- assertTrue(e is T, "Expected exception ${T::class}, but had $e instead")
- }
-}
-
-public suspend fun Flow<Int>.sum() = fold(0) { acc, value -> acc + value }
-public suspend fun Flow<Long>.longSum() = fold(0L) { acc, value -> acc + value }
-
-
-// data is added to avoid stacktrace recovery because CopyableThrowable is not accessible from common modules
-public class TestException(message: String? = null, private val data: Any? = null) : Throwable(message)
-public class TestException1(message: String? = null, private val data: Any? = null) : Throwable(message)
-public class TestException2(message: String? = null, private val data: Any? = null) : Throwable(message)
-public class TestException3(message: String? = null, private val data: Any? = null) : Throwable(message)
-public class TestCancellationException(message: String? = null, private val data: Any? = null) : CancellationException(message)
-public class TestRuntimeException(message: String? = null, private val data: Any? = null) : RuntimeException(message)
-public class RecoverableTestException(message: String? = null) : RuntimeException(message)
-public class RecoverableTestCancellationException(message: String? = null) : CancellationException(message)
-
-public fun wrapperDispatcher(context: CoroutineContext): CoroutineContext {
- val dispatcher = context[ContinuationInterceptor] as CoroutineDispatcher
- return object : CoroutineDispatcher() {
- override fun isDispatchNeeded(context: CoroutineContext): Boolean =
- dispatcher.isDispatchNeeded(context)
- override fun dispatch(context: CoroutineContext, block: Runnable) =
- dispatcher.dispatch(context, block)
- }
-}
-
-public suspend fun wrapperDispatcher(): CoroutineContext = wrapperDispatcher(coroutineContext)
-
-class BadClass {
- override fun equals(other: Any?): Boolean = error("equals")
- override fun hashCode(): Int = error("hashCode")
- override fun toString(): String = error("toString")
-}
-
-public expect val isJavaAndWindows: Boolean
diff --git a/kotlinx-coroutines-core/common/test/UnconfinedTest.kt b/kotlinx-coroutines-core/common/test/UnconfinedTest.kt
index 53c7e58a..b22e4bf4 100644
--- a/kotlinx-coroutines-core/common/test/UnconfinedTest.kt
+++ b/kotlinx-coroutines-core/common/test/UnconfinedTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class UnconfinedTest : TestBase() {
diff --git a/kotlinx-coroutines-core/common/test/UndispatchedResultTest.kt b/kotlinx-coroutines-core/common/test/UndispatchedResultTest.kt
index d29c0e40..cec00e70 100644
--- a/kotlinx-coroutines-core/common/test/UndispatchedResultTest.kt
+++ b/kotlinx-coroutines-core/common/test/UndispatchedResultTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/WithContextTest.kt b/kotlinx-coroutines-core/common/test/WithContextTest.kt
index 9eb7ddae..9e9fd35f 100644
--- a/kotlinx-coroutines-core/common/test/WithContextTest.kt
+++ b/kotlinx-coroutines-core/common/test/WithContextTest.kt
@@ -3,6 +3,7 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class WithContextTest : TestBase() {
@@ -210,7 +211,7 @@ class WithContextTest : TestBase() {
} catch (e: Throwable) {
expect(7)
// make sure TestException, not CancellationException is thrown
- assertTrue(e is TestException, "Caught $e")
+ assertIs<TestException>(e, "Caught $e")
}
}
expect(2)
@@ -240,7 +241,7 @@ class WithContextTest : TestBase() {
} catch (e: Throwable) {
expect(7)
// make sure CancellationException is thrown
- assertTrue(e is CancellationException, "Caught $e")
+ assertIs<CancellationException>(e, "Caught $e")
}
}
diff --git a/kotlinx-coroutines-core/common/test/WithTimeoutDurationTest.kt b/kotlinx-coroutines-core/common/test/WithTimeoutDurationTest.kt
index 0a60a641..855b00f2 100644
--- a/kotlinx-coroutines-core/common/test/WithTimeoutDurationTest.kt
+++ b/kotlinx-coroutines-core/common/test/WithTimeoutDurationTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
import kotlin.time.*
import kotlin.time.Duration.Companion.milliseconds
diff --git a/kotlinx-coroutines-core/common/test/WithTimeoutOrNullDurationTest.kt b/kotlinx-coroutines-core/common/test/WithTimeoutOrNullDurationTest.kt
index f62fc1f2..f92a4c26 100644
--- a/kotlinx-coroutines-core/common/test/WithTimeoutOrNullDurationTest.kt
+++ b/kotlinx-coroutines-core/common/test/WithTimeoutOrNullDurationTest.kt
@@ -3,6 +3,7 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
import kotlin.time.*
diff --git a/kotlinx-coroutines-core/common/test/WithTimeoutOrNullTest.kt b/kotlinx-coroutines-core/common/test/WithTimeoutOrNullTest.kt
index 9f1316b4..51a6a38d 100644
--- a/kotlinx-coroutines-core/common/test/WithTimeoutOrNullTest.kt
+++ b/kotlinx-coroutines-core/common/test/WithTimeoutOrNullTest.kt
@@ -3,6 +3,7 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/WithTimeoutTest.kt b/kotlinx-coroutines-core/common/test/WithTimeoutTest.kt
index 22ac2bf6..5f2690c1 100644
--- a/kotlinx-coroutines-core/common/test/WithTimeoutTest.kt
+++ b/kotlinx-coroutines-core/common/test/WithTimeoutTest.kt
@@ -3,6 +3,7 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class WithTimeoutTest : TestBase() {
diff --git a/kotlinx-coroutines-core/common/test/channels/BasicOperationsTest.kt b/kotlinx-coroutines-core/common/test/channels/BasicOperationsTest.kt
index 3f2a4f8a..fb9e0d9c 100644
--- a/kotlinx-coroutines-core/common/test/channels/BasicOperationsTest.kt
+++ b/kotlinx-coroutines-core/common/test/channels/BasicOperationsTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/channels/BroadcastChannelFactoryTest.kt b/kotlinx-coroutines-core/common/test/channels/BroadcastChannelFactoryTest.kt
index ed7b3727..652f307c 100644
--- a/kotlinx-coroutines-core/common/test/channels/BroadcastChannelFactoryTest.kt
+++ b/kotlinx-coroutines-core/common/test/channels/BroadcastChannelFactoryTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/channels/BroadcastTest.kt b/kotlinx-coroutines-core/common/test/channels/BroadcastTest.kt
index 8083cf0a..a308f7ab 100644
--- a/kotlinx-coroutines-core/common/test/channels/BroadcastTest.kt
+++ b/kotlinx-coroutines-core/common/test/channels/BroadcastTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.selects.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/channels/BufferedBroadcastChannelTest.kt b/kotlinx-coroutines-core/common/test/channels/BufferedBroadcastChannelTest.kt
index 894f140b..834d974c 100644
--- a/kotlinx-coroutines-core/common/test/channels/BufferedBroadcastChannelTest.kt
+++ b/kotlinx-coroutines-core/common/test/channels/BufferedBroadcastChannelTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/channels/BufferedChannelTest.kt b/kotlinx-coroutines-core/common/test/channels/BufferedChannelTest.kt
index 4269a480..27ac0057 100644
--- a/kotlinx-coroutines-core/common/test/channels/BufferedChannelTest.kt
+++ b/kotlinx-coroutines-core/common/test/channels/BufferedChannelTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/channels/ChannelBufferOverflowTest.kt b/kotlinx-coroutines-core/common/test/channels/ChannelBufferOverflowTest.kt
index 12e16047..a6ae885a 100644
--- a/kotlinx-coroutines-core/common/test/channels/ChannelBufferOverflowTest.kt
+++ b/kotlinx-coroutines-core/common/test/channels/ChannelBufferOverflowTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/channels/ChannelFactoryTest.kt b/kotlinx-coroutines-core/common/test/channels/ChannelFactoryTest.kt
index 64f1459a..9260c2d4 100644
--- a/kotlinx-coroutines-core/common/test/channels/ChannelFactoryTest.kt
+++ b/kotlinx-coroutines-core/common/test/channels/ChannelFactoryTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
@@ -7,28 +8,28 @@ import kotlin.test.*
class ChannelFactoryTest : TestBase() {
@Test
fun testRendezvousChannel() {
- assertTrue(Channel<Int>() is BufferedChannel)
- assertTrue(Channel<Int>(0) is BufferedChannel)
+ assertIs<BufferedChannel<*>>(Channel<Int>())
+ assertIs<BufferedChannel<*>>(Channel<Int>(0))
}
@Test
fun testUnlimitedChannel() {
- assertTrue(Channel<Int>(Channel.UNLIMITED) is BufferedChannel)
- assertTrue(Channel<Int>(Channel.UNLIMITED, BufferOverflow.DROP_OLDEST) is BufferedChannel)
- assertTrue(Channel<Int>(Channel.UNLIMITED, BufferOverflow.DROP_LATEST) is BufferedChannel)
+ assertIs<BufferedChannel<*>>(Channel<Int>(Channel.UNLIMITED))
+ assertIs<BufferedChannel<*>>(Channel<Int>(Channel.UNLIMITED, BufferOverflow.DROP_OLDEST))
+ assertIs<BufferedChannel<*>>(Channel<Int>(Channel.UNLIMITED, BufferOverflow.DROP_LATEST))
}
@Test
fun testConflatedChannel() {
- assertTrue(Channel<Int>(Channel.CONFLATED) is ConflatedBufferedChannel)
- assertTrue(Channel<Int>(1, BufferOverflow.DROP_OLDEST) is ConflatedBufferedChannel)
+ assertIs<ConflatedBufferedChannel<*>>(Channel<Int>(Channel.CONFLATED))
+ assertIs<ConflatedBufferedChannel<*>>(Channel<Int>(1, BufferOverflow.DROP_OLDEST))
}
@Test
fun testBufferedChannel() {
- assertTrue(Channel<Int>(1) is BufferedChannel)
- assertTrue(Channel<Int>(1, BufferOverflow.DROP_LATEST) is ConflatedBufferedChannel)
- assertTrue(Channel<Int>(10) is BufferedChannel)
+ assertIs<BufferedChannel<*>>(Channel<Int>(1))
+ assertIs<ConflatedBufferedChannel<*>>(Channel<Int>(1, BufferOverflow.DROP_LATEST))
+ assertIs<BufferedChannel<*>>(Channel<Int>(10))
}
@Test
diff --git a/kotlinx-coroutines-core/common/test/channels/ChannelReceiveCatchingTest.kt b/kotlinx-coroutines-core/common/test/channels/ChannelReceiveCatchingTest.kt
index b0bdb690..bb06a808 100644
--- a/kotlinx-coroutines-core/common/test/channels/ChannelReceiveCatchingTest.kt
+++ b/kotlinx-coroutines-core/common/test/channels/ChannelReceiveCatchingTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
@@ -13,13 +14,13 @@ class ChannelReceiveCatchingTest : TestBase() {
}
val element = channel.receiveCatching()
- assertTrue(element.getOrThrow() is TestException1)
- assertTrue(element.getOrNull() is TestException1)
+ assertIs<TestException1>(element.getOrThrow())
+ assertIs<TestException1>(element.getOrNull())
val closed = channel.receiveCatching()
assertTrue(closed.isClosed)
assertTrue(closed.isFailure)
- assertTrue(closed.exceptionOrNull() is TestException2)
+ assertIs<TestException2>(closed.exceptionOrNull())
}
@Test
@@ -120,12 +121,12 @@ class ChannelReceiveCatchingTest : TestBase() {
assertFalse(intResult.isClosed)
val closeCauseResult = channel.receiveCatching()
- assertTrue(closeCauseResult.getOrThrow().exceptionOrNull() is TestException1)
+ assertIs<TestException1>(closeCauseResult.getOrThrow().exceptionOrNull())
val closeCause = channel.receiveCatching()
assertTrue(closeCause.isClosed)
assertTrue(closeCause.isFailure)
- assertTrue(closeCause.exceptionOrNull() is TestException2)
+ assertIs<TestException2>(closeCause.exceptionOrNull())
}
@Test
diff --git a/kotlinx-coroutines-core/common/test/channels/ChannelUndeliveredElementFailureTest.kt b/kotlinx-coroutines-core/common/test/channels/ChannelUndeliveredElementFailureTest.kt
index bbe1cfb1..c45ff296 100644
--- a/kotlinx-coroutines-core/common/test/channels/ChannelUndeliveredElementFailureTest.kt
+++ b/kotlinx-coroutines-core/common/test/channels/ChannelUndeliveredElementFailureTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.internal.*
import kotlinx.coroutines.selects.*
diff --git a/kotlinx-coroutines-core/common/test/channels/ChannelUndeliveredElementTest.kt b/kotlinx-coroutines-core/common/test/channels/ChannelUndeliveredElementTest.kt
index 9259178e..4be7c310 100644
--- a/kotlinx-coroutines-core/common/test/channels/ChannelUndeliveredElementTest.kt
+++ b/kotlinx-coroutines-core/common/test/channels/ChannelUndeliveredElementTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.atomicfu.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/channels/ChannelsTest.kt b/kotlinx-coroutines-core/common/test/channels/ChannelsTest.kt
index 8522de63..d4d6887d 100644
--- a/kotlinx-coroutines-core/common/test/channels/ChannelsTest.kt
+++ b/kotlinx-coroutines-core/common/test/channels/ChannelsTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.coroutines.*
import kotlin.math.*
diff --git a/kotlinx-coroutines-core/common/test/channels/ConflatedBroadcastChannelTest.kt b/kotlinx-coroutines-core/common/test/channels/ConflatedBroadcastChannelTest.kt
index 1ff38b89..72b5fdea 100644
--- a/kotlinx-coroutines-core/common/test/channels/ConflatedBroadcastChannelTest.kt
+++ b/kotlinx-coroutines-core/common/test/channels/ConflatedBroadcastChannelTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
@@ -32,7 +33,7 @@ class ConflatedBroadcastChannelTest : TestBase() {
fun testBasicScenario() = runTest {
expect(1)
val broadcast = ConflatedBroadcastChannel<String>()
- assertTrue(exceptionFrom { broadcast.value } is IllegalStateException)
+ assertIs<IllegalStateException>(exceptionFrom { broadcast.value })
assertNull(broadcast.valueOrNull)
launch(start = CoroutineStart.UNDISPATCHED) {
@@ -84,11 +85,11 @@ class ConflatedBroadcastChannelTest : TestBase() {
yield() // to second receiver
expect(18)
broadcast.close()
- assertTrue(exceptionFrom { broadcast.value } is IllegalStateException)
+ assertIs<IllegalStateException>(exceptionFrom { broadcast.value })
assertNull(broadcast.valueOrNull)
expect(19)
yield() // to second receiver
- assertTrue(exceptionFrom { broadcast.send("four") } is ClosedSendChannelException)
+ assertIs<ClosedSendChannelException>(exceptionFrom { broadcast.send("four") })
finish(22)
}
@@ -103,7 +104,7 @@ class ConflatedBroadcastChannelTest : TestBase() {
val sub = broadcast.openSubscription()
assertEquals(1, sub.receive())
expect(3)
- assertTrue(exceptionFrom { sub.receive() } is ClosedReceiveChannelException) // suspends
+ assertIs<ClosedReceiveChannelException>(exceptionFrom { sub.receive() }) // suspends
expect(6)
}
expect(4)
diff --git a/kotlinx-coroutines-core/common/test/channels/ConflatedChannelTest.kt b/kotlinx-coroutines-core/common/test/channels/ConflatedChannelTest.kt
index 43ffde47..e3e52dfc 100644
--- a/kotlinx-coroutines-core/common/test/channels/ConflatedChannelTest.kt
+++ b/kotlinx-coroutines-core/common/test/channels/ConflatedChannelTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/channels/ConsumeTest.kt b/kotlinx-coroutines-core/common/test/channels/ConsumeTest.kt
index 34052936..f5df2340 100644
--- a/kotlinx-coroutines-core/common/test/channels/ConsumeTest.kt
+++ b/kotlinx-coroutines-core/common/test/channels/ConsumeTest.kt
@@ -1,6 +1,7 @@
@file:OptIn(DelicateCoroutinesApi::class)
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/channels/ProduceConsumeTest.kt b/kotlinx-coroutines-core/common/test/channels/ProduceConsumeTest.kt
index 5c8059dd..1ae5c8cd 100644
--- a/kotlinx-coroutines-core/common/test/channels/ProduceConsumeTest.kt
+++ b/kotlinx-coroutines-core/common/test/channels/ProduceConsumeTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/channels/ProduceTest.kt b/kotlinx-coroutines-core/common/test/channels/ProduceTest.kt
index 8bfe144e..1b68bacb 100644
--- a/kotlinx-coroutines-core/common/test/channels/ProduceTest.kt
+++ b/kotlinx-coroutines-core/common/test/channels/ProduceTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import kotlin.coroutines.*
diff --git a/kotlinx-coroutines-core/common/test/channels/RendezvousChannelTest.kt b/kotlinx-coroutines-core/common/test/channels/RendezvousChannelTest.kt
index 1e5fabe2..8fd41b83 100644
--- a/kotlinx-coroutines-core/common/test/channels/RendezvousChannelTest.kt
+++ b/kotlinx-coroutines-core/common/test/channels/RendezvousChannelTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/channels/SendReceiveStressTest.kt b/kotlinx-coroutines-core/common/test/channels/SendReceiveStressTest.kt
index 0abfb0b1..5fa22b54 100644
--- a/kotlinx-coroutines-core/common/test/channels/SendReceiveStressTest.kt
+++ b/kotlinx-coroutines-core/common/test/channels/SendReceiveStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/channels/UnlimitedChannelTest.kt b/kotlinx-coroutines-core/common/test/channels/UnlimitedChannelTest.kt
index 037c38bf..08bcc203 100644
--- a/kotlinx-coroutines-core/common/test/channels/UnlimitedChannelTest.kt
+++ b/kotlinx-coroutines-core/common/test/channels/UnlimitedChannelTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/BuildersTest.kt b/kotlinx-coroutines-core/common/test/flow/BuildersTest.kt
index 52ac3e77..6f2eda4d 100644
--- a/kotlinx-coroutines-core/common/test/flow/BuildersTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/BuildersTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/FlowInvariantsTest.kt b/kotlinx-coroutines-core/common/test/flow/FlowInvariantsTest.kt
index 1cfde56c..06eedb96 100644
--- a/kotlinx-coroutines-core/common/test/flow/FlowInvariantsTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/FlowInvariantsTest.kt
@@ -1,7 +1,9 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
+import kotlinx.coroutines.testing.flow.*
import kotlin.coroutines.*
import kotlin.reflect.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/IdFlowTest.kt b/kotlinx-coroutines-core/common/test/flow/IdFlowTest.kt
index 383c256a..be3be667 100644
--- a/kotlinx-coroutines-core/common/test/flow/IdFlowTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/IdFlowTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/SafeFlowTest.kt b/kotlinx-coroutines-core/common/test/flow/SafeFlowTest.kt
index 05f956fc..26132ab0 100644
--- a/kotlinx-coroutines-core/common/test/flow/SafeFlowTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/SafeFlowTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/VirtualTime.kt b/kotlinx-coroutines-core/common/test/flow/VirtualTime.kt
index d36d40b9..bd1fd6dc 100644
--- a/kotlinx-coroutines-core/common/test/flow/VirtualTime.kt
+++ b/kotlinx-coroutines-core/common/test/flow/VirtualTime.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.coroutines.*
import kotlin.jvm.*
@@ -79,6 +80,6 @@ public fun TestBase.withVirtualTime(block: suspend CoroutineScope.() -> Unit) =
// Create a platform-independent event loop
val dispatcher = VirtualTimeDispatcher(this)
withContext(dispatcher) { block() }
- ensureFinished()
+ checkFinishCall(allowNotUsingExpect = false)
}
}
diff --git a/kotlinx-coroutines-core/common/test/flow/channels/ChannelBuildersFlowTest.kt b/kotlinx-coroutines-core/common/test/flow/channels/ChannelBuildersFlowTest.kt
index 19d4e2c3..7a51a8d7 100644
--- a/kotlinx-coroutines-core/common/test/flow/channels/ChannelBuildersFlowTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/channels/ChannelBuildersFlowTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/channels/ChannelFlowTest.kt b/kotlinx-coroutines-core/common/test/flow/channels/ChannelFlowTest.kt
index 19bd878c..6e584612 100644
--- a/kotlinx-coroutines-core/common/test/flow/channels/ChannelFlowTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/channels/ChannelFlowTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/channels/FlowCallbackTest.kt b/kotlinx-coroutines-core/common/test/flow/channels/FlowCallbackTest.kt
index 5b9eabb1..2b553a5e 100644
--- a/kotlinx-coroutines-core/common/test/flow/channels/FlowCallbackTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/channels/FlowCallbackTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/internal/FlowScopeTest.kt b/kotlinx-coroutines-core/common/test/flow/internal/FlowScopeTest.kt
index 22465ec8..aeaa3c19 100644
--- a/kotlinx-coroutines-core/common/test/flow/internal/FlowScopeTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/internal/FlowScopeTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow.internal
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/BufferConflationTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/BufferConflationTest.kt
index 798dcebf..789a7132 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/BufferConflationTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/BufferConflationTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/BufferTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/BufferTest.kt
index 81d57021..c8407901 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/BufferTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/BufferTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.math.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/CancellableTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/CancellableTest.kt
index 90b0c17f..fff474eb 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/CancellableTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/CancellableTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow.operators
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/CatchTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/CatchTest.kt
index 16a4af27..420470a5 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/CatchTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/CatchTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.coroutines.*
import kotlin.test.*
@@ -99,7 +100,7 @@ class CatchTest : TestBase() {
flow
.catch { e ->
expect(4)
- assertTrue(e is TestException)
+ assertIs<TestException>(e)
assertEquals("A", kotlin.coroutines.coroutineContext[CoroutineName]?.name)
assertSame(d1, kotlin.coroutines.coroutineContext[ContinuationInterceptor] as CoroutineContext)
throw e // rethrow downstream
@@ -107,7 +108,7 @@ class CatchTest : TestBase() {
.flowOn(CoroutineName("A"))
.catch { e ->
expect(5)
- assertTrue(e is TestException)
+ assertIs<TestException>(e)
assertEquals("B", kotlin.coroutines.coroutineContext[CoroutineName]?.name)
assertSame(d1, kotlin.coroutines.coroutineContext[ContinuationInterceptor] as CoroutineContext)
throw e // rethrow downstream
@@ -115,14 +116,14 @@ class CatchTest : TestBase() {
.flowOn(CoroutineName("B"))
.catch { e ->
expect(6)
- assertTrue(e is TestException)
+ assertIs<TestException>(e)
assertSame(d1, kotlin.coroutines.coroutineContext[ContinuationInterceptor] as CoroutineContext)
throw e // rethrow downstream
}
.flowOn(d1)
.catch { e ->
expect(7)
- assertTrue(e is TestException)
+ assertIs<TestException>(e)
assertSame(d2, kotlin.coroutines.coroutineContext[ContinuationInterceptor] as CoroutineContext)
throw e // rethrow downstream
}
@@ -134,7 +135,7 @@ class CatchTest : TestBase() {
}
.catch { e ->
expect(8)
- assertTrue(e is TestException)
+ assertIs<TestException>(e)
assertSame(d0, kotlin.coroutines.coroutineContext[ContinuationInterceptor] as CoroutineContext)
}
.collect()
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/CombineParametersTestBase.kt b/kotlinx-coroutines-core/common/test/flow/operators/CombineParametersTest.kt
index 3b402ef9..f496dd74 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/CombineParametersTestBase.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/CombineParametersTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow.operators
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import kotlin.test.*
@@ -109,8 +110,7 @@ class CombineParametersTest : TestBase() {
@Test
fun testReified() = runTest {
val value = combine(flowOf(1), flowOf(2)) { args: Array<Int> ->
- @Suppress("USELESS_IS_CHECK")
- assertTrue(args is Array<Int>)
+ assertIs<Array<Int>>(args)
args[0] + args[1]
}.single()
assertEquals(3, value)
@@ -119,8 +119,7 @@ class CombineParametersTest : TestBase() {
@Test
fun testReifiedTransform() = runTest {
val value = combineTransform(flowOf(1), flowOf(2)) { args: Array<Int> ->
- @Suppress("USELESS_IS_CHECK")
- assertTrue(args is Array<Int>)
+ assertIs<Array<Int>>(args)
emit(args[0] + args[1])
}.single()
assertEquals(3, value)
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/CombineTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/CombineTest.kt
index 81cc90a1..6db9b849 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/CombineTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/CombineTest.kt
@@ -1,15 +1,13 @@
@file:Suppress("UNCHECKED_CAST")
package kotlinx.coroutines.flow.operators
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import kotlin.test.*
import kotlinx.coroutines.flow.combine as combineOriginal
import kotlinx.coroutines.flow.combineTransform as combineTransformOriginal
-/*
- * Replace: { i, j -> i + j } -> { i, j -> i + j } as soon as KT-30991 is fixed
- */
abstract class CombineTestBase : TestBase() {
abstract fun <T1, T2, R> Flow<T1>.combineLatest(other: Flow<T2>, transform: suspend (T1, T2) -> R): Flow<R>
@@ -18,7 +16,7 @@ abstract class CombineTestBase : TestBase() {
fun testCombineLatest() = runTest {
val flow = flowOf("a", "b", "c")
val flow2 = flowOf(1, 2, 3)
- val list = flow.combineLatest(flow2) { i, j -> i + j }.toList()
+ val list = flow.combineLatest(flow2, String::plus).toList()
assertEquals(listOf("a1", "b2", "c3"), list)
}
@@ -26,7 +24,7 @@ abstract class CombineTestBase : TestBase() {
fun testNulls() = runTest {
val flow = flowOf("a", null, null)
val flow2 = flowOf(1, 2, 3)
- val list = flow.combineLatest(flow2) { i, j -> i + j }.toList()
+ val list = flow.combineLatest(flow2, String?::plus).toList()
assertEquals(listOf("a1", "null2", "null3"), list)
}
@@ -34,13 +32,13 @@ abstract class CombineTestBase : TestBase() {
fun testNullsOther() = runTest {
val flow = flowOf("a", "b", "c")
val flow2 = flowOf(null, 2, null)
- val list = flow.combineLatest(flow2) { i, j -> i + j }.toList()
+ val list = flow.combineLatest(flow2, String::plus).toList()
assertEquals(listOf("anull", "b2", "cnull"), list)
}
@Test
fun testEmptyFlow() = runTest {
- val flow = emptyFlow<String>().combineLatest(emptyFlow<Int>()) { i, j -> i + j }
+ val flow = emptyFlow<String>().combineLatest(emptyFlow<Int>(), String::plus)
assertNull(flow.singleOrNull())
}
@@ -48,14 +46,14 @@ abstract class CombineTestBase : TestBase() {
fun testFirstIsEmpty() = runTest {
val f1 = emptyFlow<String>()
val f2 = flowOf(1)
- assertEquals(emptyList(), f1.combineLatest(f2) { i, j -> i + j }.toList())
+ assertEquals(emptyList(), f1.combineLatest(f2, String::plus).toList())
}
@Test
fun testSecondIsEmpty() = runTest {
val f1 = flowOf("a")
val f2 = emptyFlow<Int>()
- assertEquals(emptyList(), f1.combineLatest(f2) { i, j -> i + j }.toList())
+ assertEquals(emptyList(), f1.combineLatest(f2, String::plus).toList())
}
@Test
@@ -82,7 +80,7 @@ abstract class CombineTestBase : TestBase() {
emit(3)
}
- val result = f1.combineLatest(f2) { i, j -> i + j }.toList()
+ val result = f1.combineLatest(f2, String::plus).toList()
assertEquals(listOf("a1", "b1", "c1", "c2", "c3"), result)
finish(8)
}
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/ConflateTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/ConflateTest.kt
index 7c85ff73..b680b22f 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/ConflateTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/ConflateTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow.operators
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/DebounceTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/DebounceTest.kt
index 37cfae18..76270d0d 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/DebounceTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/DebounceTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/DistinctUntilChangedTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/DistinctUntilChangedTest.kt
index 4721e81f..874361bb 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/DistinctUntilChangedTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/DistinctUntilChangedTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/DropTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/DropTest.kt
index f6ff28aa..50f70b99 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/DropTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/DropTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/DropWhileTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/DropWhileTest.kt
index 9b0634b3..a811935f 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/DropWhileTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/DropWhileTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/FilterTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/FilterTest.kt
index 028b1fce..a68cdf42 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/FilterTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/FilterTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/FilterTrivialTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/FilterTrivialTest.kt
index 1975f508..71a7a736 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/FilterTrivialTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/FilterTrivialTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/FlatMapBaseTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/FlatMapBaseTest.kt
index 7c8c0ca2..6e518572 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/FlatMapBaseTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/FlatMapBaseTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/FlatMapLatestTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/FlatMapLatestTest.kt
index 817d6ebb..b98e97d4 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/FlatMapLatestTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/FlatMapLatestTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/FlatMapMergeBaseTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/FlatMapMergeBaseTest.kt
index fe6138ae..0cd1e0ff 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/FlatMapMergeBaseTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/FlatMapMergeBaseTest.kt
@@ -1,8 +1,9 @@
package kotlinx.coroutines.flow
-import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
+import kotlinx.coroutines.testing.*
import kotlin.test.*
+import kotlin.test.assertFailsWith
abstract class FlatMapMergeBaseTest : FlatMapBaseTest() {
@Test
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/FlatMapMergeFastPathTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/FlatMapMergeFastPathTest.kt
index ad323626..c8a41247 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/FlatMapMergeFastPathTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/FlatMapMergeFastPathTest.kt
@@ -1,7 +1,9 @@
package kotlinx.coroutines.flow
import kotlinx.coroutines.*
+import kotlinx.coroutines.testing.*
import kotlin.test.*
+import kotlin.test.assertFailsWith
class FlatMapMergeFastPathTest : FlatMapMergeBaseTest() {
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/FlatMapMergeTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/FlatMapMergeTest.kt
index 2225ee3f..e3b4ba2e 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/FlatMapMergeTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/FlatMapMergeTest.kt
@@ -1,6 +1,7 @@
package kotlinx.coroutines.flow
import kotlinx.coroutines.*
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class FlatMapMergeTest : FlatMapMergeBaseTest() {
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/FlattenConcatTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/FlattenConcatTest.kt
index fbe714a2..31741b44 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/FlattenConcatTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/FlattenConcatTest.kt
@@ -1,6 +1,7 @@
package kotlinx.coroutines.flow
import kotlinx.coroutines.*
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class FlattenConcatTest : FlatMapBaseTest() {
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/FlowContextOptimizationsTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/FlowContextOptimizationsTest.kt
index 94735c60..32022c4c 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/FlowContextOptimizationsTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/FlowContextOptimizationsTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/FlowOnTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/FlowOnTest.kt
index feb5a71e..bb0fabb8 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/FlowOnTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/FlowOnTest.kt
@@ -1,7 +1,9 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
+import kotlinx.coroutines.testing.flow.*
import kotlin.test.*
class FlowOnTest : TestBase() {
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/IndexedTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/IndexedTest.kt
index c9b84781..420bfc8f 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/IndexedTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/IndexedTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/LintTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/LintTest.kt
index d884d9cd..6d0391f7 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/LintTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/LintTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow.operators
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/MapNotNullTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/MapNotNullTest.kt
index 8eb766db..f2aa3cca 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/MapNotNullTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/MapNotNullTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/MapTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/MapTest.kt
index 63b538ac..11d1d4da 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/MapTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/MapTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/MergeTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/MergeTest.kt
index 2234c0c4..694db251 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/MergeTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/MergeTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
import kotlinx.coroutines.flow.merge as originalMerge
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/OnCompletionTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/OnCompletionTest.kt
index 94f2302b..8fc9285f 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/OnCompletionTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/OnCompletionTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.flow.internal.*
@@ -30,10 +31,10 @@ class OnCompletionTest : TestBase() {
expect(1)
throw TestException()
}.onCompletion {
- assertTrue(it is TestException)
+ assertIs<TestException>(it)
expect(2)
}.catch {
- assertTrue(it is TestException)
+ assertIs<TestException>(it)
expect(3)
}.collect()
finish(4)
@@ -47,13 +48,13 @@ class OnCompletionTest : TestBase() {
}.onEach {
expect(2)
}.onCompletion {
- assertTrue(it is TestException) // flow fails because of this exception
+ assertIs<TestException>(it) // flow fails because of this exception
expect(4)
}.onEach {
expect(3)
throw TestException()
}.catch {
- assertTrue(it is TestException)
+ assertIs<TestException>(it)
expect(5)
}.collect()
finish(6)
@@ -62,16 +63,16 @@ class OnCompletionTest : TestBase() {
@Test
fun testMultipleOnCompletions() = runTest {
flowOf(1).onCompletion {
- assertTrue(it is TestException)
+ assertIs<TestException>(it)
expect(2)
}.onEach {
expect(1)
throw TestException()
}.onCompletion {
- assertTrue(it is TestException)
+ assertIs<TestException>(it)
expect(3)
}.catch {
- assertTrue(it is TestException)
+ assertIs<TestException>(it)
expect(4)
}.collect()
finish(5)
@@ -86,7 +87,7 @@ class OnCompletionTest : TestBase() {
expect(2)
throw TestException2()
}.catch {
- assertTrue(it is TestException2)
+ assertIs<TestException2>(it)
expect(3)
}.collect()
finish(4)
@@ -105,7 +106,7 @@ class OnCompletionTest : TestBase() {
throw TestException()
}
.catch {
- assertTrue(it is TestException)
+ assertIs<TestException>(it)
expect(3)
}.collect()
finish(4)
@@ -141,7 +142,7 @@ class OnCompletionTest : TestBase() {
}
.onCompletion { e ->
expect(8)
- assertTrue(e is TestException)
+ assertIs<TestException>(e)
emit(TestData.Done(e)) // will fail
}.collect {
collected += it
@@ -168,7 +169,7 @@ class OnCompletionTest : TestBase() {
}
.onCompletion { e ->
expect(8)
- assertTrue(e is CancellationException)
+ assertIs<CancellationException>(e)
try {
emit(TestData.Done(e))
expectUnreached()
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/OnEachTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/OnEachTest.kt
index 30e04205..9698b28f 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/OnEachTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/OnEachTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/OnEmptyTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/OnEmptyTest.kt
index e94b9b28..cca77083 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/OnEmptyTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/OnEmptyTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow.operators
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/OnStartTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/OnStartTest.kt
index c91a5234..15fc4b52 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/OnStartTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/OnStartTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/RetryTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/RetryTest.kt
index e064efd7..41377cba 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/RetryTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/RetryTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
@@ -12,12 +13,12 @@ class RetryTest : TestBase() {
throw TestException()
}
val sum = flow.retryWhen { cause, attempt ->
- assertTrue(cause is TestException)
+ assertIs<TestException>(cause)
expect(2 + attempt.toInt())
attempt < 3
}.catch { cause ->
expect(6)
- assertTrue(cause is TestException)
+ assertIs<TestException>(cause)
}.sum()
assertEquals(4, sum)
finish(7)
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/SampleTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/SampleTest.kt
index 1d031d47..781587d2 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/SampleTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/SampleTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow.operators
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.flow.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/ScanTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/ScanTest.kt
index 94d3e74c..7f19f97f 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/ScanTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/ScanTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/TakeTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/TakeTest.kt
index 4c80235f..3ecc2f4a 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/TakeTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/TakeTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/TakeWhileTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/TakeWhileTest.kt
index b050fe2f..f097b777 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/TakeWhileTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/TakeWhileTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/TimeoutTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/TimeoutTest.kt
index d07c9cde..a2ca101e 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/TimeoutTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/TimeoutTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow.operators
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.flow.internal.*
@@ -240,7 +241,7 @@ class TimeoutTest : TestBase() {
expect(1)
val flow = emptyFlow<Int>().timeout(timeout)
flow::collect.startCoroutine(NopCollector, Continuation(EmptyCoroutineContext) {
- assertTrue(it.exceptionOrNull() is TimeoutCancellationException)
+ assertIs<TimeoutCancellationException>(it.exceptionOrNull())
finish(2)
})
}
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/TransformLatestTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/TransformLatestTest.kt
index 75d47b9e..e072eabd 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/TransformLatestTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/TransformLatestTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/TransformTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/TransformTest.kt
index b045e5d0..b70460a0 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/TransformTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/TransformTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/TransformWhileTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/TransformWhileTest.kt
index fa7a7543..4da0d26a 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/TransformWhileTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/TransformWhileTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/operators/ZipTest.kt b/kotlinx-coroutines-core/common/test/flow/operators/ZipTest.kt
index c0cd3dc0..1f770dfe 100644
--- a/kotlinx-coroutines-core/common/test/flow/operators/ZipTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/operators/ZipTest.kt
@@ -1,25 +1,23 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
-/*
- * Replace: { i, j -> i + j } -> ::sum as soon as KT-30991 is fixed
- */
class ZipTest : TestBase() {
@Test
fun testZip() = runTest {
val f1 = flowOf("a", "b", "c")
val f2 = flowOf(1, 2, 3)
- assertEquals(listOf("a1", "b2", "c3"), f1.zip(f2, { i, j -> i + j }).toList())
+ assertEquals(listOf("a1", "b2", "c3"), f1.zip(f2, String::plus).toList())
}
@Test
fun testUnevenZip() = runTest {
val f1 = flowOf("a", "b", "c", "d", "e")
val f2 = flowOf(1, 2, 3)
- assertEquals(listOf("a1", "b2", "c3"), f1.zip(f2) { i, j -> i + j }.toList())
+ assertEquals(listOf("a1", "b2", "c3"), f1.zip(f2, String::plus).toList())
assertEquals(listOf("a1", "b2", "c3"), f2.zip(f1) { i, j -> j + i }.toList())
}
@@ -27,35 +25,35 @@ class ZipTest : TestBase() {
fun testEmptyFlows() = runTest {
val f1 = emptyFlow<String>()
val f2 = emptyFlow<Int>()
- assertEquals(emptyList(), f1.zip(f2, { i, j -> i + j }).toList())
+ assertEquals(emptyList(), f1.zip(f2, String::plus).toList())
}
@Test
fun testEmpty() = runTest {
val f1 = emptyFlow<String>()
val f2 = flowOf(1)
- assertEquals(emptyList(), f1.zip(f2, { i, j -> i + j }).toList())
+ assertEquals(emptyList(), f1.zip(f2, String::plus).toList())
}
@Test
fun testEmptyOther() = runTest {
val f1 = flowOf("a")
val f2 = emptyFlow<Int>()
- assertEquals(emptyList(), f1.zip(f2, { i, j -> i + j }).toList())
+ assertEquals(emptyList(), f1.zip(f2, String::plus).toList())
}
@Test
fun testNulls() = runTest {
val f1 = flowOf("a", null, null, "d")
val f2 = flowOf(1, 2, 3)
- assertEquals(listOf("a1", "null2", "null3"), f1.zip(f2, { i, j -> i + j }).toList())
+ assertEquals(listOf("a1", "null2", "null3"), f1.zip(f2, String?::plus).toList())
}
@Test
fun testNullsOther() = runTest {
val f1 = flowOf("a", "b", "c")
val f2 = flowOf(1, null, null, 2)
- assertEquals(listOf("a1", "bnull", "cnull"), f1.zip(f2, { i, j -> i + j }).toList())
+ assertEquals(listOf("a1", "bnull", "cnull"), f1.zip(f2, String::plus).toList())
}
@Test
@@ -70,7 +68,7 @@ class ZipTest : TestBase() {
emit("b")
expectUnreached()
}
- assertEquals(listOf("1a", "2b"), f1.zip(f2) { s1, s2 -> s1 + s2 }.toList())
+ assertEquals(listOf("1a", "2b"), f1.zip(f2, String::plus).toList())
finish(1)
}
@@ -88,7 +86,7 @@ class ZipTest : TestBase() {
}
val f2 = flowOf("a", "b")
- assertEquals(listOf("1a", "2b"), f1.zip(f2) { s1, s2 -> s1 + s2 }.toList())
+ assertEquals(listOf("1a", "2b"), f1.zip(f2, String::plus).toList())
finish(2)
}
@@ -108,7 +106,7 @@ class ZipTest : TestBase() {
yield()
}
- assertEquals(listOf("a1", "b2"), f2.zip(f1) { s1, s2 -> s1 + s2 }.toList())
+ assertEquals(listOf("a1", "b2"), f2.zip(f1, String::plus).toList())
finish(2)
}
@@ -248,6 +246,6 @@ class ZipTest : TestBase() {
yield()
}
- f1.zip(f2) { a, b -> a + b }.collect { }
+ f1.zip(f2, String::plus).collect { }
}
}
diff --git a/kotlinx-coroutines-core/common/test/flow/sharing/ShareInBufferTest.kt b/kotlinx-coroutines-core/common/test/flow/sharing/ShareInBufferTest.kt
index 036ea7c4..8871e318 100644
--- a/kotlinx-coroutines-core/common/test/flow/sharing/ShareInBufferTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/sharing/ShareInBufferTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.math.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/sharing/ShareInConflationTest.kt b/kotlinx-coroutines-core/common/test/flow/sharing/ShareInConflationTest.kt
index c4c2b66c..73d14acc 100644
--- a/kotlinx-coroutines-core/common/test/flow/sharing/ShareInConflationTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/sharing/ShareInConflationTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/sharing/ShareInFusionTest.kt b/kotlinx-coroutines-core/common/test/flow/sharing/ShareInFusionTest.kt
index 9e1277e5..c7b46508 100644
--- a/kotlinx-coroutines-core/common/test/flow/sharing/ShareInFusionTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/sharing/ShareInFusionTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/sharing/ShareInTest.kt b/kotlinx-coroutines-core/common/test/flow/sharing/ShareInTest.kt
index 414d708f..1df59b91 100644
--- a/kotlinx-coroutines-core/common/test/flow/sharing/ShareInTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/sharing/ShareInTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
@@ -100,7 +101,7 @@ class ShareInTest : TestBase() {
sharingJob.join() // should complete sharing
assertEquals(listOf("OK"), shared.replayCache) // cache is still there
if (failed) {
- assertTrue(sharingJob.getCompletionExceptionOrNull() is TestException)
+ assertIs<TestException>(sharingJob.getCompletionExceptionOrNull())
} else {
assertNull(sharingJob.getCompletionExceptionOrNull())
}
diff --git a/kotlinx-coroutines-core/common/test/flow/sharing/SharedFlowScenarioTest.kt b/kotlinx-coroutines-core/common/test/flow/sharing/SharedFlowScenarioTest.kt
index 056df9af..f4417e10 100644
--- a/kotlinx-coroutines-core/common/test/flow/sharing/SharedFlowScenarioTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/sharing/SharedFlowScenarioTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.coroutines.*
diff --git a/kotlinx-coroutines-core/common/test/flow/sharing/SharedFlowTest.kt b/kotlinx-coroutines-core/common/test/flow/sharing/SharedFlowTest.kt
index eb72bb06..eab4b79a 100644
--- a/kotlinx-coroutines-core/common/test/flow/sharing/SharedFlowTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/sharing/SharedFlowTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.random.*
@@ -610,7 +611,7 @@ class SharedFlowTest : TestBase() {
throw TestException()
}
.catch { e ->
- assertTrue(e is TestException)
+ assertIs<TestException>(e)
expect(3)
}
.collect {
diff --git a/kotlinx-coroutines-core/common/test/flow/sharing/SharingStartedTest.kt b/kotlinx-coroutines-core/common/test/flow/sharing/SharingStartedTest.kt
index 17b6254a..09450a1c 100644
--- a/kotlinx-coroutines-core/common/test/flow/sharing/SharingStartedTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/sharing/SharingStartedTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/sharing/SharingStartedWhileSubscribedTest.kt b/kotlinx-coroutines-core/common/test/flow/sharing/SharingStartedWhileSubscribedTest.kt
index 3149e3a6..c8199f51 100644
--- a/kotlinx-coroutines-core/common/test/flow/sharing/SharingStartedWhileSubscribedTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/sharing/SharingStartedWhileSubscribedTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
import kotlin.time.*
diff --git a/kotlinx-coroutines-core/common/test/flow/sharing/StateFlowTest.kt b/kotlinx-coroutines-core/common/test/flow/sharing/StateFlowTest.kt
index 3500b791..f8c1a835 100644
--- a/kotlinx-coroutines-core/common/test/flow/sharing/StateFlowTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/sharing/StateFlowTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
@@ -141,7 +142,7 @@ class StateFlowTest : TestBase() {
}
}
.catch { e ->
- assertTrue(e is TestException)
+ assertIs<TestException>(e)
expect(6)
}
.launchIn(this)
diff --git a/kotlinx-coroutines-core/common/test/flow/sharing/StateInTest.kt b/kotlinx-coroutines-core/common/test/flow/sharing/StateInTest.kt
index 892fcd8f..75a5e4b9 100644
--- a/kotlinx-coroutines-core/common/test/flow/sharing/StateInTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/sharing/StateInTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
@@ -66,7 +67,7 @@ class StateInTest : TestBase() {
sharingJob.join() // should complete sharing
assertEquals("OK", shared.value) // value is still there
if (failed) {
- assertTrue(sharingJob.getCompletionExceptionOrNull() is TestException)
+ assertIs<TestException>(sharingJob.getCompletionExceptionOrNull())
} else {
assertNull(sharingJob.getCompletionExceptionOrNull())
}
diff --git a/kotlinx-coroutines-core/common/test/flow/terminal/CollectLatestTest.kt b/kotlinx-coroutines-core/common/test/flow/terminal/CollectLatestTest.kt
index df6cf4f2..2cecf8c4 100644
--- a/kotlinx-coroutines-core/common/test/flow/terminal/CollectLatestTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/terminal/CollectLatestTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/terminal/CountTest.kt b/kotlinx-coroutines-core/common/test/flow/terminal/CountTest.kt
index fed726b8..167fdec0 100644
--- a/kotlinx-coroutines-core/common/test/flow/terminal/CountTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/terminal/CountTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/terminal/FirstTest.kt b/kotlinx-coroutines-core/common/test/flow/terminal/FirstTest.kt
index d38a8d62..74336262 100644
--- a/kotlinx-coroutines-core/common/test/flow/terminal/FirstTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/terminal/FirstTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.flow.internal.*
diff --git a/kotlinx-coroutines-core/common/test/flow/terminal/FoldTest.kt b/kotlinx-coroutines-core/common/test/flow/terminal/FoldTest.kt
index 5149a118..350d0751 100644
--- a/kotlinx-coroutines-core/common/test/flow/terminal/FoldTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/terminal/FoldTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/terminal/LastTest.kt b/kotlinx-coroutines-core/common/test/flow/terminal/LastTest.kt
index f235d502..b424b2e6 100644
--- a/kotlinx-coroutines-core/common/test/flow/terminal/LastTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/terminal/LastTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/terminal/LaunchInTest.kt b/kotlinx-coroutines-core/common/test/flow/terminal/LaunchInTest.kt
index 6d1d56b4..e2b01f63 100644
--- a/kotlinx-coroutines-core/common/test/flow/terminal/LaunchInTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/terminal/LaunchInTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
@@ -15,7 +16,7 @@ class LaunchInTest : TestBase() {
assertEquals(1, it)
expect(2)
}.onCompletion {
- assertTrue(it is TestException)
+ assertIs<TestException>(it)
expect(3)
}.catch {
assertTrue { it is TestException }
diff --git a/kotlinx-coroutines-core/common/test/flow/terminal/ReduceTest.kt b/kotlinx-coroutines-core/common/test/flow/terminal/ReduceTest.kt
index 0574c63c..ee70063c 100644
--- a/kotlinx-coroutines-core/common/test/flow/terminal/ReduceTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/terminal/ReduceTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/terminal/SingleTest.kt b/kotlinx-coroutines-core/common/test/flow/terminal/SingleTest.kt
index 3d6bf9e9..b1741bb0 100644
--- a/kotlinx-coroutines-core/common/test/flow/terminal/SingleTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/terminal/SingleTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/flow/terminal/ToCollectionTest.kt b/kotlinx-coroutines-core/common/test/flow/terminal/ToCollectionTest.kt
index 7cce5cfe..a5c5fe65 100644
--- a/kotlinx-coroutines-core/common/test/flow/terminal/ToCollectionTest.kt
+++ b/kotlinx-coroutines-core/common/test/flow/terminal/ToCollectionTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/selects/SelectBiasTest.kt b/kotlinx-coroutines-core/common/test/selects/SelectBiasTest.kt
index b23169ab..42cdf945 100644
--- a/kotlinx-coroutines-core/common/test/selects/SelectBiasTest.kt
+++ b/kotlinx-coroutines-core/common/test/selects/SelectBiasTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.selects
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/selects/SelectBufferedChannelTest.kt b/kotlinx-coroutines-core/common/test/selects/SelectBufferedChannelTest.kt
index a8ddd130..3abee423 100644
--- a/kotlinx-coroutines-core/common/test/selects/SelectBufferedChannelTest.kt
+++ b/kotlinx-coroutines-core/common/test/selects/SelectBufferedChannelTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.selects
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
@@ -314,7 +315,7 @@ class SelectBufferedChannelTest : TestBase() {
channel.onReceiveCatching {
expect(5)
assertTrue(it.isClosed)
- assertTrue(it.exceptionOrNull() is TestException)
+ assertIs<TestException>(it.exceptionOrNull())
}
}
diff --git a/kotlinx-coroutines-core/common/test/selects/SelectDeferredTest.kt b/kotlinx-coroutines-core/common/test/selects/SelectDeferredTest.kt
index 077e5d05..0fc1b3be 100644
--- a/kotlinx-coroutines-core/common/test/selects/SelectDeferredTest.kt
+++ b/kotlinx-coroutines-core/common/test/selects/SelectDeferredTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines.selects
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/selects/SelectJobTest.kt b/kotlinx-coroutines-core/common/test/selects/SelectJobTest.kt
index 82448f1a..6af517c0 100644
--- a/kotlinx-coroutines-core/common/test/selects/SelectJobTest.kt
+++ b/kotlinx-coroutines-core/common/test/selects/SelectJobTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.selects
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/selects/SelectLoopTest.kt b/kotlinx-coroutines-core/common/test/selects/SelectLoopTest.kt
index e7a8ea08..dd83d4af 100644
--- a/kotlinx-coroutines-core/common/test/selects/SelectLoopTest.kt
+++ b/kotlinx-coroutines-core/common/test/selects/SelectLoopTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines.selects
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/selects/SelectMutexTest.kt b/kotlinx-coroutines-core/common/test/selects/SelectMutexTest.kt
index 14a49c6d..db3361f3 100644
--- a/kotlinx-coroutines-core/common/test/selects/SelectMutexTest.kt
+++ b/kotlinx-coroutines-core/common/test/selects/SelectMutexTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.selects
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.sync.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/selects/SelectOldTest.kt b/kotlinx-coroutines-core/common/test/selects/SelectOldTest.kt
index 493beaf5..b500c9ff 100644
--- a/kotlinx-coroutines-core/common/test/selects/SelectOldTest.kt
+++ b/kotlinx-coroutines-core/common/test/selects/SelectOldTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.selects
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/selects/SelectRendezvousChannelTest.kt b/kotlinx-coroutines-core/common/test/selects/SelectRendezvousChannelTest.kt
index 561ad4c6..36faaf4e 100644
--- a/kotlinx-coroutines-core/common/test/selects/SelectRendezvousChannelTest.kt
+++ b/kotlinx-coroutines-core/common/test/selects/SelectRendezvousChannelTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines.selects
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
@@ -336,7 +337,7 @@ class SelectRendezvousChannelTest : TestBase() {
channel.onReceiveCatching {
expect(5)
assertTrue(it.isClosed)
- assertTrue(it.exceptionOrNull() is TestException)
+ assertIs<TestException>(it.exceptionOrNull())
}
}
diff --git a/kotlinx-coroutines-core/common/test/selects/SelectTimeoutDurationTest.kt b/kotlinx-coroutines-core/common/test/selects/SelectTimeoutDurationTest.kt
index 23813d3a..f78e1c39 100644
--- a/kotlinx-coroutines-core/common/test/selects/SelectTimeoutDurationTest.kt
+++ b/kotlinx-coroutines-core/common/test/selects/SelectTimeoutDurationTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.selects
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
import kotlin.time.*
diff --git a/kotlinx-coroutines-core/common/test/selects/SelectTimeoutTest.kt b/kotlinx-coroutines-core/common/test/selects/SelectTimeoutTest.kt
index cf7f76c0..f3abfe4b 100644
--- a/kotlinx-coroutines-core/common/test/selects/SelectTimeoutTest.kt
+++ b/kotlinx-coroutines-core/common/test/selects/SelectTimeoutTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.selects
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/selects/SelectUnlimitedChannelTest.kt b/kotlinx-coroutines-core/common/test/selects/SelectUnlimitedChannelTest.kt
index d65f7cf5..e460bd70 100644
--- a/kotlinx-coroutines-core/common/test/selects/SelectUnlimitedChannelTest.kt
+++ b/kotlinx-coroutines-core/common/test/selects/SelectUnlimitedChannelTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.selects
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/sync/MutexTest.kt b/kotlinx-coroutines-core/common/test/sync/MutexTest.kt
index cb4c2915..7c6b8ab6 100644
--- a/kotlinx-coroutines-core/common/test/sync/MutexTest.kt
+++ b/kotlinx-coroutines-core/common/test/sync/MutexTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.sync
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.selects.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/common/test/sync/SemaphoreTest.kt b/kotlinx-coroutines-core/common/test/sync/SemaphoreTest.kt
index e39f2f18..89f066c2 100644
--- a/kotlinx-coroutines-core/common/test/sync/SemaphoreTest.kt
+++ b/kotlinx-coroutines-core/common/test/sync/SemaphoreTest.kt
@@ -1,10 +1,8 @@
package kotlinx.coroutines.sync
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
-import kotlin.test.Test
-import kotlin.test.assertEquals
-import kotlin.test.assertFalse
-import kotlin.test.assertTrue
+import kotlin.test.*
class SemaphoreTest : TestBase() {
diff --git a/kotlinx-coroutines-core/concurrent/test/AbstractDispatcherConcurrencyTest.kt b/kotlinx-coroutines-core/concurrent/test/AbstractDispatcherConcurrencyTest.kt
index ac56f996..b7648eb6 100644
--- a/kotlinx-coroutines-core/concurrent/test/AbstractDispatcherConcurrencyTest.kt
+++ b/kotlinx-coroutines-core/concurrent/test/AbstractDispatcherConcurrencyTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/concurrent/test/AtomicCancellationTest.kt b/kotlinx-coroutines-core/concurrent/test/AtomicCancellationTest.kt
index 65236869..d43c307b 100644
--- a/kotlinx-coroutines-core/concurrent/test/AtomicCancellationTest.kt
+++ b/kotlinx-coroutines-core/concurrent/test/AtomicCancellationTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.selects.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/concurrent/test/CommonThreadLocalTest.kt b/kotlinx-coroutines-core/concurrent/test/CommonThreadLocalTest.kt
index 3dad74e7..b692e2d0 100644
--- a/kotlinx-coroutines-core/concurrent/test/CommonThreadLocalTest.kt
+++ b/kotlinx-coroutines-core/concurrent/test/CommonThreadLocalTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.exceptions.*
import kotlinx.coroutines.internal.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/concurrent/test/ConcurrentExceptionsStressTest.kt b/kotlinx-coroutines-core/concurrent/test/ConcurrentExceptionsStressTest.kt
index 9515a387..a3fa590c 100644
--- a/kotlinx-coroutines-core/concurrent/test/ConcurrentExceptionsStressTest.kt
+++ b/kotlinx-coroutines-core/concurrent/test/ConcurrentExceptionsStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.exceptions.*
import kotlinx.coroutines.internal.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/concurrent/test/JobStructuredJoinStressTest.kt b/kotlinx-coroutines-core/concurrent/test/JobStructuredJoinStressTest.kt
index fb52662f..4abb4958 100644
--- a/kotlinx-coroutines-core/concurrent/test/JobStructuredJoinStressTest.kt
+++ b/kotlinx-coroutines-core/concurrent/test/JobStructuredJoinStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/concurrent/test/LimitedParallelismConcurrentTest.kt b/kotlinx-coroutines-core/concurrent/test/LimitedParallelismConcurrentTest.kt
index cb4c598e..5985aaa1 100644
--- a/kotlinx-coroutines-core/concurrent/test/LimitedParallelismConcurrentTest.kt
+++ b/kotlinx-coroutines-core/concurrent/test/LimitedParallelismConcurrentTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.atomicfu.*
import kotlinx.coroutines.*
import kotlinx.coroutines.exceptions.*
diff --git a/kotlinx-coroutines-core/concurrent/test/RunBlockingTest.kt b/kotlinx-coroutines-core/concurrent/test/RunBlockingTest.kt
index fae433a7..f04b491c 100644
--- a/kotlinx-coroutines-core/concurrent/test/RunBlockingTest.kt
+++ b/kotlinx-coroutines-core/concurrent/test/RunBlockingTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.exceptions.*
import kotlin.coroutines.*
import kotlin.test.*
@@ -23,7 +24,7 @@ class RunBlockingTest : TestBase() {
expect(1)
runBlocking {
expect(2)
- assertTrue(coroutineContext[ContinuationInterceptor] is EventLoop)
+ assertIs<EventLoop>(coroutineContext[ContinuationInterceptor])
yield() // is supported!
expect(3)
}
diff --git a/kotlinx-coroutines-core/concurrent/test/channels/BroadcastChannelSubStressTest.kt b/kotlinx-coroutines-core/concurrent/test/channels/BroadcastChannelSubStressTest.kt
index 70635030..8f6a8e0c 100644
--- a/kotlinx-coroutines-core/concurrent/test/channels/BroadcastChannelSubStressTest.kt
+++ b/kotlinx-coroutines-core/concurrent/test/channels/BroadcastChannelSubStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.atomicfu.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/concurrent/test/channels/ChannelCancelUndeliveredElementStressTest.kt b/kotlinx-coroutines-core/concurrent/test/channels/ChannelCancelUndeliveredElementStressTest.kt
index 41771387..292d5bda 100644
--- a/kotlinx-coroutines-core/concurrent/test/channels/ChannelCancelUndeliveredElementStressTest.kt
+++ b/kotlinx-coroutines-core/concurrent/test/channels/ChannelCancelUndeliveredElementStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.atomicfu.*
import kotlinx.coroutines.*
import kotlinx.coroutines.selects.*
@@ -77,7 +78,7 @@ class ChannelCancelUndeliveredElementStressTest : TestBase() {
}
}
} catch (e: Throwable) {
- assertTrue(e is CancellationException) // the only exception possible in this test
+ assertIs<CancellationException>(e) // the only exception possible in this test
dSendExceptionCnt++
throw e
}
diff --git a/kotlinx-coroutines-core/concurrent/test/channels/ConflatedBroadcastChannelNotifyStressTest.kt b/kotlinx-coroutines-core/concurrent/test/channels/ConflatedBroadcastChannelNotifyStressTest.kt
index 825b99df..a9e8756d 100644
--- a/kotlinx-coroutines-core/concurrent/test/channels/ConflatedBroadcastChannelNotifyStressTest.kt
+++ b/kotlinx-coroutines-core/concurrent/test/channels/ConflatedBroadcastChannelNotifyStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.atomicfu.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/concurrent/test/channels/TrySendBlockingTest.kt b/kotlinx-coroutines-core/concurrent/test/channels/TrySendBlockingTest.kt
index 674d588f..4a485503 100644
--- a/kotlinx-coroutines-core/concurrent/test/channels/TrySendBlockingTest.kt
+++ b/kotlinx-coroutines-core/concurrent/test/channels/TrySendBlockingTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
@@ -26,7 +27,7 @@ class TrySendBlockingTest : TestBase() {
val channel = Channel<Unit>().also { it.close() }
channel.trySendBlocking(Unit)
.onSuccess { expectUnreached() }
- .onFailure { assertTrue(it is ClosedSendChannelException) }
+ .onFailure { assertIs<ClosedSendChannelException>(it) }
.also { assertTrue { it.isClosed } }
}
@@ -34,7 +35,7 @@ class TrySendBlockingTest : TestBase() {
val channel = Channel<Unit>().also { it.close(TestException()) }
channel.trySendBlocking(Unit)
.onSuccess { expectUnreached() }
- .onFailure { assertTrue(it is TestException) }
+ .onFailure { assertIs<TestException>(it) }
.also { assertTrue { it.isClosed } }
}
@@ -42,7 +43,7 @@ class TrySendBlockingTest : TestBase() {
val channel = Channel<Unit>().also { it.cancel(TestCancellationException()) }
channel.trySendBlocking(Unit)
.onSuccess { expectUnreached() }
- .onFailure { assertTrue(it is TestCancellationException) }
+ .onFailure { assertIs<TestCancellationException>(it) }
.also { assertTrue { it.isClosed } }
}
}
diff --git a/kotlinx-coroutines-core/concurrent/test/flow/CombineStressTest.kt b/kotlinx-coroutines-core/concurrent/test/flow/CombineStressTest.kt
index a284f44b..102d7d2d 100644
--- a/kotlinx-coroutines-core/concurrent/test/flow/CombineStressTest.kt
+++ b/kotlinx-coroutines-core/concurrent/test/flow/CombineStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/concurrent/test/flow/FlowCancellationTest.kt b/kotlinx-coroutines-core/concurrent/test/flow/FlowCancellationTest.kt
index 03345872..4e365637 100644
--- a/kotlinx-coroutines-core/concurrent/test/flow/FlowCancellationTest.kt
+++ b/kotlinx-coroutines-core/concurrent/test/flow/FlowCancellationTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.flow.*
diff --git a/kotlinx-coroutines-core/concurrent/test/flow/StateFlowCommonStressTest.kt b/kotlinx-coroutines-core/concurrent/test/flow/StateFlowCommonStressTest.kt
index 9490e467..e066052f 100644
--- a/kotlinx-coroutines-core/concurrent/test/flow/StateFlowCommonStressTest.kt
+++ b/kotlinx-coroutines-core/concurrent/test/flow/StateFlowCommonStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.random.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/concurrent/test/flow/StateFlowUpdateCommonTest.kt b/kotlinx-coroutines-core/concurrent/test/flow/StateFlowUpdateCommonTest.kt
index ad4d7920..a4a5118a 100644
--- a/kotlinx-coroutines-core/concurrent/test/flow/StateFlowUpdateCommonTest.kt
+++ b/kotlinx-coroutines-core/concurrent/test/flow/StateFlowUpdateCommonTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/concurrent/test/selects/SelectChannelStressTest.kt b/kotlinx-coroutines-core/concurrent/test/selects/SelectChannelStressTest.kt
index a5d9dd46..32098b29 100644
--- a/kotlinx-coroutines-core/concurrent/test/selects/SelectChannelStressTest.kt
+++ b/kotlinx-coroutines-core/concurrent/test/selects/SelectChannelStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.selects
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/concurrent/test/selects/SelectMutexStressTest.kt b/kotlinx-coroutines-core/concurrent/test/selects/SelectMutexStressTest.kt
index 021bf02e..e8c2c822 100644
--- a/kotlinx-coroutines-core/concurrent/test/selects/SelectMutexStressTest.kt
+++ b/kotlinx-coroutines-core/concurrent/test/selects/SelectMutexStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.selects
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.sync.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/concurrent/test/sync/MutexStressTest.kt b/kotlinx-coroutines-core/concurrent/test/sync/MutexStressTest.kt
index 30b1379a..8c8f04f8 100644
--- a/kotlinx-coroutines-core/concurrent/test/sync/MutexStressTest.kt
+++ b/kotlinx-coroutines-core/concurrent/test/sync/MutexStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.sync
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.exceptions.*
import kotlinx.coroutines.selects.*
diff --git a/kotlinx-coroutines-core/concurrent/test/sync/SemaphoreStressTest.kt b/kotlinx-coroutines-core/concurrent/test/sync/SemaphoreStressTest.kt
index b0db0681..4be485d7 100644
--- a/kotlinx-coroutines-core/concurrent/test/sync/SemaphoreStressTest.kt
+++ b/kotlinx-coroutines-core/concurrent/test/sync/SemaphoreStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.sync
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.exceptions.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/js/test/PromiseTest.kt b/kotlinx-coroutines-core/js/test/PromiseTest.kt
index 4d309d55..319778dd 100644
--- a/kotlinx-coroutines-core/js/test/PromiseTest.kt
+++ b/kotlinx-coroutines-core/js/test/PromiseTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.js.*
import kotlin.test.*
@@ -26,7 +27,7 @@ class PromiseTest : TestBase() {
deferred.await()
expectUnreached()
} catch (e: Throwable) {
- assertTrue(e is TestException)
+ assertIs<TestException>(e)
assertEquals("Rejected", e.message)
}
}
diff --git a/kotlinx-coroutines-core/js/test/TestBase.kt b/kotlinx-coroutines-core/js/test/TestBase.kt
deleted file mode 100644
index 7a3c6eff..00000000
--- a/kotlinx-coroutines-core/js/test/TestBase.kt
+++ /dev/null
@@ -1,141 +0,0 @@
-package kotlinx.coroutines
-
-import kotlin.js.*
-
-public actual val isStressTest: Boolean = false
-public actual val stressTestMultiplier: Int = 1
-public actual val stressTestMultiplierSqrt: Int = 1
-
-@Suppress("ACTUAL_WITHOUT_EXPECT", "ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE")
-public actual typealias TestResult = Promise<Unit>
-
-public actual val isNative = false
-
-public actual open class TestBase actual constructor() {
- public actual val isBoundByJsTestTimeout = true
- private var actionIndex = 0
- private var finished = false
- private var error: Throwable? = null
- private var lastTestPromise: Promise<*>? = null
-
- /**
- * Throws [IllegalStateException] like `error` in stdlib, but also ensures that the test will not
- * complete successfully even if this exception is consumed somewhere in the test.
- */
- public actual fun error(message: Any, cause: Throwable?): Nothing {
- if (cause != null) console.log(cause)
- val exception = IllegalStateException(
- if (cause == null) message.toString() else "$message; caused by $cause")
- if (error == null) error = exception
- throw exception
- }
-
- private fun printError(message: String, cause: Throwable) {
- if (error == null) error = cause
- println("$message: $cause")
- console.log(cause)
- }
-
- /**
- * Asserts that this invocation is `index`-th in the execution sequence (counting from one).
- */
- public actual fun expect(index: Int) {
- val wasIndex = ++actionIndex
- check(index == wasIndex) { "Expecting action index $index but it is actually $wasIndex" }
- }
-
- /**
- * Asserts that this line is never executed.
- */
- public actual fun expectUnreached() {
- error("Should not be reached")
- }
-
- /**
- * Asserts that this it the last action in the test. It must be invoked by any test that used [expect].
- */
- public actual fun finish(index: Int) {
- expect(index)
- check(!finished) { "Should call 'finish(...)' at most once" }
- finished = true
- }
-
- /**
- * Asserts that [finish] was invoked
- */
- public actual fun ensureFinished() {
- require(finished) { "finish(...) should be caller prior to this check" }
- }
-
- public actual fun reset() {
- check(actionIndex == 0 || finished) { "Expecting that 'finish(...)' was invoked, but it was not" }
- actionIndex = 0
- finished = false
- }
-
- actual fun println(message: Any?) {
- kotlin.io.println(message)
- }
-
- @Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
- public actual fun runTest(
- expected: ((Throwable) -> Boolean)? = null,
- unhandled: List<(Throwable) -> Boolean> = emptyList(),
- block: suspend CoroutineScope.() -> Unit
- ): TestResult {
- var exCount = 0
- var ex: Throwable? = null
- /*
- * This is an additional sanity check against `runTest` mis-usage on JS.
- * The only way to write an async test on JS is to return Promise from the test function.
- * _Just_ launching promise and returning `Unit` won't suffice as the underlying test framework
- * won't be able to detect an asynchronous failure in a timely manner.
- * We cannot detect such situations, but we can detect the most common erroneous pattern
- * in our code base, an attempt to use multiple `runTest` in the same `@Test` method,
- * which typically is a premise to the same error:
- * ```
- * @Test
- * fun incorrectTestForJs() { // <- promise is not returned
- * for (parameter in parameters) {
- * runTest {
- * runTestForParameter(parameter)
- * }
- * }
- * }
- * ```
- */
- if (lastTestPromise != null) {
- error("Attempt to run multiple asynchronous test within one @Test method")
- }
- val result = GlobalScope.promise(block = block, context = CoroutineExceptionHandler { _, e ->
- if (e is CancellationException) return@CoroutineExceptionHandler // are ignored
- exCount++
- when {
- exCount > unhandled.size ->
- printError("Too many unhandled exceptions $exCount, expected ${unhandled.size}, got: $e", e)
- !unhandled[exCount - 1](e) ->
- printError("Unhandled exception was unexpected: $e", e)
- }
- }).catch { e ->
- ex = e
- if (expected != null) {
- if (!expected(e))
- error("Unexpected exception", e)
- } else
- throw e
- }.finally {
- if (ex == null && expected != null) error("Exception was expected but none produced")
- if (exCount < unhandled.size)
- error("Too few unhandled exceptions $exCount, expected ${unhandled.size}")
- error?.let { throw it }
- check(actionIndex == 0 || finished) { "Expecting that 'finish(...)' was invoked, but it was not" }
- }
- lastTestPromise = result
- return result
- }
-}
-
-private fun <T> Promise<T>.finally(block: () -> Unit): Promise<T> =
- then(onFulfilled = { value -> block(); value }, onRejected = { ex -> block(); throw ex })
-
-public actual val isJavaAndWindows: Boolean get() = false
diff --git a/kotlinx-coroutines-core/jsAndWasmShared/test/ImmediateDispatcherTest.kt b/kotlinx-coroutines-core/jsAndWasmShared/test/ImmediateDispatcherTest.kt
index e5322ee4..936713b2 100644
--- a/kotlinx-coroutines-core/jsAndWasmShared/test/ImmediateDispatcherTest.kt
+++ b/kotlinx-coroutines-core/jsAndWasmShared/test/ImmediateDispatcherTest.kt
@@ -1,5 +1,7 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
+import kotlinx.coroutines.testing.*
import kotlin.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jsAndWasmShared/test/SetTimeoutDispatcherTest.kt b/kotlinx-coroutines-core/jsAndWasmShared/test/SetTimeoutDispatcherTest.kt
index 97f303e1..3b4e422e 100644
--- a/kotlinx-coroutines-core/jsAndWasmShared/test/SetTimeoutDispatcherTest.kt
+++ b/kotlinx-coroutines-core/jsAndWasmShared/test/SetTimeoutDispatcherTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class SetTimeoutDispatcherTest : TestBase() {
diff --git a/kotlinx-coroutines-core/jvm/src/AbstractTimeSource.kt b/kotlinx-coroutines-core/jvm/src/AbstractTimeSource.kt
index ed86f3a5..f497dc80 100644
--- a/kotlinx-coroutines-core/jvm/src/AbstractTimeSource.kt
+++ b/kotlinx-coroutines-core/jvm/src/AbstractTimeSource.kt
@@ -20,7 +20,12 @@ internal abstract class AbstractTimeSource {
// For tests only
// @JvmField: Don't use JvmField here to enable R8 optimizations via "assumenosideeffects"
-internal var timeSource: AbstractTimeSource? = null
+private var timeSource: AbstractTimeSource? = null
+
+// TODO: without this, there's a compilation error. Why?
+internal inline fun mockTimeSource(source: AbstractTimeSource?) {
+ timeSource = source
+}
@InlineOnly
internal inline fun currentTimeMillis(): Long =
diff --git a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testOfferFromScope.txt b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testOfferFromScope.txt
index aa5a6a17..de14e9da 100644
--- a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testOfferFromScope.txt
+++ b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testOfferFromScope.txt
@@ -1,10 +1,10 @@
-kotlinx.coroutines.RecoverableTestException
+kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$testOfferFromScope$1.invokeSuspend(StackTraceRecoveryChannelsTest.kt:109)
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest.sendInChannel(StackTraceRecoveryChannelsTest.kt:167)
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$sendWithContext$2.invokeSuspend(StackTraceRecoveryChannelsTest.kt:162)
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$sendFromScope$2.invokeSuspend(StackTraceRecoveryChannelsTest.kt:172)
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$testOfferFromScope$1.invokeSuspend(StackTraceRecoveryChannelsTest.kt:112)
-Caused by: kotlinx.coroutines.RecoverableTestException
+Caused by: kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$testOfferFromScope$1.invokeSuspend(StackTraceRecoveryChannelsTest.kt:109)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
diff --git a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testOfferWithContextWrapped.txt b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testOfferWithContextWrapped.txt
index 4908d3be..1a153d3e 100644
--- a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testOfferWithContextWrapped.txt
+++ b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testOfferWithContextWrapped.txt
@@ -1,9 +1,9 @@
-kotlinx.coroutines.RecoverableTestException
+kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$testOfferWithContextWrapped$1.invokeSuspend(StackTraceRecoveryChannelsTest.kt:98)
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest.sendInChannel(StackTraceRecoveryChannelsTest.kt:199)
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$sendWithContext$2.invokeSuspend(StackTraceRecoveryChannelsTest.kt:194)
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$testOfferWithContextWrapped$1.invokeSuspend(StackTraceRecoveryChannelsTest.kt:100)
-Caused by: kotlinx.coroutines.RecoverableTestException
+Caused by: kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$testOfferWithContextWrapped$1.invokeSuspend(StackTraceRecoveryChannelsTest.kt:98)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
diff --git a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testOfferWithCurrentContext.txt b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testOfferWithCurrentContext.txt
index 1eb464c7..5bc7124c 100644
--- a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testOfferWithCurrentContext.txt
+++ b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testOfferWithCurrentContext.txt
@@ -1,9 +1,9 @@
-kotlinx.coroutines.RecoverableTestException
+kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$testOfferWithCurrentContext$1.invokeSuspend(StackTraceRecoveryChannelsTest.kt:86)
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest.sendInChannel(StackTraceRecoveryChannelsTest.kt:210)
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$sendWithContext$2.invokeSuspend(StackTraceRecoveryChannelsTest.kt:205)
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$testOfferWithCurrentContext$1.invokeSuspend(StackTraceRecoveryChannelsTest.kt:89)
-Caused by: kotlinx.coroutines.RecoverableTestException
+Caused by: kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$testOfferWithCurrentContext$1.invokeSuspend(StackTraceRecoveryChannelsTest.kt:86)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
diff --git a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testReceiveFromChannel.txt b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testReceiveFromChannel.txt
index da3558ba..e02f709a 100644
--- a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testReceiveFromChannel.txt
+++ b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testReceiveFromChannel.txt
@@ -1,9 +1,9 @@
-kotlinx.coroutines.RecoverableTestException
+kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.channels.BufferedChannel.receive$suspendImpl(BufferedChannel.kt)
at kotlinx.coroutines.channels.BufferedChannel.receive(BufferedChannel.kt)
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest.channelReceive(StackTraceRecoveryChannelsTest.kt)
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest.access$channelReceive(StackTraceRecoveryChannelsTest.kt)
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$channelReceive$1.invokeSuspend(StackTraceRecoveryChannelsTest.kt)
-Caused by: kotlinx.coroutines.RecoverableTestException
+Caused by: kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$testReceiveFromChannel$1$job$1.invokeSuspend(StackTraceRecoveryChannelsTest.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt)
diff --git a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testReceiveFromClosedChannel.txt b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testReceiveFromClosedChannel.txt
index 3f392cd3..d4863005 100644
--- a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testReceiveFromClosedChannel.txt
+++ b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testReceiveFromClosedChannel.txt
@@ -1,8 +1,8 @@
-kotlinx.coroutines.RecoverableTestException
+kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$testReceiveFromClosedChannel$1.invokeSuspend(StackTraceRecoveryChannelsTest.kt:110)
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest.channelReceive(StackTraceRecoveryChannelsTest.kt:116)
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$testReceiveFromClosedChannel$1.invokeSuspend(StackTraceRecoveryChannelsTest.kt:111)
-Caused by: kotlinx.coroutines.RecoverableTestException
+Caused by: kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$testReceiveFromClosedChannel$1.invokeSuspend(StackTraceRecoveryChannelsTest.kt:110)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
diff --git a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testSendFromScope.txt b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testSendFromScope.txt
index 49c3628b..bc0f9cd7 100644
--- a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testSendFromScope.txt
+++ b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testSendFromScope.txt
@@ -1,10 +1,10 @@
-kotlinx.coroutines.RecoverableTestCancellationException
+kotlinx.coroutines.testing.RecoverableTestCancellationException
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$testSendFromScope$1.invokeSuspend(StackTraceRecoveryChannelsTest.kt:136)
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest.sendInChannel(StackTraceRecoveryChannelsTest.kt:167)
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$sendWithContext$2.invokeSuspend(StackTraceRecoveryChannelsTest.kt:162)
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$sendFromScope$2.invokeSuspend(StackTraceRecoveryChannelsTest.kt:172)
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$testSendFromScope$1$deferred$1.invokeSuspend(StackTraceRecoveryChannelsTest.kt:126)
-Caused by: kotlinx.coroutines.RecoverableTestCancellationException
+Caused by: kotlinx.coroutines.testing.RecoverableTestCancellationException
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$testSendFromScope$1.invokeSuspend(StackTraceRecoveryChannelsTest.kt:136)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
diff --git a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testSendToChannel.txt b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testSendToChannel.txt
index e40cc741..af6e5642 100644
--- a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testSendToChannel.txt
+++ b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testSendToChannel.txt
@@ -17,4 +17,4 @@ Caused by: java.util.concurrent.CancellationException: Channel was cancelled
at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt)
at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt)
at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
- at kotlinx.coroutines.TestBase.runTest(TestBase.kt)
+ at kotlinx.coroutines.testing.TestBase.runTest(TestBase.kt)
diff --git a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testSendToClosedChannel.txt b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testSendToClosedChannel.txt
index f2609594..cd200924 100644
--- a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testSendToClosedChannel.txt
+++ b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/channels/testSendToClosedChannel.txt
@@ -1,8 +1,8 @@
-kotlinx.coroutines.RecoverableTestException
+kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$testSendToClosedChannel$1.invokeSuspend(StackTraceRecoveryChannelsTest.kt:43)
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest.channelSend(StackTraceRecoveryChannelsTest.kt:74)
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$testSendToClosedChannel$1.invokeSuspend(StackTraceRecoveryChannelsTest.kt:44)
-Caused by: kotlinx.coroutines.RecoverableTestException
+Caused by: kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryChannelsTest$testSendToClosedChannel$1.invokeSuspend(StackTraceRecoveryChannelsTest.kt:43)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
diff --git a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testEventLoopDispatcher.txt b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testEventLoopDispatcher.txt
index 0e75e645..3c7ee94b 100644
--- a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testEventLoopDispatcher.txt
+++ b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testEventLoopDispatcher.txt
@@ -1,4 +1,4 @@
-kotlinx.coroutines.RecoverableTestException
+kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.testResumeModeFastPath(StackTraceRecoveryResumeModeTest.kt:61)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testEventLoopDispatcher$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:40)
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)
@@ -6,7 +6,7 @@ kotlinx.coroutines.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.doFastPath(StackTraceRecoveryResumeModeTest.kt:71)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.testResumeModeFastPath(StackTraceRecoveryResumeModeTest.kt:62)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testEventLoopDispatcher$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:40)
-Caused by: kotlinx.coroutines.RecoverableTestException
+Caused by: kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.testResumeModeFastPath(StackTraceRecoveryResumeModeTest.kt:61)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testEventLoopDispatcher$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:40)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
diff --git a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testEventLoopDispatcherSuspending.txt b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testEventLoopDispatcherSuspending.txt
index 0792646e..100c8f04 100644
--- a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testEventLoopDispatcherSuspending.txt
+++ b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testEventLoopDispatcherSuspending.txt
@@ -1,10 +1,10 @@
-otlinx.coroutines.RecoverableTestException
+kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testResumeModeSuspending$2.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:99)
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$withContext$4.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:116)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.doSuspendingPath(StackTraceRecoveryResumeModeTest.kt:110)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.testResumeModeSuspending(StackTraceRecoveryResumeModeTest.kt:101)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testEventLoopDispatcherSuspending$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:89)
-Caused by: kotlinx.coroutines.RecoverableTestException
+Caused by: kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testResumeModeSuspending$2.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:99)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
diff --git a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedEventLoopChangedContext.txt b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedEventLoopChangedContext.txt
index f3ca1fc4..18d2293e 100644
--- a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedEventLoopChangedContext.txt
+++ b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedEventLoopChangedContext.txt
@@ -1,4 +1,4 @@
-kotlinx.coroutines.RecoverableTestException
+kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.testResumeModeFastPath(StackTraceRecoveryResumeModeTest.kt:61)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedEventLoopChangedContext$1$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:54)
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)
@@ -7,7 +7,7 @@ kotlinx.coroutines.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.testResumeModeFastPath(StackTraceRecoveryResumeModeTest.kt:62)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedEventLoopChangedContext$1$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:54)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedEventLoopChangedContext$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:53)
-Caused by: kotlinx.coroutines.RecoverableTestException
+Caused by: kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.testResumeModeFastPath(StackTraceRecoveryResumeModeTest.kt:61)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedEventLoopChangedContext$1$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:54)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
diff --git a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedEventLoopChangedContextSuspending.txt b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedEventLoopChangedContextSuspending.txt
index dbb574fe..fb44df47 100644
--- a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedEventLoopChangedContextSuspending.txt
+++ b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedEventLoopChangedContextSuspending.txt
@@ -1,4 +1,4 @@
-kotlinx.coroutines.RecoverableTestException
+kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testResumeModeSuspending$2.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:113)
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$withContext$4.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:130)
@@ -6,6 +6,6 @@ kotlinx.coroutines.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.testResumeModeSuspending(StackTraceRecoveryResumeModeTest.kt:115)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedEventLoopChangedContextSuspending$1$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:103)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedEventLoopChangedContextSuspending$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:102)
-Caused by: kotlinx.coroutines.RecoverableTestException
+Caused by: kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testResumeModeSuspending$2.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:113)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
diff --git a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedEventLoopDispatcher.txt b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedEventLoopDispatcher.txt
index e17e2db6..13b12c18 100644
--- a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedEventLoopDispatcher.txt
+++ b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedEventLoopDispatcher.txt
@@ -1,4 +1,4 @@
-kotlinx.coroutines.RecoverableTestException
+kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.testResumeModeFastPath(StackTraceRecoveryResumeModeTest.kt:61)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedEventLoopDispatcher$1$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:47)
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)
@@ -7,7 +7,7 @@ kotlinx.coroutines.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.testResumeModeFastPath(StackTraceRecoveryResumeModeTest.kt:62)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedEventLoopDispatcher$1$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:47)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedEventLoopDispatcher$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:46)
-Caused by: kotlinx.coroutines.RecoverableTestException
+Caused by: kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.testResumeModeFastPath(StackTraceRecoveryResumeModeTest.kt:61)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedEventLoopDispatcher$1$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:47)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
diff --git a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedEventLoopDispatcherSuspending.txt b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedEventLoopDispatcherSuspending.txt
index 26e03599..2b302644 100644
--- a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedEventLoopDispatcherSuspending.txt
+++ b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedEventLoopDispatcherSuspending.txt
@@ -1,4 +1,4 @@
-kotlinx.coroutines.RecoverableTestException
+kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testResumeModeSuspending$2.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:113)
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$withContext$4.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:130)
@@ -6,6 +6,6 @@ kotlinx.coroutines.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.testResumeModeSuspending(StackTraceRecoveryResumeModeTest.kt:115)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedEventLoopDispatcherSuspending$1$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:96)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedEventLoopDispatcherSuspending$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:95)
-Caused by: kotlinx.coroutines.RecoverableTestException
+Caused by: kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testResumeModeSuspending$2.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:113)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
diff --git a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedUnconfined.txt b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedUnconfined.txt
index f247920e..5740f123 100644
--- a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedUnconfined.txt
+++ b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedUnconfined.txt
@@ -1,4 +1,4 @@
-kotlinx.coroutines.RecoverableTestException
+kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.testResumeModeFastPath(StackTraceRecoveryResumeModeTest.kt:61)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedUnconfined$1$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:27)
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)
@@ -7,7 +7,7 @@ kotlinx.coroutines.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.testResumeModeFastPath(StackTraceRecoveryResumeModeTest.kt:62)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedUnconfined$1$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:27)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedUnconfined$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:26)
-Caused by: kotlinx.coroutines.RecoverableTestException
+Caused by: kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.testResumeModeFastPath(StackTraceRecoveryResumeModeTest.kt:61)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedUnconfined$1$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:27)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
diff --git a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedUnconfinedChangedContext.txt b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedUnconfinedChangedContext.txt
index b7ae52c9..a3bc4edb 100644
--- a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedUnconfinedChangedContext.txt
+++ b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedUnconfinedChangedContext.txt
@@ -1,4 +1,4 @@
-kotlinx.coroutines.RecoverableTestException
+kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.testResumeModeFastPath(StackTraceRecoveryResumeModeTest.kt:61)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedUnconfinedChangedContext$1$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:34)
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)
@@ -7,7 +7,7 @@ kotlinx.coroutines.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.testResumeModeFastPath(StackTraceRecoveryResumeModeTest.kt:62)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedUnconfinedChangedContext$1$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:34)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedUnconfinedChangedContext$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:33)
-Caused by: kotlinx.coroutines.RecoverableTestException
+Caused by: kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.testResumeModeFastPath(StackTraceRecoveryResumeModeTest.kt:61)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedUnconfinedChangedContext$1$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:34)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
diff --git a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedUnconfinedChangedContextSuspending.txt b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedUnconfinedChangedContextSuspending.txt
index 241a3b23..ffbcd58e 100644
--- a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedUnconfinedChangedContextSuspending.txt
+++ b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedUnconfinedChangedContextSuspending.txt
@@ -1,4 +1,4 @@
-kotlinx.coroutines.RecoverableTestException
+kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testResumeModeSuspending$2.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:128)
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$withContext$4.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:148)
@@ -6,6 +6,6 @@ kotlinx.coroutines.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.testResumeModeSuspending(StackTraceRecoveryResumeModeTest.kt:130)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedUnconfinedChangedContextSuspending$1$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:95)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedUnconfinedChangedContextSuspending$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:94)
-Caused by: kotlinx.coroutines.RecoverableTestException
+Caused by: kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testResumeModeSuspending$2.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:128)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
diff --git a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedUnconfinedSuspending.txt b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedUnconfinedSuspending.txt
index 4484c664..e115a698 100644
--- a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedUnconfinedSuspending.txt
+++ b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testNestedUnconfinedSuspending.txt
@@ -1,4 +1,4 @@
-kotlinx.coroutines.RecoverableTestException
+kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testResumeModeSuspending$2.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:128)
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$withContext$4.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:148)
@@ -6,6 +6,6 @@ kotlinx.coroutines.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.testResumeModeSuspending(StackTraceRecoveryResumeModeTest.kt:130)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedUnconfinedSuspending$1$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:88)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testNestedUnconfinedSuspending$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:87)
-Caused by: kotlinx.coroutines.RecoverableTestException
+Caused by: kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testResumeModeSuspending$2.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:128)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
diff --git a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testUnconfined.txt b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testUnconfined.txt
index 9fc71678..21252458 100644
--- a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testUnconfined.txt
+++ b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testUnconfined.txt
@@ -1,8 +1,8 @@
-kotlinx.coroutines.RecoverableTestException
+kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.channels.BufferedChannel.receive$suspendImpl(BufferedChannel.kt)
at kotlinx.coroutines.channels.BufferedChannel.receive(BufferedChannel.kt)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$withContext$2.invokeSuspend(StackTraceRecoveryResumeModeTest.kt)
-Caused by: kotlinx.coroutines.RecoverableTestException
+Caused by: kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.testResumeModeFastPath(StackTraceRecoveryResumeModeTest.kt)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.access$testResumeModeFastPath(StackTraceRecoveryResumeModeTest.kt)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testUnconfined$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt)
diff --git a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testUnconfinedSuspending.txt b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testUnconfinedSuspending.txt
index fb742a30..1199fe64 100644
--- a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testUnconfinedSuspending.txt
+++ b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/resume-mode/testUnconfinedSuspending.txt
@@ -1,9 +1,9 @@
-kotlinx.coroutines.RecoverableTestException
+kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testResumeModeSuspending$2.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:128)
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.doSuspendingPath(StackTraceRecoveryResumeModeTest.kt:140)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest.testResumeModeSuspending(StackTraceRecoveryResumeModeTest.kt:130)
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testUnconfinedSuspending$1.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:82)
-Caused by: kotlinx.coroutines.RecoverableTestException
+Caused by: kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoveryResumeModeTest$testResumeModeSuspending$2.invokeSuspend(StackTraceRecoveryResumeModeTest.kt:128)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
diff --git a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/select/testSelectCompletedAwait.txt b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/select/testSelectCompletedAwait.txt
index 2e86a7ad..900cb6c2 100644
--- a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/select/testSelectCompletedAwait.txt
+++ b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/select/testSelectCompletedAwait.txt
@@ -1,7 +1,7 @@
-kotlinx.coroutines.RecoverableTestException
+kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoverySelectTest$testSelectCompletedAwait$1.invokeSuspend(StackTraceRecoverySelectTest.kt:40)
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)
at kotlinx.coroutines.exceptions.StackTraceRecoverySelectTest$testSelectCompletedAwait$1.invokeSuspend(StackTraceRecoverySelectTest.kt:41)
-Caused by: kotlinx.coroutines.RecoverableTestException
+Caused by: kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoverySelectTest$testSelectCompletedAwait$1.invokeSuspend(StackTraceRecoverySelectTest.kt:40)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
diff --git a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/select/testSelectJoin.txt b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/select/testSelectJoin.txt
index 420aa7e9..15a689b7 100644
--- a/kotlinx-coroutines-core/jvm/test-resources/stacktraces/select/testSelectJoin.txt
+++ b/kotlinx-coroutines-core/jvm/test-resources/stacktraces/select/testSelectJoin.txt
@@ -1,8 +1,8 @@
-kotlinx.coroutines.RecoverableTestException
+kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoverySelectTest$doSelect$2$1.invokeSuspend(StackTraceRecoverySelectTest.kt)
at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)
at kotlinx.coroutines.selects.SelectImplementation.processResultAndInvokeBlockRecoveringException(Select.kt)
at kotlinx.coroutines.exceptions.StackTraceRecoverySelectTest$testSelectJoin$1.invokeSuspend(StackTraceRecoverySelectTest.kt)
-Caused by: kotlinx.coroutines.RecoverableTestException
+Caused by: kotlinx.coroutines.testing.RecoverableTestException
at kotlinx.coroutines.exceptions.StackTraceRecoverySelectTest$doSelect$2$1.invokeSuspend(StackTraceRecoverySelectTest.kt)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt)
diff --git a/kotlinx-coroutines-core/jvm/test/AbstractLincheckTest.kt b/kotlinx-coroutines-core/jvm/test/AbstractLincheckTest.kt
index 869b9543..4cb45ba9 100644
--- a/kotlinx-coroutines-core/jvm/test/AbstractLincheckTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/AbstractLincheckTest.kt
@@ -1,9 +1,9 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.jetbrains.kotlinx.lincheck.*
import org.jetbrains.kotlinx.lincheck.strategy.managed.modelchecking.*
import org.jetbrains.kotlinx.lincheck.strategy.stress.*
-import org.jetbrains.kotlinx.lincheck.verifier.*
import org.junit.*
abstract class AbstractLincheckTest {
diff --git a/kotlinx-coroutines-core/jvm/test/AsyncJvmTest.kt b/kotlinx-coroutines-core/jvm/test/AsyncJvmTest.kt
index e50eff1e..05bc505f 100644
--- a/kotlinx-coroutines-core/jvm/test/AsyncJvmTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/AsyncJvmTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/AwaitJvmTest.kt b/kotlinx-coroutines-core/jvm/test/AwaitJvmTest.kt
index f6fe8e13..e43611e8 100644
--- a/kotlinx-coroutines-core/jvm/test/AwaitJvmTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/AwaitJvmTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.*
class AwaitJvmTest : TestBase() {
diff --git a/kotlinx-coroutines-core/jvm/test/AwaitStressTest.kt b/kotlinx-coroutines-core/jvm/test/AwaitStressTest.kt
index 5f6c6edd..8c84e7da 100644
--- a/kotlinx-coroutines-core/jvm/test/AwaitStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/AwaitStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.*
import org.junit.Test
import java.util.concurrent.*
diff --git a/kotlinx-coroutines-core/jvm/test/CancellableContinuationJvmTest.kt b/kotlinx-coroutines-core/jvm/test/CancellableContinuationJvmTest.kt
index cca06d03..e53cd0cc 100644
--- a/kotlinx-coroutines-core/jvm/test/CancellableContinuationJvmTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/CancellableContinuationJvmTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/CancellableContinuationResumeCloseStressTest.kt b/kotlinx-coroutines-core/jvm/test/CancellableContinuationResumeCloseStressTest.kt
index d9ce0266..fa6030d2 100644
--- a/kotlinx-coroutines-core/jvm/test/CancellableContinuationResumeCloseStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/CancellableContinuationResumeCloseStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.atomicfu.*
import org.junit.*
import java.util.concurrent.*
diff --git a/kotlinx-coroutines-core/jvm/test/CancelledAwaitStressTest.kt b/kotlinx-coroutines-core/jvm/test/CancelledAwaitStressTest.kt
index 7d82a5e6..5a85aebb 100644
--- a/kotlinx-coroutines-core/jvm/test/CancelledAwaitStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/CancelledAwaitStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.*
class CancelledAwaitStressTest : TestBase() {
diff --git a/kotlinx-coroutines-core/jvm/test/CoroutinesJvmTest.kt b/kotlinx-coroutines-core/jvm/test/CoroutinesJvmTest.kt
index c23b4f35..416226cb 100644
--- a/kotlinx-coroutines-core/jvm/test/CoroutinesJvmTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/CoroutinesJvmTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class CoroutinesJvmTest : TestBase() {
diff --git a/kotlinx-coroutines-core/jvm/test/DebugThreadNameTest.kt b/kotlinx-coroutines-core/jvm/test/DebugThreadNameTest.kt
index 5e88e34c..4505f39d 100644
--- a/kotlinx-coroutines-core/jvm/test/DebugThreadNameTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/DebugThreadNameTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class DebugThreadNameTest : TestBase() {
diff --git a/kotlinx-coroutines-core/jvm/test/DefaultExecutorStressTest.kt b/kotlinx-coroutines-core/jvm/test/DefaultExecutorStressTest.kt
index 26dad4e6..58b80245 100644
--- a/kotlinx-coroutines-core/jvm/test/DefaultExecutorStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/DefaultExecutorStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.Test
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/DelayJvmTest.kt b/kotlinx-coroutines-core/jvm/test/DelayJvmTest.kt
index 1ed491b7..710f773f 100644
--- a/kotlinx-coroutines-core/jvm/test/DelayJvmTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/DelayJvmTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.*
import java.util.concurrent.*
import kotlin.coroutines.*
diff --git a/kotlinx-coroutines-core/jvm/test/DispatcherKeyTest.kt b/kotlinx-coroutines-core/jvm/test/DispatcherKeyTest.kt
index 673097db..8b6c219c 100644
--- a/kotlinx-coroutines-core/jvm/test/DispatcherKeyTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/DispatcherKeyTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.Test
import kotlin.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/EventLoopsTest.kt b/kotlinx-coroutines-core/jvm/test/EventLoopsTest.kt
index 0e7ef93a..9ab52fd2 100644
--- a/kotlinx-coroutines-core/jvm/test/EventLoopsTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/EventLoopsTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.atomicfu.*
import kotlinx.coroutines.channels.*
import org.junit.Test
diff --git a/kotlinx-coroutines-core/jvm/test/ExecutorAsCoroutineDispatcherDelayTest.kt b/kotlinx-coroutines-core/jvm/test/ExecutorAsCoroutineDispatcherDelayTest.kt
index 982493f5..072ae280 100644
--- a/kotlinx-coroutines-core/jvm/test/ExecutorAsCoroutineDispatcherDelayTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/ExecutorAsCoroutineDispatcherDelayTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.Test
import java.lang.Runnable
import java.util.concurrent.*
diff --git a/kotlinx-coroutines-core/jvm/test/ExecutorsTest.kt b/kotlinx-coroutines-core/jvm/test/ExecutorsTest.kt
index 892ed558..1ad2f8a2 100644
--- a/kotlinx-coroutines-core/jvm/test/ExecutorsTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/ExecutorsTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.Test
import java.util.concurrent.*
import kotlin.coroutines.*
diff --git a/kotlinx-coroutines-core/jvm/test/FailFastOnStartTest.kt b/kotlinx-coroutines-core/jvm/test/FailFastOnStartTest.kt
index 8446fccf..ae3c503d 100644
--- a/kotlinx-coroutines-core/jvm/test/FailFastOnStartTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/FailFastOnStartTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.channels.*
import org.junit.*
import org.junit.Test
diff --git a/kotlinx-coroutines-core/jvm/test/FailingCoroutinesMachineryTest.kt b/kotlinx-coroutines-core/jvm/test/FailingCoroutinesMachineryTest.kt
index 0125a71d..144e4e9d 100644
--- a/kotlinx-coroutines-core/jvm/test/FailingCoroutinesMachineryTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/FailingCoroutinesMachineryTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.*
import org.junit.Test
import org.junit.runner.*
diff --git a/kotlinx-coroutines-core/jvm/test/IODispatcherTest.kt b/kotlinx-coroutines-core/jvm/test/IODispatcherTest.kt
index b3f3754f..db81f12c 100644
--- a/kotlinx-coroutines-core/jvm/test/IODispatcherTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/IODispatcherTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.Test
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/JobActivationStressTest.kt b/kotlinx-coroutines-core/jvm/test/JobActivationStressTest.kt
index 8b9592b7..c8bfbf01 100644
--- a/kotlinx-coroutines-core/jvm/test/JobActivationStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/JobActivationStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.*
import org.junit.Test
import java.util.concurrent.*
@@ -55,13 +56,13 @@ class JobActivationStressTest : TestBase() {
joinAll(d, canceller, starter)
if (wasStarted) {
val exception = d.getCompletionExceptionOrNull()
- assertTrue(exception is TestException, "exception=$exception")
+ assertIs<TestException>(exception, "exception=$exception")
val cause = synchronized(causeHolder) {
while (causeHolder.cause == null) (causeHolder as Object).wait()
causeHolder.cause
}
- assertTrue(cause is TestException, "cause=$cause")
+ assertIs<TestException>(cause, "cause=$cause")
}
}
}
-} \ No newline at end of file
+}
diff --git a/kotlinx-coroutines-core/jvm/test/JobCancellationExceptionSerializerTest.kt b/kotlinx-coroutines-core/jvm/test/JobCancellationExceptionSerializerTest.kt
index cff3fbf1..c063e945 100644
--- a/kotlinx-coroutines-core/jvm/test/JobCancellationExceptionSerializerTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/JobCancellationExceptionSerializerTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.*
import java.io.*
diff --git a/kotlinx-coroutines-core/jvm/test/JobChildStressTest.kt b/kotlinx-coroutines-core/jvm/test/JobChildStressTest.kt
index 46b3928e..3ac1967b 100644
--- a/kotlinx-coroutines-core/jvm/test/JobChildStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/JobChildStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.*
import org.junit.Test
import java.util.concurrent.*
@@ -49,8 +50,8 @@ class JobChildStressTest : TestBase() {
assertNull(unhandledException)
if (wasLaunched) {
val exception = parent.getCompletionExceptionOrNull()
- assertTrue(exception is TestException, "exception=$exception")
+ assertIs<TestException>(exception, "exception=$exception")
}
}
}
-} \ No newline at end of file
+}
diff --git a/kotlinx-coroutines-core/jvm/test/JobDisposeStressTest.kt b/kotlinx-coroutines-core/jvm/test/JobDisposeStressTest.kt
index f3b5b497..22b5d599 100644
--- a/kotlinx-coroutines-core/jvm/test/JobDisposeStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/JobDisposeStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.Test
import kotlin.concurrent.thread
diff --git a/kotlinx-coroutines-core/jvm/test/JobHandlersUpgradeStressTest.kt b/kotlinx-coroutines-core/jvm/test/JobHandlersUpgradeStressTest.kt
index f9c99793..dc2314bb 100644
--- a/kotlinx-coroutines-core/jvm/test/JobHandlersUpgradeStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/JobHandlersUpgradeStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.atomicfu.*
import java.util.*
import java.util.concurrent.*
diff --git a/kotlinx-coroutines-core/jvm/test/JobStressTest.kt b/kotlinx-coroutines-core/jvm/test/JobStressTest.kt
index fab7a3a3..cb0274e8 100644
--- a/kotlinx-coroutines-core/jvm/test/JobStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/JobStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class JobStressTest : TestBase() {
diff --git a/kotlinx-coroutines-core/jvm/test/JoinStressTest.kt b/kotlinx-coroutines-core/jvm/test/JoinStressTest.kt
index e0e0de8b..6c3190de 100644
--- a/kotlinx-coroutines-core/jvm/test/JoinStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/JoinStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.*
import org.junit.Test
import java.util.concurrent.*
diff --git a/kotlinx-coroutines-core/jvm/test/LimitedParallelismStressTest.kt b/kotlinx-coroutines-core/jvm/test/LimitedParallelismStressTest.kt
index 9a797807..211ff04c 100644
--- a/kotlinx-coroutines-core/jvm/test/LimitedParallelismStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/LimitedParallelismStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.*
import org.junit.Test
import org.junit.runner.*
diff --git a/kotlinx-coroutines-core/jvm/test/LimitedParallelismUnhandledExceptionTest.kt b/kotlinx-coroutines-core/jvm/test/LimitedParallelismUnhandledExceptionTest.kt
index 0ce9b227..e9525549 100644
--- a/kotlinx-coroutines-core/jvm/test/LimitedParallelismUnhandledExceptionTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/LimitedParallelismUnhandledExceptionTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.Test
import java.util.concurrent.*
import kotlin.coroutines.*
diff --git a/kotlinx-coroutines-core/jvm/test/MemoryFootprintTest.kt b/kotlinx-coroutines-core/jvm/test/MemoryFootprintTest.kt
index fd8c7504..8f78a926 100644
--- a/kotlinx-coroutines-core/jvm/test/MemoryFootprintTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/MemoryFootprintTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.Test
import org.openjdk.jol.info.ClassLayout
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/MutexCancellationStressTest.kt b/kotlinx-coroutines-core/jvm/test/MutexCancellationStressTest.kt
index d5627bc9..dc096fe7 100644
--- a/kotlinx-coroutines-core/jvm/test/MutexCancellationStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/MutexCancellationStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.internal.*
import kotlinx.coroutines.selects.*
import kotlinx.coroutines.sync.*
diff --git a/kotlinx-coroutines-core/jvm/test/NoParamAssertionsTest.kt b/kotlinx-coroutines-core/jvm/test/NoParamAssertionsTest.kt
index 729e8acb..40b61444 100644
--- a/kotlinx-coroutines-core/jvm/test/NoParamAssertionsTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/NoParamAssertionsTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/RejectedExecutionTest.kt b/kotlinx-coroutines-core/jvm/test/RejectedExecutionTest.kt
index 15471512..770a854a 100644
--- a/kotlinx-coroutines-core/jvm/test/RejectedExecutionTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/RejectedExecutionTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.internal.*
import kotlinx.coroutines.scheduling.*
diff --git a/kotlinx-coroutines-core/jvm/test/ReusableCancellableContinuationInvariantStressTest.kt b/kotlinx-coroutines-core/jvm/test/ReusableCancellableContinuationInvariantStressTest.kt
index 9e610780..ef0d146d 100644
--- a/kotlinx-coroutines-core/jvm/test/ReusableCancellableContinuationInvariantStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/ReusableCancellableContinuationInvariantStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.Test
import java.util.concurrent.CountDownLatch
import java.util.concurrent.atomic.AtomicReference
diff --git a/kotlinx-coroutines-core/jvm/test/ReusableCancellableContinuationLeakStressTest.kt b/kotlinx-coroutines-core/jvm/test/ReusableCancellableContinuationLeakStressTest.kt
index e5059432..b2ed34cd 100644
--- a/kotlinx-coroutines-core/jvm/test/ReusableCancellableContinuationLeakStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/ReusableCancellableContinuationLeakStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.channels.*
import org.junit.Test
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/ReusableCancellableContinuationTest.kt b/kotlinx-coroutines-core/jvm/test/ReusableCancellableContinuationTest.kt
index c3944c6d..d9f455a9 100644
--- a/kotlinx-coroutines-core/jvm/test/ReusableCancellableContinuationTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/ReusableCancellableContinuationTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.selects.*
import org.junit.Test
diff --git a/kotlinx-coroutines-core/jvm/test/ReusableContinuationStressTest.kt b/kotlinx-coroutines-core/jvm/test/ReusableContinuationStressTest.kt
index ccff46db..489ecc3d 100644
--- a/kotlinx-coroutines-core/jvm/test/ReusableContinuationStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/ReusableContinuationStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.flow.*
import org.junit.*
diff --git a/kotlinx-coroutines-core/jvm/test/RunBlockingJvmTest.kt b/kotlinx-coroutines-core/jvm/test/RunBlockingJvmTest.kt
index bc60a3aa..cc2291e6 100644
--- a/kotlinx-coroutines-core/jvm/test/RunBlockingJvmTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/RunBlockingJvmTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.*
class RunBlockingJvmTest : TestBase() {
diff --git a/kotlinx-coroutines-core/jvm/test/RunInterruptibleStressTest.kt b/kotlinx-coroutines-core/jvm/test/RunInterruptibleStressTest.kt
index c8461974..b42bdad5 100644
--- a/kotlinx-coroutines-core/jvm/test/RunInterruptibleStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/RunInterruptibleStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.*
import org.junit.Test
import java.util.concurrent.atomic.*
diff --git a/kotlinx-coroutines-core/jvm/test/RunInterruptibleTest.kt b/kotlinx-coroutines-core/jvm/test/RunInterruptibleTest.kt
index 3208d041..bf194c0d 100644
--- a/kotlinx-coroutines-core/jvm/test/RunInterruptibleTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/RunInterruptibleTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.channels.*
import java.io.*
import java.util.concurrent.*
diff --git a/kotlinx-coroutines-core/jvm/test/TestBaseTest.kt b/kotlinx-coroutines-core/jvm/test/TestBaseTest.kt
index 2c66b0c4..49b26ab7 100644
--- a/kotlinx-coroutines-core/jvm/test/TestBaseTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/TestBaseTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.*
class TestBaseTest : TestBase() {
diff --git a/kotlinx-coroutines-core/jvm/test/ThreadContextElementRestoreTest.kt b/kotlinx-coroutines-core/jvm/test/ThreadContextElementRestoreTest.kt
index 5cdaa9c5..cd341968 100644
--- a/kotlinx-coroutines-core/jvm/test/ThreadContextElementRestoreTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/ThreadContextElementRestoreTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.Test
import kotlin.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/ThreadContextElementTest.kt b/kotlinx-coroutines-core/jvm/test/ThreadContextElementTest.kt
index 4255cf7e..3b106c44 100644
--- a/kotlinx-coroutines-core/jvm/test/ThreadContextElementTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/ThreadContextElementTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.Test
import kotlin.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/ThreadContextMutableCopiesTest.kt b/kotlinx-coroutines-core/jvm/test/ThreadContextMutableCopiesTest.kt
index 6aa033ba..0b174ec5 100644
--- a/kotlinx-coroutines-core/jvm/test/ThreadContextMutableCopiesTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/ThreadContextMutableCopiesTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.flow.*
import kotlin.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/ThreadContextOrderTest.kt b/kotlinx-coroutines-core/jvm/test/ThreadContextOrderTest.kt
index 53f23378..877a4ca2 100644
--- a/kotlinx-coroutines-core/jvm/test/ThreadContextOrderTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/ThreadContextOrderTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.internal.*
import org.junit.Test
import kotlin.coroutines.*
diff --git a/kotlinx-coroutines-core/jvm/test/ThreadLocalStressTest.kt b/kotlinx-coroutines-core/jvm/test/ThreadLocalStressTest.kt
index 94d72ba7..63ed3f23 100644
--- a/kotlinx-coroutines-core/jvm/test/ThreadLocalStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/ThreadLocalStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.sync.*
import java.util.concurrent.*
import kotlin.coroutines.*
diff --git a/kotlinx-coroutines-core/jvm/test/ThreadLocalTest.kt b/kotlinx-coroutines-core/jvm/test/ThreadLocalTest.kt
index be001aa4..79a2490f 100644
--- a/kotlinx-coroutines-core/jvm/test/ThreadLocalTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/ThreadLocalTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.*
import org.junit.Test
import java.lang.IllegalStateException
diff --git a/kotlinx-coroutines-core/jvm/test/UnconfinedConcurrentStressTest.kt b/kotlinx-coroutines-core/jvm/test/UnconfinedConcurrentStressTest.kt
index 226a782e..61aa7daa 100644
--- a/kotlinx-coroutines-core/jvm/test/UnconfinedConcurrentStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/UnconfinedConcurrentStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.*
import org.junit.Test
import java.util.concurrent.*
diff --git a/kotlinx-coroutines-core/jvm/test/VirtualTimeSource.kt b/kotlinx-coroutines-core/jvm/test/VirtualTimeSource.kt
index 097e7eee..8a461087 100644
--- a/kotlinx-coroutines-core/jvm/test/VirtualTimeSource.kt
+++ b/kotlinx-coroutines-core/jvm/test/VirtualTimeSource.kt
@@ -9,14 +9,14 @@ private const val SHUTDOWN_TIMEOUT = 1000L
internal inline fun withVirtualTimeSource(log: PrintStream? = null, block: () -> Unit) {
DefaultExecutor.shutdownForTests(SHUTDOWN_TIMEOUT) // shutdown execution with old time source (in case it was working)
val testTimeSource = VirtualTimeSource(log)
- timeSource = testTimeSource
+ mockTimeSource(testTimeSource)
DefaultExecutor.ensureStarted() // should start with new time source
try {
block()
} finally {
DefaultExecutor.shutdownForTests(SHUTDOWN_TIMEOUT)
testTimeSource.shutdown()
- timeSource = null // restore time source
+ mockTimeSource(null) // restore time source
}
}
diff --git a/kotlinx-coroutines-core/jvm/test/WithDefaultContextTest.kt b/kotlinx-coroutines-core/jvm/test/WithDefaultContextTest.kt
index 78762f94..44b31275 100644
--- a/kotlinx-coroutines-core/jvm/test/WithDefaultContextTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/WithDefaultContextTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class WithDefaultContextTest : TestBase() {
diff --git a/kotlinx-coroutines-core/jvm/test/WithTimeoutChildDipspatchStressTest.kt b/kotlinx-coroutines-core/jvm/test/WithTimeoutChildDipspatchStressTest.kt
index 49a92a60..cc5e1d86 100644
--- a/kotlinx-coroutines-core/jvm/test/WithTimeoutChildDipspatchStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/WithTimeoutChildDipspatchStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import org.junit.Test
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/WithTimeoutOrNullJvmTest.kt b/kotlinx-coroutines-core/jvm/test/WithTimeoutOrNullJvmTest.kt
index 4537c8d5..a0a29f0d 100644
--- a/kotlinx-coroutines-core/jvm/test/WithTimeoutOrNullJvmTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/WithTimeoutOrNullJvmTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class WithTimeoutOrNullJvmTest : TestBase() {
diff --git a/kotlinx-coroutines-core/jvm/test/WithTimeoutOrNullThreadDispatchTest.kt b/kotlinx-coroutines-core/jvm/test/WithTimeoutOrNullThreadDispatchTest.kt
index 3ca6f4d3..a5aeefda 100644
--- a/kotlinx-coroutines-core/jvm/test/WithTimeoutOrNullThreadDispatchTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/WithTimeoutOrNullThreadDispatchTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
diff --git a/kotlinx-coroutines-core/jvm/test/WithTimeoutThreadDispatchTest.kt b/kotlinx-coroutines-core/jvm/test/WithTimeoutThreadDispatchTest.kt
index 848bc2a4..58c7336d 100644
--- a/kotlinx-coroutines-core/jvm/test/WithTimeoutThreadDispatchTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/WithTimeoutThreadDispatchTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.test.*
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
diff --git a/kotlinx-coroutines-core/jvm/test/channels/ActorLazyTest.kt b/kotlinx-coroutines-core/jvm/test/channels/ActorLazyTest.kt
index bfdc2b40..7ed5d4eb 100644
--- a/kotlinx-coroutines-core/jvm/test/channels/ActorLazyTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/channels/ActorLazyTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/channels/ActorTest.kt b/kotlinx-coroutines-core/jvm/test/channels/ActorTest.kt
index 1f9790a7..88981587 100644
--- a/kotlinx-coroutines-core/jvm/test/channels/ActorTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/channels/ActorTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import org.junit.runner.*
diff --git a/kotlinx-coroutines-core/jvm/test/channels/BroadcastChannelLeakTest.kt b/kotlinx-coroutines-core/jvm/test/channels/BroadcastChannelLeakTest.kt
index df944654..71026364 100644
--- a/kotlinx-coroutines-core/jvm/test/channels/BroadcastChannelLeakTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/channels/BroadcastChannelLeakTest.kt
@@ -1,6 +1,6 @@
package kotlinx.coroutines.channels
-import kotlinx.coroutines.*
+import kotlinx.coroutines.testing.*
import org.junit.Test
import kotlin.test.*
@@ -31,4 +31,4 @@ class BroadcastChannelLeakTest : TestBase() {
FieldWalker.assertReachableCount(0, broadcast) { it === sub }
}
}
-} \ No newline at end of file
+}
diff --git a/kotlinx-coroutines-core/jvm/test/channels/BroadcastChannelMultiReceiveStressTest.kt b/kotlinx-coroutines-core/jvm/test/channels/BroadcastChannelMultiReceiveStressTest.kt
index 2777bfb4..e6e629da 100644
--- a/kotlinx-coroutines-core/jvm/test/channels/BroadcastChannelMultiReceiveStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/channels/BroadcastChannelMultiReceiveStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.selects.*
import org.junit.*
diff --git a/kotlinx-coroutines-core/jvm/test/channels/BufferedChannelStressTest.kt b/kotlinx-coroutines-core/jvm/test/channels/BufferedChannelStressTest.kt
index 0dc6c707..87754b35 100644
--- a/kotlinx-coroutines-core/jvm/test/channels/BufferedChannelStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/channels/BufferedChannelStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import org.junit.runner.*
diff --git a/kotlinx-coroutines-core/jvm/test/channels/ChannelMemoryLeakStressTest.kt b/kotlinx-coroutines-core/jvm/test/channels/ChannelMemoryLeakStressTest.kt
index db96f61e..67170c22 100644
--- a/kotlinx-coroutines-core/jvm/test/channels/ChannelMemoryLeakStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/channels/ChannelMemoryLeakStressTest.kt
@@ -1,5 +1,6 @@
package channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import org.junit.Test
diff --git a/kotlinx-coroutines-core/jvm/test/channels/ChannelSelectStressTest.kt b/kotlinx-coroutines-core/jvm/test/channels/ChannelSelectStressTest.kt
index 45ccddcf..f7a12c60 100644
--- a/kotlinx-coroutines-core/jvm/test/channels/ChannelSelectStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/channels/ChannelSelectStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.atomicfu.*
import kotlinx.coroutines.*
import kotlinx.coroutines.selects.*
diff --git a/kotlinx-coroutines-core/jvm/test/channels/ChannelSendReceiveStressTest.kt b/kotlinx-coroutines-core/jvm/test/channels/ChannelSendReceiveStressTest.kt
index 230041a2..e9c087a7 100644
--- a/kotlinx-coroutines-core/jvm/test/channels/ChannelSendReceiveStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/channels/ChannelSendReceiveStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.selects.*
import org.junit.*
diff --git a/kotlinx-coroutines-core/jvm/test/channels/ChannelUndeliveredElementSelectOldStressTest.kt b/kotlinx-coroutines-core/jvm/test/channels/ChannelUndeliveredElementSelectOldStressTest.kt
index 7e2c08e5..fc5c3845 100644
--- a/kotlinx-coroutines-core/jvm/test/channels/ChannelUndeliveredElementSelectOldStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/channels/ChannelUndeliveredElementSelectOldStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.atomicfu.*
import kotlinx.coroutines.*
import kotlinx.coroutines.selects.*
diff --git a/kotlinx-coroutines-core/jvm/test/channels/ChannelUndeliveredElementStressTest.kt b/kotlinx-coroutines-core/jvm/test/channels/ChannelUndeliveredElementStressTest.kt
index 9b44d836..ec123f15 100644
--- a/kotlinx-coroutines-core/jvm/test/channels/ChannelUndeliveredElementStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/channels/ChannelUndeliveredElementStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.atomicfu.*
import kotlinx.coroutines.*
import kotlinx.coroutines.selects.*
diff --git a/kotlinx-coroutines-core/jvm/test/channels/ConflatedChannelCloseStressTest.kt b/kotlinx-coroutines-core/jvm/test/channels/ConflatedChannelCloseStressTest.kt
index 9c7095a9..e36cafe4 100644
--- a/kotlinx-coroutines-core/jvm/test/channels/ConflatedChannelCloseStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/channels/ConflatedChannelCloseStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import java.util.concurrent.atomic.*
diff --git a/kotlinx-coroutines-core/jvm/test/channels/DoubleChannelCloseStressTest.kt b/kotlinx-coroutines-core/jvm/test/channels/DoubleChannelCloseStressTest.kt
index 20917151..247b077a 100644
--- a/kotlinx-coroutines-core/jvm/test/channels/DoubleChannelCloseStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/channels/DoubleChannelCloseStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
diff --git a/kotlinx-coroutines-core/jvm/test/channels/InvokeOnCloseStressTest.kt b/kotlinx-coroutines-core/jvm/test/channels/InvokeOnCloseStressTest.kt
index 7a3974b5..19aa0402 100644
--- a/kotlinx-coroutines-core/jvm/test/channels/InvokeOnCloseStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/channels/InvokeOnCloseStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import org.junit.Test
diff --git a/kotlinx-coroutines-core/jvm/test/channels/ProduceConsumeJvmTest.kt b/kotlinx-coroutines-core/jvm/test/channels/ProduceConsumeJvmTest.kt
index 1fe45a00..6b5f2bfa 100644
--- a/kotlinx-coroutines-core/jvm/test/channels/ProduceConsumeJvmTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/channels/ProduceConsumeJvmTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import org.junit.runner.*
diff --git a/kotlinx-coroutines-core/jvm/test/channels/SendReceiveJvmStressTest.kt b/kotlinx-coroutines-core/jvm/test/channels/SendReceiveJvmStressTest.kt
index 525afca4..865f2ab8 100644
--- a/kotlinx-coroutines-core/jvm/test/channels/SendReceiveJvmStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/channels/SendReceiveJvmStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.runner.*
import org.junit.runners.*
diff --git a/kotlinx-coroutines-core/jvm/test/channels/SimpleSendReceiveJvmTest.kt b/kotlinx-coroutines-core/jvm/test/channels/SimpleSendReceiveJvmTest.kt
index 5b407496..37082513 100644
--- a/kotlinx-coroutines-core/jvm/test/channels/SimpleSendReceiveJvmTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/channels/SimpleSendReceiveJvmTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import org.junit.runner.*
diff --git a/kotlinx-coroutines-core/jvm/test/channels/TickerChannelCommonTest.kt b/kotlinx-coroutines-core/jvm/test/channels/TickerChannelCommonTest.kt
index e0182332..65102095 100644
--- a/kotlinx-coroutines-core/jvm/test/channels/TickerChannelCommonTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/channels/TickerChannelCommonTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.selects.*
import org.junit.Test
diff --git a/kotlinx-coroutines-core/jvm/test/channels/TickerChannelTest.kt b/kotlinx-coroutines-core/jvm/test/channels/TickerChannelTest.kt
index b4afc9a5..051d6707 100644
--- a/kotlinx-coroutines-core/jvm/test/channels/TickerChannelTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/channels/TickerChannelTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.channels
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
diff --git a/kotlinx-coroutines-core/jvm/test/exceptions/CoroutineExceptionHandlerJvmTest.kt b/kotlinx-coroutines-core/jvm/test/exceptions/CoroutineExceptionHandlerJvmTest.kt
index 846df5b8..2e351990 100644
--- a/kotlinx-coroutines-core/jvm/test/exceptions/CoroutineExceptionHandlerJvmTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/exceptions/CoroutineExceptionHandlerJvmTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.exceptions
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import org.junit.Test
@@ -29,9 +30,9 @@ class CoroutineExceptionHandlerJvmTest : TestBase() {
}
job.join()
- assertTrue(caughtException is RuntimeException)
- assertTrue(caughtException.cause is AssertionError)
- assertTrue(caughtException.suppressed[0] is TestException)
+ assertIs<RuntimeException>(caughtException)
+ assertIs<AssertionError>(caughtException.cause)
+ assertIs<TestException>(caughtException.suppressed[0])
finish(3)
}
@@ -43,7 +44,7 @@ class CoroutineExceptionHandlerJvmTest : TestBase() {
expect(2)
throw TestException()
}.join()
- assertTrue(caughtException is TestException)
+ assertIs<TestException>(caughtException)
assertContains(caughtException.suppressed[0].toString(), "last-ditch")
finish(3)
}
diff --git a/kotlinx-coroutines-core/jvm/test/exceptions/FlowSuppressionTest.kt b/kotlinx-coroutines-core/jvm/test/exceptions/FlowSuppressionTest.kt
index 09792492..8af4937e 100644
--- a/kotlinx-coroutines-core/jvm/test/exceptions/FlowSuppressionTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/exceptions/FlowSuppressionTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.exceptions
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import org.junit.*
diff --git a/kotlinx-coroutines-core/jvm/test/exceptions/JobBasicCancellationTest.kt b/kotlinx-coroutines-core/jvm/test/exceptions/JobBasicCancellationTest.kt
index e21ef3ea..7ea6c4a8 100644
--- a/kotlinx-coroutines-core/jvm/test/exceptions/JobBasicCancellationTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/exceptions/JobBasicCancellationTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.exceptions
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import java.io.*
@@ -148,7 +149,7 @@ class JobBasicCancellationTest : TestBase() {
assertTrue(deferred.completeExceptionally(IndexOutOfBoundsException()))
assertFalse(deferred.completeExceptionally(AssertionError())) // second is too late
val cause = deferred.getCancellationException().cause!!
- assertTrue(cause is IndexOutOfBoundsException)
+ assertIs<IndexOutOfBoundsException>(cause)
assertNull(cause.cause)
assertTrue(cause.suppressed.isEmpty())
}
diff --git a/kotlinx-coroutines-core/jvm/test/exceptions/JobExceptionHandlingTest.kt b/kotlinx-coroutines-core/jvm/test/exceptions/JobExceptionHandlingTest.kt
index 85dcac24..d0310204 100644
--- a/kotlinx-coroutines-core/jvm/test/exceptions/JobExceptionHandlingTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/exceptions/JobExceptionHandlingTest.kt
@@ -1,7 +1,9 @@
package kotlinx.coroutines.exceptions
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.CoroutineStart.*
+import kotlinx.coroutines.testing.exceptions.*
import org.junit.Test
import java.io.*
import kotlin.test.*
@@ -188,9 +190,7 @@ class JobExceptionHandlingTest : TestBase() {
finish(5)
}
- assertTrue(exception is ArithmeticException)
- assertNull(exception.cause)
- assertTrue(exception.suppressed.isEmpty())
+ checkException<ArithmeticException>(exception)
}
@Test
@@ -228,11 +228,12 @@ class JobExceptionHandlingTest : TestBase() {
finish(6)
}
- assertTrue(exception is ArithmeticException)
+ assertIs<ArithmeticException>(exception)
+ assertNull(exception.cause)
val suppressed = exception.suppressed
assertEquals(2, suppressed.size)
- assertTrue(suppressed[0] is IOException)
- assertTrue(suppressed[1] is IllegalArgumentException)
+ assertIs<IOException>(suppressed[0])
+ assertIs<IllegalArgumentException>(suppressed[1])
}
@Test
@@ -265,11 +266,11 @@ class JobExceptionHandlingTest : TestBase() {
finish(5)
}
- assertTrue(exception is AssertionError)
+ assertIs<AssertionError>(exception)
val suppressed = exception.suppressed
assertEquals(2, suppressed.size)
- assertTrue(suppressed[0] is IOException)
- assertTrue(suppressed[1] is IllegalArgumentException)
+ assertIs<IOException>(suppressed[0])
+ assertIs<IllegalArgumentException>(suppressed[1])
}
@Test
diff --git a/kotlinx-coroutines-core/jvm/test/exceptions/JobExceptionsStressTest.kt b/kotlinx-coroutines-core/jvm/test/exceptions/JobExceptionsStressTest.kt
index feb29b8b..4634c4f7 100644
--- a/kotlinx-coroutines-core/jvm/test/exceptions/JobExceptionsStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/exceptions/JobExceptionsStressTest.kt
@@ -1,6 +1,8 @@
package kotlinx.coroutines.exceptions
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
+import kotlinx.coroutines.testing.exceptions.*
import org.junit.*
import org.junit.Test
import java.util.concurrent.*
diff --git a/kotlinx-coroutines-core/jvm/test/exceptions/JobNestedExceptionsTest.kt b/kotlinx-coroutines-core/jvm/test/exceptions/JobNestedExceptionsTest.kt
index 63f85fd3..8b0a32b3 100644
--- a/kotlinx-coroutines-core/jvm/test/exceptions/JobNestedExceptionsTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/exceptions/JobNestedExceptionsTest.kt
@@ -1,6 +1,8 @@
package kotlinx.coroutines.exceptions
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
+import kotlinx.coroutines.testing.exceptions.*
import org.junit.Test
import java.io.*
import kotlin.test.*
@@ -57,7 +59,7 @@ class JobNestedExceptionsTest : TestBase() {
finish(3)
}
- assertTrue(exception is IOException)
+ assertIs<IOException>(exception)
}
@Test
@@ -76,13 +78,13 @@ class JobNestedExceptionsTest : TestBase() {
job.join()
finish(5)
}
- assertTrue(exception is ArithmeticException, "Found $exception")
+ assertIs<ArithmeticException>(exception, "Found $exception")
checkException<IOException>(exception.suppressed[0])
}
@Test
fun testChildThrowsDuringCompletion() {
- val exceptions = captureMultipleExceptionsRun {
+ val exception = captureExceptionsRun {
expect(1)
val job = launch(NonCancellable + CoroutineName("outer"), start = CoroutineStart.ATOMIC) {
expect(2)
@@ -104,12 +106,10 @@ class JobNestedExceptionsTest : TestBase() {
finish(7)
}
- assertEquals(1, exceptions.size, "Found $exceptions")
- val exception = exceptions[0]
- assertTrue(exception is ArithmeticException, "Exception is $exception")
+ assertIs<ArithmeticException>(exception, "Exception is $exception")
val suppressed = exception.suppressed
val ioe = suppressed[0]
- assertTrue(ioe is IOException)
+ assertIs<IOException>(ioe)
checkException<NullPointerException>(ioe.suppressed[0])
checkCycles(exception)
}
diff --git a/kotlinx-coroutines-core/jvm/test/exceptions/ProduceExceptionsTest.kt b/kotlinx-coroutines-core/jvm/test/exceptions/ProduceExceptionsTest.kt
index 8e737dc2..98f080e6 100644
--- a/kotlinx-coroutines-core/jvm/test/exceptions/ProduceExceptionsTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/exceptions/ProduceExceptionsTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.exceptions
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import org.junit.Test
@@ -61,7 +62,7 @@ class ProduceExceptionsTest : TestBase() {
produce.receive()
expectUnreached()
} catch (e: TestException) {
- assertTrue(e.suppressed[0] is TestException2)
+ assertIs<TestException2>(e.suppressed[0])
}
}
@@ -158,7 +159,7 @@ class ProduceExceptionsTest : TestBase() {
channel.receive()
} catch (e: CancellationException) {
// RECOVER_STACK_TRACES
- assertTrue(e.cause?.cause is TestException2)
+ assertIs<TestException2>(e.cause?.cause)
finish(4)
}
}
diff --git a/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryChannelsTest.kt b/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryChannelsTest.kt
index 9badd48d..f6d1986b 100644
--- a/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryChannelsTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryChannelsTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.exceptions
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import org.junit.*
diff --git a/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryCustomExceptionsTest.kt b/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryCustomExceptionsTest.kt
index 65f950be..ea0a8681 100644
--- a/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryCustomExceptionsTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryCustomExceptionsTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.exceptions
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import org.junit.Test
@@ -47,7 +48,7 @@ class StackTraceRecoveryCustomExceptionsTest : TestBase() {
} catch (e: Copyable) {
assertEquals(239, e.customData)
val cause = e.cause
- assertTrue(cause is Copyable)
+ assertIs<Copyable>(cause)
assertEquals(239, cause.customData)
}
}
@@ -64,7 +65,7 @@ class StackTraceRecoveryCustomExceptionsTest : TestBase() {
} catch (e: WithDefault) {
assertEquals("custom", e.message)
val cause = e.cause
- assertTrue(cause is WithDefault)
+ assertIs<WithDefault>(cause)
assertEquals("custom", cause.message)
}
}
@@ -79,7 +80,7 @@ class StackTraceRecoveryCustomExceptionsTest : TestBase() {
}
}
val ex = result.exceptionOrNull() ?: error("Expected to fail")
- assertTrue(ex is WrongMessageException)
+ assertIs<WrongMessageException>(ex)
assertEquals("Token OK", ex.message)
}
@@ -114,7 +115,7 @@ class StackTraceRecoveryCustomExceptionsTest : TestBase() {
// Iterator has a special code path
}
}.exceptionOrNull() ?: error("Expected to fail")
- assertTrue(ex is WrongMessageException)
+ assertIs<WrongMessageException>(ex)
assertEquals("Token OK", ex.message)
}
@@ -137,7 +138,7 @@ class StackTraceRecoveryCustomExceptionsTest : TestBase() {
}
}
val ex = result.exceptionOrNull() ?: error("Expected to fail")
- assertTrue(ex is CopyableWithCustomMessage)
+ assertIs<CopyableWithCustomMessage>(ex)
assertEquals("Recovered: [OK]", ex.message)
}
diff --git a/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryNestedScopesTest.kt b/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryNestedScopesTest.kt
index dbb1ead5..0422df98 100644
--- a/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryNestedScopesTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryNestedScopesTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.exceptions
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import kotlin.coroutines.*
@@ -8,7 +9,7 @@ class StackTraceRecoveryNestedScopesTest : TestBase() {
private val TEST_MACROS = "TEST_NAME"
- private val expectedTrace = "kotlinx.coroutines.RecoverableTestException\n" +
+ private val expectedTrace = "kotlinx.coroutines.testing.RecoverableTestException\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryNestedScopesTest.failure(StackTraceRecoveryNestedScopesTest.kt:9)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryNestedScopesTest.access\$failure(StackTraceRecoveryNestedScopesTest.kt:7)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryNestedScopesTest\$createFailingAsync\$1.invokeSuspend(StackTraceRecoveryNestedScopesTest.kt:12)\n" +
@@ -16,7 +17,7 @@ class StackTraceRecoveryNestedScopesTest : TestBase() {
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryNestedScopesTest\$callWithTimeout\$2.invokeSuspend(StackTraceRecoveryNestedScopesTest.kt:23)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryNestedScopesTest\$callCoroutineScope\$2.invokeSuspend(StackTraceRecoveryNestedScopesTest.kt:29)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryNestedScopesTest\$$TEST_MACROS\$1.invokeSuspend(StackTraceRecoveryNestedScopesTest.kt:36)\n" +
- "Caused by: kotlinx.coroutines.RecoverableTestException\n" +
+ "Caused by: kotlinx.coroutines.testing.RecoverableTestException\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryNestedScopesTest.failure(StackTraceRecoveryNestedScopesTest.kt:9)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryNestedScopesTest.access\$failure(StackTraceRecoveryNestedScopesTest.kt:7)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryNestedScopesTest\$createFailingAsync\$1.invokeSuspend(StackTraceRecoveryNestedScopesTest.kt:12)\n" +
@@ -78,7 +79,7 @@ class StackTraceRecoveryNestedScopesTest : TestBase() {
deferred.await()
} catch (e: Exception) {
verifyStackTrace(e,
- "kotlinx.coroutines.RecoverableTestException\n" +
+ "kotlinx.coroutines.testing.RecoverableTestException\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryNestedScopesTest.failure(StackTraceRecoveryNestedScopesTest.kt:23)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryNestedScopesTest.access\$failure(StackTraceRecoveryNestedScopesTest.kt:7)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryNestedScopesTest\$createFailingAsync\$1.invokeSuspend(StackTraceRecoveryNestedScopesTest.kt:26)\n" +
@@ -88,7 +89,7 @@ class StackTraceRecoveryNestedScopesTest : TestBase() {
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryNestedScopesTest\$testAwaitNestedScopes\$1\$deferred\$1.invokeSuspend(StackTraceRecoveryNestedScopesTest.kt:68)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryNestedScopesTest.verifyAwait(StackTraceRecoveryNestedScopesTest.kt:76)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryNestedScopesTest\$testAwaitNestedScopes\$1.invokeSuspend(StackTraceRecoveryNestedScopesTest.kt:71)\n" +
- "Caused by: kotlinx.coroutines.RecoverableTestException\n" +
+ "Caused by: kotlinx.coroutines.testing.RecoverableTestException\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryNestedScopesTest.failure(StackTraceRecoveryNestedScopesTest.kt:23)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryNestedScopesTest.access\$failure(StackTraceRecoveryNestedScopesTest.kt:7)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryNestedScopesTest\$createFailingAsync\$1.invokeSuspend(StackTraceRecoveryNestedScopesTest.kt:26)\n" +
diff --git a/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryNestedTest.kt b/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryNestedTest.kt
index 7421321a..28875c9a 100644
--- a/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryNestedTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryNestedTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines.exceptions
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryResumeModeTest.kt b/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryResumeModeTest.kt
index 45005aa7..1039d295 100644
--- a/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryResumeModeTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryResumeModeTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.exceptions
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import org.junit.*
diff --git a/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoverySelectTest.kt b/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoverySelectTest.kt
index fb6cb626..0ac80848 100644
--- a/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoverySelectTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoverySelectTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.exceptions
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.selects.*
diff --git a/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryTest.kt b/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryTest.kt
index 6e0afa72..169654d1 100644
--- a/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryTest.kt
@@ -1,8 +1,10 @@
package kotlinx.coroutines.exceptions
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.intrinsics.*
+import kotlinx.coroutines.testing.exceptions.*
import org.junit.Test
import java.lang.RuntimeException
import java.util.concurrent.*
@@ -85,14 +87,14 @@ class StackTraceRecoveryTest : TestBase() {
}
outerMethod(deferred,
- "kotlinx.coroutines.RecoverableTestException\n" +
+ "kotlinx.coroutines.testing.RecoverableTestException\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryTest\$testWithContext\$1\$deferred\$1.invokeSuspend(StackTraceRecoveryTest.kt:143)\n" +
"\tat _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryTest.innerMethod(StackTraceRecoveryTest.kt:158)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryTest\$outerMethod\$2.invokeSuspend(StackTraceRecoveryTest.kt:151)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryTest.outerMethod(StackTraceRecoveryTest.kt:150)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryTest\$testWithContext\$1.invokeSuspend(StackTraceRecoveryTest.kt:141)\n",
- "Caused by: kotlinx.coroutines.RecoverableTestException\n" +
+ "Caused by: kotlinx.coroutines.testing.RecoverableTestException\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryTest\$testWithContext\$1\$deferred\$1.invokeSuspend(StackTraceRecoveryTest.kt:143)\n" +
"\tat kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:32)\n")
deferred.join()
@@ -122,14 +124,14 @@ class StackTraceRecoveryTest : TestBase() {
}
outerScopedMethod(deferred,
- "kotlinx.coroutines.RecoverableTestException\n" +
+ "kotlinx.coroutines.testing.RecoverableTestException\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryTest\$testCoroutineScope\$1\$deferred\$1.invokeSuspend(StackTraceRecoveryTest.kt:143)\n" +
"\tat _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryTest.innerMethod(StackTraceRecoveryTest.kt:158)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryTest\$outerScopedMethod\$2\$1.invokeSuspend(StackTraceRecoveryTest.kt:193)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryTest\$outerScopedMethod\$2.invokeSuspend(StackTraceRecoveryTest.kt:151)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryTest\$testCoroutineScope\$1.invokeSuspend(StackTraceRecoveryTest.kt:141)\n",
- "Caused by: kotlinx.coroutines.RecoverableTestException\n" +
+ "Caused by: kotlinx.coroutines.testing.RecoverableTestException\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryTest\$testCoroutineScope\$1\$deferred\$1.invokeSuspend(StackTraceRecoveryTest.kt:143)\n" +
"\tat kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:32)\n")
deferred.join()
@@ -219,14 +221,14 @@ class StackTraceRecoveryTest : TestBase() {
barrier.await()
val e = exception
assertNotNull(e)
- verifyStackTrace(e, "kotlinx.coroutines.RecoverableTestException\n" +
+ verifyStackTrace(e, "kotlinx.coroutines.testing.RecoverableTestException\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryTest.throws(StackTraceRecoveryTest.kt:280)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryTest.access\$throws(StackTraceRecoveryTest.kt:20)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryTest\$throws\$1.invokeSuspend(StackTraceRecoveryTest.kt)\n" +
"\tat _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryTest.awaiter(StackTraceRecoveryTest.kt:285)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryTest\$testNonDispatchedRecovery\$await\$1.invokeSuspend(StackTraceRecoveryTest.kt:291)\n" +
- "Caused by: kotlinx.coroutines.RecoverableTestException")
+ "Caused by: kotlinx.coroutines.testing.RecoverableTestException")
}
private class Callback(val cont: CancellableContinuation<*>)
@@ -238,12 +240,12 @@ class StackTraceRecoveryTest : TestBase() {
try {
awaitCallback(channel)
} catch (e: Throwable) {
- verifyStackTrace(e, "kotlinx.coroutines.RecoverableTestException\n" +
+ verifyStackTrace(e, "kotlinx.coroutines.testing.RecoverableTestException\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryTest\$testCancellableContinuation\$1.invokeSuspend(StackTraceRecoveryTest.kt:329)\n" +
"\tat _COROUTINE._BOUNDARY._(CoroutineDebugging.kt)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryTest.awaitCallback(StackTraceRecoveryTest.kt:348)\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryTest\$testCancellableContinuation\$1\$1.invokeSuspend(StackTraceRecoveryTest.kt:322)\n" +
- "Caused by: kotlinx.coroutines.RecoverableTestException\n" +
+ "Caused by: kotlinx.coroutines.testing.RecoverableTestException\n" +
"\tat kotlinx.coroutines.exceptions.StackTraceRecoveryTest\$testCancellableContinuation\$1.invokeSuspend(StackTraceRecoveryTest.kt:329)")
}
}
diff --git a/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryWithTimeoutTest.kt b/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryWithTimeoutTest.kt
index 2099e21a..6d573669 100644
--- a/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryWithTimeoutTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/exceptions/StackTraceRecoveryWithTimeoutTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.exceptions
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import org.junit.rules.*
diff --git a/kotlinx-coroutines-core/jvm/test/exceptions/SuppressionTests.kt b/kotlinx-coroutines-core/jvm/test/exceptions/SuppressionTests.kt
index fbcf168d..33469573 100644
--- a/kotlinx-coroutines-core/jvm/test/exceptions/SuppressionTests.kt
+++ b/kotlinx-coroutines-core/jvm/test/exceptions/SuppressionTests.kt
@@ -1,7 +1,9 @@
package kotlinx.coroutines.exceptions
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
+import kotlinx.coroutines.testing.exceptions.*
import java.io.*
import kotlin.coroutines.*
import kotlin.test.*
@@ -18,7 +20,7 @@ class SuppressionTests : TestBase() {
}
override fun onCancelling(cause: Throwable?) {
- assertTrue(cause is ArithmeticException)
+ assertIs<ArithmeticException>(cause)
assertTrue(cause.suppressed.isEmpty())
expect(5)
}
@@ -28,20 +30,20 @@ class SuppressionTests : TestBase() {
}
override fun onCancelled(cause: Throwable, handled: Boolean) {
- assertTrue(cause is ArithmeticException)
+ assertIs<ArithmeticException>(cause)
checkException<IOException>(cause.suppressed[0])
expect(8)
}
}
coroutine.invokeOnCompletion(onCancelling = true) {
- assertTrue(it is ArithmeticException)
+ assertIs<ArithmeticException>(it)
assertTrue(it.suppressed.isEmpty())
expect(6)
}
coroutine.invokeOnCompletion {
- assertTrue(it is ArithmeticException)
+ assertIs<ArithmeticException>(it)
checkException<IOException>(it.suppressed[0])
expect(9)
}
diff --git a/kotlinx-coroutines-core/jvm/test/exceptions/WithContextCancellationStressTest.kt b/kotlinx-coroutines-core/jvm/test/exceptions/WithContextCancellationStressTest.kt
index 864904e0..ad353340 100644
--- a/kotlinx-coroutines-core/jvm/test/exceptions/WithContextCancellationStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/exceptions/WithContextCancellationStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.exceptions
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import org.junit.Test
diff --git a/kotlinx-coroutines-core/jvm/test/exceptions/WithContextExceptionHandlingTest.kt b/kotlinx-coroutines-core/jvm/test/exceptions/WithContextExceptionHandlingTest.kt
index 8618f9eb..11809ce5 100644
--- a/kotlinx-coroutines-core/jvm/test/exceptions/WithContextExceptionHandlingTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/exceptions/WithContextExceptionHandlingTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.exceptions
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import org.junit.runner.*
@@ -25,7 +26,7 @@ class WithContextExceptionHandlingTest(private val mode: Mode) : TestBase() {
* Result: TE2
*/
runCancellation(null, TestException2()) { e ->
- assertTrue(e is TestException2)
+ assertIs<TestException2>(e)
assertNull(e.cause)
val suppressed = e.suppressed
assertTrue(suppressed.isEmpty())
@@ -41,7 +42,7 @@ class WithContextExceptionHandlingTest(private val mode: Mode) : TestBase() {
*/
val cancellationCause = TestCancellationException()
runCancellation(cancellationCause, TestException2()) { e ->
- assertTrue(e is TestException2)
+ assertIs<TestException2>(e)
assertNull(e.cause)
val suppressed = e.suppressed
assertTrue(suppressed.isEmpty())
@@ -57,7 +58,7 @@ class WithContextExceptionHandlingTest(private val mode: Mode) : TestBase() {
*/
val cancellationCause = TestCancellationException()
runCancellation(cancellationCause, cancellationCause) { e ->
- assertTrue(e is TestCancellationException)
+ assertIs<TestCancellationException>(e)
assertNull(e.cause)
val suppressed = e.suppressed
assertTrue(suppressed.isEmpty())
@@ -274,4 +275,4 @@ class WithContextExceptionHandlingTest(private val mode: Mode) : TestBase() {
}
fail()
}
-} \ No newline at end of file
+}
diff --git a/kotlinx-coroutines-core/jvm/test/flow/CallbackFlowTest.kt b/kotlinx-coroutines-core/jvm/test/flow/CallbackFlowTest.kt
index 17fa5321..f59bc1b2 100644
--- a/kotlinx-coroutines-core/jvm/test/flow/CallbackFlowTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/flow/CallbackFlowTest.kt
@@ -1,7 +1,9 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
+import kotlinx.coroutines.testing.flow.*
import org.junit.Test
import kotlin.concurrent.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/flow/ExceptionTransparencyTest.kt b/kotlinx-coroutines-core/jvm/test/flow/ExceptionTransparencyTest.kt
index e5ffa5d8..63875087 100644
--- a/kotlinx-coroutines-core/jvm/test/flow/ExceptionTransparencyTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/flow/ExceptionTransparencyTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/flow/FirstJvmTest.kt b/kotlinx-coroutines-core/jvm/test/flow/FirstJvmTest.kt
index 262bd9dc..1ac9bd2c 100644
--- a/kotlinx-coroutines-core/jvm/test/flow/FirstJvmTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/flow/FirstJvmTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/flow/FlatMapStressTest.kt b/kotlinx-coroutines-core/jvm/test/flow/FlatMapStressTest.kt
index 928474a9..01201e09 100644
--- a/kotlinx-coroutines-core/jvm/test/flow/FlatMapStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/flow/FlatMapStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.internal.*
import kotlinx.coroutines.scheduling.*
diff --git a/kotlinx-coroutines-core/jvm/test/flow/OnCompletionInterceptedReleaseTest.kt b/kotlinx-coroutines-core/jvm/test/flow/OnCompletionInterceptedReleaseTest.kt
index d293ead7..5d332bf3 100644
--- a/kotlinx-coroutines-core/jvm/test/flow/OnCompletionInterceptedReleaseTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/flow/OnCompletionInterceptedReleaseTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import kotlin.coroutines.*
diff --git a/kotlinx-coroutines-core/jvm/test/flow/SafeCollectorMemoryLeakTest.kt b/kotlinx-coroutines-core/jvm/test/flow/SafeCollectorMemoryLeakTest.kt
index 36b28c5d..094f8cca 100644
--- a/kotlinx-coroutines-core/jvm/test/flow/SafeCollectorMemoryLeakTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/flow/SafeCollectorMemoryLeakTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
diff --git a/kotlinx-coroutines-core/jvm/test/flow/SharedFlowStressTest.kt b/kotlinx-coroutines-core/jvm/test/flow/SharedFlowStressTest.kt
index fe90365a..712f2bd0 100644
--- a/kotlinx-coroutines-core/jvm/test/flow/SharedFlowStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/flow/SharedFlowStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.atomicfu.*
import kotlinx.coroutines.*
import org.junit.*
diff --git a/kotlinx-coroutines-core/jvm/test/flow/SharingReferenceTest.kt b/kotlinx-coroutines-core/jvm/test/flow/SharingReferenceTest.kt
index fce21b20..f1e15be1 100644
--- a/kotlinx-coroutines-core/jvm/test/flow/SharingReferenceTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/flow/SharingReferenceTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.internal.*
import org.junit.*
diff --git a/kotlinx-coroutines-core/jvm/test/flow/SharingStressTest.kt b/kotlinx-coroutines-core/jvm/test/flow/SharingStressTest.kt
index 0a7352bc..7a524853 100644
--- a/kotlinx-coroutines-core/jvm/test/flow/SharingStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/flow/SharingStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import org.junit.Test
diff --git a/kotlinx-coroutines-core/jvm/test/flow/StateFlowCancellabilityTest.kt b/kotlinx-coroutines-core/jvm/test/flow/StateFlowCancellabilityTest.kt
index 6f93199d..cb91dd6d 100644
--- a/kotlinx-coroutines-core/jvm/test/flow/StateFlowCancellabilityTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/flow/StateFlowCancellabilityTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import java.util.concurrent.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/flow/StateFlowStressTest.kt b/kotlinx-coroutines-core/jvm/test/flow/StateFlowStressTest.kt
index d69a88e0..3739aef9 100644
--- a/kotlinx-coroutines-core/jvm/test/flow/StateFlowStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/flow/StateFlowStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import kotlin.random.*
diff --git a/kotlinx-coroutines-core/jvm/test/flow/StateFlowUpdateStressTest.kt b/kotlinx-coroutines-core/jvm/test/flow/StateFlowUpdateStressTest.kt
index 2d85b2e7..adc6610f 100644
--- a/kotlinx-coroutines-core/jvm/test/flow/StateFlowUpdateStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/flow/StateFlowUpdateStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.flow
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/internal/ConcurrentWeakMapCollectionStressTest.kt b/kotlinx-coroutines-core/jvm/test/internal/ConcurrentWeakMapCollectionStressTest.kt
index ff9c8f7a..a85b3963 100644
--- a/kotlinx-coroutines-core/jvm/test/internal/ConcurrentWeakMapCollectionStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/internal/ConcurrentWeakMapCollectionStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.internal
+import kotlinx.coroutines.testing.*
import junit.framework.Assert.*
import kotlinx.coroutines.*
import kotlinx.coroutines.debug.internal.*
diff --git a/kotlinx-coroutines-core/jvm/test/internal/ConcurrentWeakMapOperationStressTest.kt b/kotlinx-coroutines-core/jvm/test/internal/ConcurrentWeakMapOperationStressTest.kt
index ae58a384..934dbbcd 100644
--- a/kotlinx-coroutines-core/jvm/test/internal/ConcurrentWeakMapOperationStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/internal/ConcurrentWeakMapOperationStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.internal
+import kotlinx.coroutines.testing.*
import kotlinx.atomicfu.*
import kotlinx.coroutines.*
import kotlinx.coroutines.debug.internal.*
diff --git a/kotlinx-coroutines-core/jvm/test/internal/ConcurrentWeakMapTest.kt b/kotlinx-coroutines-core/jvm/test/internal/ConcurrentWeakMapTest.kt
index dbeb77bd..2394e90d 100644
--- a/kotlinx-coroutines-core/jvm/test/internal/ConcurrentWeakMapTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/internal/ConcurrentWeakMapTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.internal
+import kotlinx.coroutines.testing.*
import junit.framework.Assert.*
import kotlinx.coroutines.*
import kotlinx.coroutines.debug.internal.*
diff --git a/kotlinx-coroutines-core/jvm/test/internal/FastServiceLoaderTest.kt b/kotlinx-coroutines-core/jvm/test/internal/FastServiceLoaderTest.kt
index a070f635..b47cd7d6 100644
--- a/kotlinx-coroutines-core/jvm/test/internal/FastServiceLoaderTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/internal/FastServiceLoaderTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.internal
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/internal/LockFreeLinkedListLongStressTest.kt b/kotlinx-coroutines-core/jvm/test/internal/LockFreeLinkedListLongStressTest.kt
index fd44d5de..577e73d1 100644
--- a/kotlinx-coroutines-core/jvm/test/internal/LockFreeLinkedListLongStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/internal/LockFreeLinkedListLongStressTest.kt
@@ -1,6 +1,7 @@
package kotlinx.coroutines.internal
-import kotlinx.coroutines.TestBase
+import kotlinx.coroutines.testing.*
+import kotlinx.coroutines.testing.TestBase
import org.junit.Test
import java.util.*
import java.util.concurrent.atomic.AtomicInteger
diff --git a/kotlinx-coroutines-core/jvm/test/internal/LockFreeTaskQueueStressTest.kt b/kotlinx-coroutines-core/jvm/test/internal/LockFreeTaskQueueStressTest.kt
index f4c4e9bc..625df766 100644
--- a/kotlinx-coroutines-core/jvm/test/internal/LockFreeTaskQueueStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/internal/LockFreeTaskQueueStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.internal
+import kotlinx.coroutines.testing.*
import kotlinx.atomicfu.*
import kotlinx.coroutines.*
import org.junit.runner.*
diff --git a/kotlinx-coroutines-core/jvm/test/internal/LockFreeTaskQueueTest.kt b/kotlinx-coroutines-core/jvm/test/internal/LockFreeTaskQueueTest.kt
index 5be63f76..de4dff8a 100644
--- a/kotlinx-coroutines-core/jvm/test/internal/LockFreeTaskQueueTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/internal/LockFreeTaskQueueTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.internal
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.runner.*
import org.junit.runners.*
diff --git a/kotlinx-coroutines-core/jvm/test/internal/ThreadSafeHeapStressTest.kt b/kotlinx-coroutines-core/jvm/test/internal/ThreadSafeHeapStressTest.kt
index 742043fa..20ae9f3e 100644
--- a/kotlinx-coroutines-core/jvm/test/internal/ThreadSafeHeapStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/internal/ThreadSafeHeapStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.internal
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import java.util.concurrent.*
import java.util.concurrent.CancellationException
diff --git a/kotlinx-coroutines-core/jvm/test/internal/ThreadSafeHeapTest.kt b/kotlinx-coroutines-core/jvm/test/internal/ThreadSafeHeapTest.kt
index 0fb583c2..c7f25480 100644
--- a/kotlinx-coroutines-core/jvm/test/internal/ThreadSafeHeapTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/internal/ThreadSafeHeapTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.internal
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
import java.util.*
diff --git a/kotlinx-coroutines-core/jvm/test/jdk8/future/AsFutureTest.kt b/kotlinx-coroutines-core/jvm/test/jdk8/future/AsFutureTest.kt
index afde06c3..3296072c 100644
--- a/kotlinx-coroutines-core/jvm/test/jdk8/future/AsFutureTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/jdk8/future/AsFutureTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.future
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import java.util.concurrent.*
@@ -61,7 +62,7 @@ class AsFutureTest : TestBase() {
expectUnreached()
} catch (e: ExecutionException) {
assertTrue(future.isCompletedExceptionally)
- assertTrue(e.cause is OutOfMemoryError)
+ assertIs<OutOfMemoryError>(e.cause)
finish(2)
}
}
@@ -77,7 +78,7 @@ class AsFutureTest : TestBase() {
expectUnreached()
} catch (e: ExecutionException) {
assertTrue(future.isCompletedExceptionally)
- assertTrue(e.cause is OutOfMemoryError)
+ assertIs<OutOfMemoryError>(e.cause)
finish(2)
}
}
@@ -115,6 +116,6 @@ class AsFutureTest : TestBase() {
assertTrue(deferred.isCancelled)
assertTrue(deferred.isCompleted)
assertFalse(deferred.isActive)
- assertTrue(deferred.getCompletionExceptionOrNull() is CancellationException)
+ assertIs<CancellationException>(deferred.getCompletionExceptionOrNull())
}
}
diff --git a/kotlinx-coroutines-core/jvm/test/jdk8/future/FutureAsDeferredUnhandledCompletionExceptionTest.kt b/kotlinx-coroutines-core/jvm/test/jdk8/future/FutureAsDeferredUnhandledCompletionExceptionTest.kt
index ebd95f5b..97d54847 100644
--- a/kotlinx-coroutines-core/jvm/test/jdk8/future/FutureAsDeferredUnhandledCompletionExceptionTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/jdk8/future/FutureAsDeferredUnhandledCompletionExceptionTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.future
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.future.*
import org.junit.*
diff --git a/kotlinx-coroutines-core/jvm/test/jdk8/future/FutureExceptionsTest.kt b/kotlinx-coroutines-core/jvm/test/jdk8/future/FutureExceptionsTest.kt
index a714f1e8..0fc1290a 100644
--- a/kotlinx-coroutines-core/jvm/test/jdk8/future/FutureExceptionsTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/jdk8/future/FutureExceptionsTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.future
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import java.io.*
diff --git a/kotlinx-coroutines-core/jvm/test/jdk8/future/FutureTest.kt b/kotlinx-coroutines-core/jvm/test/jdk8/future/FutureTest.kt
index 13af7f13..0b9f83b0 100644
--- a/kotlinx-coroutines-core/jvm/test/jdk8/future/FutureTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/jdk8/future/FutureTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.future
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.CancellationException
import org.junit.*
@@ -154,7 +155,7 @@ class FutureTest : TestBase() {
future.get()
fail("'get' should've throw an exception")
} catch (e: ExecutionException) {
- assertTrue(e.cause is IllegalStateException)
+ assertIs<IllegalStateException>(e.cause)
assertEquals("OK", e.cause!!.message)
}
}
@@ -236,14 +237,14 @@ class FutureTest : TestBase() {
assertTrue(deferred.isCancelled)
val completionException = deferred.getCompletionExceptionOrNull()!!
- assertTrue(completionException is TestException)
+ assertIs<TestException>(completionException)
assertEquals("something went wrong", completionException.message)
try {
deferred.await()
fail("deferred.await() should throw an exception")
} catch (e: Throwable) {
- assertTrue(e is TestException)
+ assertIs<TestException>(e)
assertEquals("something went wrong", e.message)
}
}
@@ -470,7 +471,7 @@ class FutureTest : TestBase() {
private inline fun <reified T: Throwable> CompletableFuture<*>.checkFutureException(vararg suppressed: KClass<out Throwable>) {
val e = assertFailsWith<ExecutionException> { get() }
val cause = e.cause!!
- assertTrue(cause is T)
+ assertIs<T>(cause)
for ((index, clazz) in suppressed.withIndex()) {
assertTrue(clazz.isInstance(cause.suppressed[index]))
}
diff --git a/kotlinx-coroutines-core/jvm/test/jdk8/stream/ConsumeAsFlowTest.kt b/kotlinx-coroutines-core/jvm/test/jdk8/stream/ConsumeAsFlowTest.kt
index 38f4c57a..49e8f34c 100644
--- a/kotlinx-coroutines-core/jvm/test/jdk8/stream/ConsumeAsFlowTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/jdk8/stream/ConsumeAsFlowTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.stream
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import org.junit.Test
diff --git a/kotlinx-coroutines-core/jvm/test/jdk8/time/DurationOverflowTest.kt b/kotlinx-coroutines-core/jvm/test/jdk8/time/DurationOverflowTest.kt
index 42adef86..d13e4e05 100644
--- a/kotlinx-coroutines-core/jvm/test/jdk8/time/DurationOverflowTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/jdk8/time/DurationOverflowTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.time
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.selects.*
import org.junit.Test
diff --git a/kotlinx-coroutines-core/jvm/test/jdk8/time/FlowDebounceTest.kt b/kotlinx-coroutines-core/jvm/test/jdk8/time/FlowDebounceTest.kt
index c0b442df..7313b1a7 100644
--- a/kotlinx-coroutines-core/jvm/test/jdk8/time/FlowDebounceTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/jdk8/time/FlowDebounceTest.kt
@@ -1,6 +1,7 @@
package kotlinx.coroutines.time
-import kotlinx.coroutines.TestBase
+import kotlinx.coroutines.testing.*
+import kotlinx.coroutines.testing.TestBase
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.withVirtualTime
diff --git a/kotlinx-coroutines-core/jvm/test/jdk8/time/FlowSampleTest.kt b/kotlinx-coroutines-core/jvm/test/jdk8/time/FlowSampleTest.kt
index c51cedf9..a19c4b75 100644
--- a/kotlinx-coroutines-core/jvm/test/jdk8/time/FlowSampleTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/jdk8/time/FlowSampleTest.kt
@@ -1,6 +1,7 @@
package kotlinx.coroutines.time
-import kotlinx.coroutines.TestBase
+import kotlinx.coroutines.testing.*
+import kotlinx.coroutines.testing.TestBase
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.toList
import kotlinx.coroutines.withVirtualTime
diff --git a/kotlinx-coroutines-core/jvm/test/jdk8/time/WithTimeoutTest.kt b/kotlinx-coroutines-core/jvm/test/jdk8/time/WithTimeoutTest.kt
index 7ebe9948..c34a6b19 100644
--- a/kotlinx-coroutines-core/jvm/test/jdk8/time/WithTimeoutTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/jdk8/time/WithTimeoutTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.time
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import java.time.*
diff --git a/kotlinx-coroutines-core/jvm/test/knit/ClosedAfterGuideTestExecutor.kt b/kotlinx-coroutines-core/jvm/test/knit/ClosedAfterGuideTestExecutor.kt
index e5127d6a..bbe4dc10 100644
--- a/kotlinx-coroutines-core/jvm/test/knit/ClosedAfterGuideTestExecutor.kt
+++ b/kotlinx-coroutines-core/jvm/test/knit/ClosedAfterGuideTestExecutor.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines // Trick to make guide tests use these declarations with executors that can be closed on our side implicitly
+import kotlinx.coroutines.testing.*
import java.util.concurrent.*
import java.util.concurrent.atomic.*
import kotlin.coroutines.*
@@ -9,15 +10,6 @@ internal fun newSingleThreadContext(name: String): ExecutorCoroutineDispatcher =
internal fun newFixedThreadPoolContext(nThreads: Int, name: String): ExecutorCoroutineDispatcher =
ClosedAfterGuideTestDispatcher(nThreads, name)
-internal class PoolThread(
- @JvmField val dispatcher: ExecutorCoroutineDispatcher, // for debugging & tests
- target: Runnable, name: String
-) : Thread(target, name) {
- init {
- isDaemon = true
- }
-}
-
private class ClosedAfterGuideTestDispatcher(
private val nThreads: Int,
private val name: String
diff --git a/kotlinx-coroutines-core/jvm/test/knit/TestUtil.kt b/kotlinx-coroutines-core/jvm/test/knit/TestUtil.kt
index 85d79869..d0a55515 100644
--- a/kotlinx-coroutines-core/jvm/test/knit/TestUtil.kt
+++ b/kotlinx-coroutines-core/jvm/test/knit/TestUtil.kt
@@ -3,6 +3,7 @@ package kotlinx.coroutines.knit
import kotlinx.coroutines.*
import kotlinx.coroutines.internal.*
import kotlinx.coroutines.scheduling.*
+import kotlinx.coroutines.testing.*
import kotlinx.knit.test.*
import java.util.concurrent.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/lincheck/ChannelsLincheckTest.kt b/kotlinx-coroutines-core/jvm/test/lincheck/ChannelsLincheckTest.kt
index 4391ce6a..26a58c3d 100644
--- a/kotlinx-coroutines-core/jvm/test/lincheck/ChannelsLincheckTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/lincheck/ChannelsLincheckTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines.lincheck
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.channels.Channel.Factory.CONFLATED
diff --git a/kotlinx-coroutines-core/jvm/test/lincheck/SemaphoreLincheckTest.kt b/kotlinx-coroutines-core/jvm/test/lincheck/SemaphoreLincheckTest.kt
index 94a521ba..12b44d57 100644
--- a/kotlinx-coroutines-core/jvm/test/lincheck/SemaphoreLincheckTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/lincheck/SemaphoreLincheckTest.kt
@@ -1,6 +1,7 @@
@file:Suppress("unused")
package kotlinx.coroutines.lincheck
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.sync.*
import org.jetbrains.kotlinx.lincheck.*
diff --git a/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherLivenessStressTest.kt b/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherLivenessStressTest.kt
index 83e925e6..20748a2d 100644
--- a/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherLivenessStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherLivenessStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.scheduling
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import org.junit.Test
diff --git a/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherMixedStealingStressTest.kt b/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherMixedStealingStressTest.kt
index 2b8dacb9..fe0fa4a4 100644
--- a/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherMixedStealingStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherMixedStealingStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.scheduling
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import java.util.concurrent.*
diff --git a/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherTerminationStressTest.kt b/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherTerminationStressTest.kt
index f947ddc9..2b00eb7c 100644
--- a/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherTerminationStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherTerminationStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.scheduling.*
import org.junit.*
import java.util.*
diff --git a/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherTest.kt b/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherTest.kt
index b994cef3..49510cde 100644
--- a/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.scheduling
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import org.junit.rules.*
diff --git a/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherThreadLimitStressTest.kt b/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherThreadLimitStressTest.kt
index 13efa3f0..8029db68 100644
--- a/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherThreadLimitStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherThreadLimitStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.scheduling
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Ignore
import org.junit.Test
diff --git a/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherWorkSignallingStressTest.kt b/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherWorkSignallingStressTest.kt
index 8b9c7e51..81a14210 100644
--- a/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherWorkSignallingStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/scheduling/BlockingCoroutineDispatcherWorkSignallingStressTest.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines.scheduling
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import java.util.concurrent.*
diff --git a/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineDispatcherTest.kt b/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineDispatcherTest.kt
index 398d1150..ee21be23 100644
--- a/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineDispatcherTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineDispatcherTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.scheduling
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import org.junit.Test
diff --git a/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerCloseStressTest.kt b/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerCloseStressTest.kt
index 9e3fff80..d6719aaa 100644
--- a/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerCloseStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerCloseStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.scheduling
+import kotlinx.coroutines.testing.*
import kotlinx.atomicfu.*
import kotlinx.coroutines.*
import org.junit.Test
diff --git a/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerInternalApiStressTest.kt b/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerInternalApiStressTest.kt
index db71afc2..dbc66091 100644
--- a/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerInternalApiStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerInternalApiStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.scheduling
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.internal.AVAILABLE_PROCESSORS
import org.junit.Test
diff --git a/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerLivenessStressTest.kt b/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerLivenessStressTest.kt
index c014f536..07b549f9 100644
--- a/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerLivenessStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerLivenessStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.scheduling
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.scheduling.CoroutineScheduler.Companion.MAX_SUPPORTED_POOL_SIZE
import org.junit.*
diff --git a/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerOversubscriptionTest.kt b/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerOversubscriptionTest.kt
index d6c023b4..c891878f 100644
--- a/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerOversubscriptionTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerOversubscriptionTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.scheduling
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import java.util.concurrent.*
diff --git a/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerStressTest.kt b/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerStressTest.kt
index 0b91e491..615cdeea 100644
--- a/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.scheduling
+import kotlinx.coroutines.testing.*
import kotlinx.atomicfu.*
import kotlinx.coroutines.*
import kotlinx.coroutines.internal.*
diff --git a/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerTest.kt b/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerTest.kt
index ef3640ec..edb37996 100644
--- a/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/scheduling/CoroutineSchedulerTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.scheduling
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import java.lang.Runnable
diff --git a/kotlinx-coroutines-core/jvm/test/scheduling/DefaultDispatchersTest.kt b/kotlinx-coroutines-core/jvm/test/scheduling/DefaultDispatchersTest.kt
index bee35d3e..f06f7cbe 100644
--- a/kotlinx-coroutines-core/jvm/test/scheduling/DefaultDispatchersTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/scheduling/DefaultDispatchersTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.scheduling
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import java.util.concurrent.*
diff --git a/kotlinx-coroutines-core/jvm/test/scheduling/LimitingCoroutineDispatcherStressTest.kt b/kotlinx-coroutines-core/jvm/test/scheduling/LimitingCoroutineDispatcherStressTest.kt
index 6b3f9322..6a11444d 100644
--- a/kotlinx-coroutines-core/jvm/test/scheduling/LimitingCoroutineDispatcherStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/scheduling/LimitingCoroutineDispatcherStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.scheduling
+import kotlinx.coroutines.testing.*
import kotlinx.atomicfu.*
import kotlinx.coroutines.*
import org.junit.Test
diff --git a/kotlinx-coroutines-core/jvm/test/scheduling/LimitingDispatcherTest.kt b/kotlinx-coroutines-core/jvm/test/scheduling/LimitingDispatcherTest.kt
index b4baaf94..1ba11200 100644
--- a/kotlinx-coroutines-core/jvm/test/scheduling/LimitingDispatcherTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/scheduling/LimitingDispatcherTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.scheduling
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import java.util.concurrent.*
diff --git a/kotlinx-coroutines-core/jvm/test/scheduling/SchedulerTestBase.kt b/kotlinx-coroutines-core/jvm/test/scheduling/SchedulerTestBase.kt
index c9ea6249..f6e0f70a 100644
--- a/kotlinx-coroutines-core/jvm/test/scheduling/SchedulerTestBase.kt
+++ b/kotlinx-coroutines-core/jvm/test/scheduling/SchedulerTestBase.kt
@@ -2,6 +2,7 @@
package kotlinx.coroutines.scheduling
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.internal.*
import org.junit.*
diff --git a/kotlinx-coroutines-core/jvm/test/scheduling/SharingWorkerClassTest.kt b/kotlinx-coroutines-core/jvm/test/scheduling/SharingWorkerClassTest.kt
index e1c3a831..87103d76 100644
--- a/kotlinx-coroutines-core/jvm/test/scheduling/SharingWorkerClassTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/scheduling/SharingWorkerClassTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.scheduling
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/scheduling/WorkQueueStressTest.kt b/kotlinx-coroutines-core/jvm/test/scheduling/WorkQueueStressTest.kt
index 17a78190..1bf2434f 100644
--- a/kotlinx-coroutines-core/jvm/test/scheduling/WorkQueueStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/scheduling/WorkQueueStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.scheduling
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import org.junit.Test
diff --git a/kotlinx-coroutines-core/jvm/test/scheduling/WorkQueueTest.kt b/kotlinx-coroutines-core/jvm/test/scheduling/WorkQueueTest.kt
index 3aabb3ed..e9fbc6be 100644
--- a/kotlinx-coroutines-core/jvm/test/scheduling/WorkQueueTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/scheduling/WorkQueueTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.scheduling
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import org.junit.Test
diff --git a/kotlinx-coroutines-core/jvm/test/selects/SelectDeadlockStressTest.kt b/kotlinx-coroutines-core/jvm/test/selects/SelectDeadlockStressTest.kt
index 52925941..466aecf9 100644
--- a/kotlinx-coroutines-core/jvm/test/selects/SelectDeadlockStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/selects/SelectDeadlockStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.selects
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import org.junit.*
diff --git a/kotlinx-coroutines-core/jvm/test/selects/SelectMemoryLeakStressTest.kt b/kotlinx-coroutines-core/jvm/test/selects/SelectMemoryLeakStressTest.kt
index 07203d9b..4b0ce469 100644
--- a/kotlinx-coroutines-core/jvm/test/selects/SelectMemoryLeakStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/selects/SelectMemoryLeakStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.selects
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/jvm/test/selects/SelectPhilosophersStressTest.kt b/kotlinx-coroutines-core/jvm/test/selects/SelectPhilosophersStressTest.kt
index 5c1ca952..09918068 100644
--- a/kotlinx-coroutines-core/jvm/test/selects/SelectPhilosophersStressTest.kt
+++ b/kotlinx-coroutines-core/jvm/test/selects/SelectPhilosophersStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.selects
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.sync.*
import org.junit.Test
diff --git a/kotlinx-coroutines-core/native/test/DelayExceptionTest.kt b/kotlinx-coroutines-core/native/test/DelayExceptionTest.kt
index e80398c1..8ffa0e2e 100644
--- a/kotlinx-coroutines-core/native/test/DelayExceptionTest.kt
+++ b/kotlinx-coroutines-core/native/test/DelayExceptionTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-core/native/test/TestBase.kt b/kotlinx-coroutines-core/native/test/TestBase.kt
deleted file mode 100644
index 12990bcd..00000000
--- a/kotlinx-coroutines-core/native/test/TestBase.kt
+++ /dev/null
@@ -1,110 +0,0 @@
-package kotlinx.coroutines
-
-import kotlinx.atomicfu.*
-
-public actual val isStressTest: Boolean = false
-public actual val stressTestMultiplier: Int = 1
-public actual val stressTestMultiplierSqrt: Int = 1
-
-public actual val isNative = true
-
-@Suppress("ACTUAL_WITHOUT_EXPECT")
-public actual typealias TestResult = Unit
-
-public actual open class TestBase actual constructor() {
- public actual val isBoundByJsTestTimeout = false
- private val actionIndex = atomic(0)
- private val finished = atomic(false)
- private var error: Throwable? = null
-
- /**
- * Throws [IllegalStateException] like `error` in stdlib, but also ensures that the test will not
- * complete successfully even if this exception is consumed somewhere in the test.
- */
- public actual fun error(message: Any, cause: Throwable?): Nothing {
- val exception = IllegalStateException(message.toString(), cause)
- if (error == null) error = exception
- throw exception
- }
-
- private fun printError(message: String, cause: Throwable) {
- if (error == null) error = cause
- println("$message: $cause")
- }
-
- /**
- * Asserts that this invocation is `index`-th in the execution sequence (counting from one).
- */
- public actual fun expect(index: Int) {
- val wasIndex = actionIndex.incrementAndGet()
- check(index == wasIndex) { "Expecting action index $index but it is actually $wasIndex" }
- }
-
- /**
- * Asserts that this line is never executed.
- */
- public actual fun expectUnreached() {
- error("Should not be reached")
- }
-
- /**
- * Asserts that this it the last action in the test. It must be invoked by any test that used [expect].
- */
- public actual fun finish(index: Int) {
- expect(index)
- check(!finished.value) { "Should call 'finish(...)' at most once" }
- finished.value = true
- }
-
- /**
- * Asserts that [finish] was invoked
- */
- actual fun ensureFinished() {
- require(finished.value) { "finish(...) should be caller prior to this check" }
- }
-
- actual fun reset() {
- check(actionIndex.value == 0 || finished.value) { "Expecting that 'finish(...)' was invoked, but it was not" }
- actionIndex.value = 0
- finished.value = false
- }
-
- actual fun println(message: Any?) {
- kotlin.io.println(message)
- }
-
- @Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
- public actual fun runTest(
- expected: ((Throwable) -> Boolean)? = null,
- unhandled: List<(Throwable) -> Boolean> = emptyList(),
- block: suspend CoroutineScope.() -> Unit
- ): TestResult {
- var exCount = 0
- var ex: Throwable? = null
- try {
- runBlocking(block = block, context = CoroutineExceptionHandler { _, e ->
- if (e is CancellationException) return@CoroutineExceptionHandler // are ignored
- exCount++
- when {
- exCount > unhandled.size ->
- printError("Too many unhandled exceptions $exCount, expected ${unhandled.size}, got: $e", e)
- !unhandled[exCount - 1](e) ->
- printError("Unhandled exception was unexpected: $e", e)
- }
- })
- } catch (e: Throwable) {
- ex = e
- if (expected != null) {
- if (!expected(e))
- error("Unexpected exception: $e", e)
- } else
- throw e
- } finally {
- if (ex == null && expected != null) error("Exception was expected but none produced")
- }
- if (exCount < unhandled.size)
- error("Too few unhandled exceptions $exCount, expected ${unhandled.size}")
- }
-}
-
-public actual val isJavaAndWindows: Boolean get() = false
diff --git a/kotlinx-coroutines-core/native/test/WorkerTest.kt b/kotlinx-coroutines-core/native/test/WorkerTest.kt
index 41c6cec8..1eb9d92a 100644
--- a/kotlinx-coroutines-core/native/test/WorkerTest.kt
+++ b/kotlinx-coroutines-core/native/test/WorkerTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.channels.*
import kotlin.coroutines.*
import kotlin.native.concurrent.*
diff --git a/kotlinx-coroutines-core/nativeDarwin/test/MainDispatcherTest.kt b/kotlinx-coroutines-core/nativeDarwin/test/MainDispatcherTest.kt
index ac967f44..0094bcd7 100644
--- a/kotlinx-coroutines-core/nativeDarwin/test/MainDispatcherTest.kt
+++ b/kotlinx-coroutines-core/nativeDarwin/test/MainDispatcherTest.kt
@@ -1,6 +1,8 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.cinterop.*
+import kotlinx.coroutines.testing.*
import platform.CoreFoundation.*
import platform.darwin.*
import kotlin.coroutines.*
diff --git a/kotlinx-coroutines-core/wasmJs/test/PromiseTest.kt b/kotlinx-coroutines-core/wasmJs/test/PromiseTest.kt
index 4ae42c5c..63550439 100644
--- a/kotlinx-coroutines-core/wasmJs/test/PromiseTest.kt
+++ b/kotlinx-coroutines-core/wasmJs/test/PromiseTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlin.js.*
import kotlin.test.*
@@ -26,7 +27,7 @@ class PromiseTest : TestBase() {
deferred.await()
expectUnreached()
} catch (e: Throwable) {
- assertTrue(e is TestException)
+ assertIs<TestException>(e)
assertEquals("Rejected", e.message)
}
}
diff --git a/kotlinx-coroutines-core/wasmJs/test/TestBase.kt b/kotlinx-coroutines-core/wasmJs/test/TestBase.kt
deleted file mode 100644
index e5a326e6..00000000
--- a/kotlinx-coroutines-core/wasmJs/test/TestBase.kt
+++ /dev/null
@@ -1,139 +0,0 @@
-package kotlinx.coroutines
-
-import kotlin.js.*
-
-public actual val isStressTest: Boolean = false
-public actual val stressTestMultiplier: Int = 1
-public actual val stressTestMultiplierSqrt: Int = 1
-
-@Suppress("ACTUAL_WITHOUT_EXPECT", "ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE")
-public actual typealias TestResult = Promise<JsAny?>
-
-public actual val isNative = false
-
-@Suppress("NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS") // Counterpart for @Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
-public actual open class TestBase actual constructor() {
- public actual val isBoundByJsTestTimeout = true
- private var actionIndex = 0
- private var finished = false
- private var error: Throwable? = null
- private var lastTestPromise: Promise<JsAny?>? = null
-
- /**
- * Throws [IllegalStateException] like `error` in stdlib, but also ensures that the test will not
- * complete successfully even if this exception is consumed somewhere in the test.
- */
- @Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
- public actual fun error(message: Any, cause: Throwable? = null): Nothing {
- if (cause != null) println(cause)
- val exception = IllegalStateException(
- if (cause == null) message.toString() else "$message; caused by $cause")
- if (error == null) error = exception
- throw exception
- }
-
- private fun printError(message: String, cause: Throwable) {
- if (error == null) error = cause
- println("$message: $cause")
- println(cause)
- }
-
- /**
- * Asserts that this invocation is `index`-th in the execution sequence (counting from one).
- */
- public actual fun expect(index: Int) {
- val wasIndex = ++actionIndex
- check(index == wasIndex) { "Expecting action index $index but it is actually $wasIndex" }
- }
-
- /**
- * Asserts that this line is never executed.
- */
- public actual fun expectUnreached() {
- error("Should not be reached")
- }
-
- /**
- * Asserts that this it the last action in the test. It must be invoked by any test that used [expect].
- */
- public actual fun finish(index: Int) {
- expect(index)
- check(!finished) { "Should call 'finish(...)' at most once" }
- finished = true
- }
-
- /**
- * Asserts that [finish] was invoked
- */
- public actual fun ensureFinished() {
- require(finished) { "finish(...) should be caller prior to this check" }
- }
-
- public actual fun reset() {
- check(actionIndex == 0 || finished) { "Expecting that 'finish(...)' was invoked, but it was not" }
- actionIndex = 0
- finished = false
- }
-
- @Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
- public actual fun runTest(
- expected: ((Throwable) -> Boolean)? = null,
- unhandled: List<(Throwable) -> Boolean> = emptyList(),
- block: suspend CoroutineScope.() -> Unit
- ): TestResult {
- var exCount = 0
- var ex: Throwable? = null
- /*
- * This is an additional sanity check against `runTest` mis-usage on JS.
- * The only way to write an async test on JS is to return Promise from the test function.
- * _Just_ launching promise and returning `Unit` won't suffice as the underlying test framework
- * won't be able to detect an asynchronous failure in a timely manner.
- * We cannot detect such situations, but we can detect the most common erroneous pattern
- * in our code base, an attempt to use multiple `runTest` in the same `@Test` method,
- * which typically is a premise to the same error:
- * ```
- * @Test
- * fun incorrectTestForJs() { // <- promise is not returned
- * for (parameter in parameters) {
- * runTest {
- * runTestForParameter(parameter)
- * }
- * }
- * }
- * ```
- */
- if (lastTestPromise != null) {
- error("Attempt to run multiple asynchronous test within one @Test method")
- }
- val result = GlobalScope.promise(block = block, context = CoroutineExceptionHandler { _, e ->
- if (e is CancellationException) return@CoroutineExceptionHandler // are ignored
- exCount++
- when {
- exCount > unhandled.size ->
- printError("Too many unhandled exceptions $exCount, expected ${unhandled.size}, got: $e", e)
- !unhandled[exCount - 1](e) ->
- printError("Unhandled exception was unexpected: $e", e)
- }
- }).catch { jsE ->
- val e = jsE.toThrowableOrNull() ?: error("Unexpected non-Kotlin exception $jsE")
- ex = e
- if (expected != null) {
- if (!expected(e))
- error("Unexpected exception", e)
- } else
- throw e
-
- null
- }.finally {
- if (ex == null && expected != null) error("Exception was expected but none produced")
- if (exCount < unhandled.size)
- error("Too few unhandled exceptions $exCount, expected ${unhandled.size}")
- error?.let { throw it }
- check(actionIndex == 0 || finished) { "Expecting that 'finish(...)' was invoked, but it was not" }
- }
- lastTestPromise = result
- return result
- }
-}
-
-public actual val isJavaAndWindows: Boolean get() = false \ No newline at end of file
diff --git a/kotlinx-coroutines-debug/test/BlockHoundTest.kt b/kotlinx-coroutines-debug/test/BlockHoundTest.kt
index 5ec767c3..8faa3e88 100644
--- a/kotlinx-coroutines-debug/test/BlockHoundTest.kt
+++ b/kotlinx-coroutines-debug/test/BlockHoundTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.debug
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import org.junit.*
diff --git a/kotlinx-coroutines-debug/test/CoroutinesDumpTest.kt b/kotlinx-coroutines-debug/test/CoroutinesDumpTest.kt
index 350d9daf..ee56e4e0 100644
--- a/kotlinx-coroutines-debug/test/CoroutinesDumpTest.kt
+++ b/kotlinx-coroutines-debug/test/CoroutinesDumpTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.debug
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import kotlin.coroutines.*
diff --git a/kotlinx-coroutines-debug/test/DebugLeaksTest.kt b/kotlinx-coroutines-debug/test/DebugLeaksTest.kt
index fecd41da..7a59783c 100644
--- a/kotlinx-coroutines-debug/test/DebugLeaksTest.kt
+++ b/kotlinx-coroutines-debug/test/DebugLeaksTest.kt
@@ -1,3 +1,4 @@
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.debug.*
import kotlinx.coroutines.debug.internal.*
@@ -50,4 +51,4 @@ class DebugLeaksTest : DebugTestBase() {
private fun assertNoCapturedReference() {
FieldWalker.assertReachableCount(0, DebugProbesImpl, rootStatics = true) { it is Captured }
}
-} \ No newline at end of file
+}
diff --git a/kotlinx-coroutines-debug/test/DebugProbesTest.kt b/kotlinx-coroutines-debug/test/DebugProbesTest.kt
index 4bdcb410..ea269af1 100644
--- a/kotlinx-coroutines-debug/test/DebugProbesTest.kt
+++ b/kotlinx-coroutines-debug/test/DebugProbesTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.debug
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import java.util.concurrent.*
@@ -50,8 +51,8 @@ class DebugProbesTest : DebugTestBase() {
"\tat kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt)\n" +
"\tat kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt)\n" +
"\tat kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)\n" +
- "\tat kotlinx.coroutines.TestBase.runTest(TestBase.kt)\n" +
- "\tat kotlinx.coroutines.TestBase.runTest\$default(TestBase.kt)\n" +
+ "\tat kotlinx.coroutines.testing.TestBase.runTest(TestBase.kt)\n" +
+ "\tat kotlinx.coroutines.testing.TestBase.runTest\$default(TestBase.kt)\n" +
"\tat kotlinx.coroutines.debug.DebugProbesTest.testAsyncWithProbes(DebugProbesTest.kt)",
"Caused by: java.util.concurrent.ExecutionException\n" +
"\tat kotlinx.coroutines.debug.DebugProbesTest\$createDeferred\$1.invokeSuspend(DebugProbesTest.kt)\n" +
diff --git a/kotlinx-coroutines-debug/test/DebugTestBase.kt b/kotlinx-coroutines-debug/test/DebugTestBase.kt
index 55b91760..27792753 100644
--- a/kotlinx-coroutines-debug/test/DebugTestBase.kt
+++ b/kotlinx-coroutines-debug/test/DebugTestBase.kt
@@ -1,6 +1,7 @@
package kotlinx.coroutines.debug
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.debug.junit4.*
import org.junit.*
diff --git a/kotlinx-coroutines-debug/test/DumpCoroutineInfoAsJsonAndReferencesTest.kt b/kotlinx-coroutines-debug/test/DumpCoroutineInfoAsJsonAndReferencesTest.kt
index ba18977d..afd7a502 100644
--- a/kotlinx-coroutines-debug/test/DumpCoroutineInfoAsJsonAndReferencesTest.kt
+++ b/kotlinx-coroutines-debug/test/DumpCoroutineInfoAsJsonAndReferencesTest.kt
@@ -1,6 +1,7 @@
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
package kotlinx.coroutines.debug
+import kotlinx.coroutines.testing.*
import com.google.gson.*
import kotlinx.coroutines.*
import kotlinx.coroutines.debug.internal.*
@@ -67,12 +68,13 @@ class DumpCoroutineInfoAsJsonAndReferencesTest : DebugTestBase() {
val lastObservedFrames = dumpResult[2]
val coroutinesInfo = dumpResult[3]
- assertTrue(coroutinesInfoAsJsonString is String)
- assertTrue(lastObservedThreads is Array<*>)
- assertTrue(lastObservedFrames is Array<*>)
- assertTrue(coroutinesInfo is Array<*>)
+ assertIs<String>(coroutinesInfoAsJsonString)
+ assertIs<Array<*>>(lastObservedThreads)
+ assertIs<Array<*>>(lastObservedFrames)
+ assertIs<Array<*>>(coroutinesInfo)
- val coroutinesInfoFromJson = Gson().fromJson(coroutinesInfoAsJsonString, Array<CoroutineInfoFromJson>::class.java)
+ val coroutinesInfoFromJson =
+ Gson().fromJson(coroutinesInfoAsJsonString, Array<CoroutineInfoFromJson>::class.java)
val size = coroutinesInfo.size
assertTrue(size != 0)
@@ -83,7 +85,7 @@ class DumpCoroutineInfoAsJsonAndReferencesTest : DebugTestBase() {
for (i in 0 until size) {
val info = coroutinesInfo[i]
val infoFromJson = coroutinesInfoFromJson[i]
- assertTrue(info is DebugCoroutineInfo)
+ assertIs<DebugCoroutineInfo>(info)
assertEquals(info.lastObservedThread, lastObservedThreads[i])
assertEquals(info.lastObservedFrame, lastObservedFrames[i])
assertEquals(info.sequenceNumber, infoFromJson.sequenceNumber)
diff --git a/kotlinx-coroutines-debug/test/DumpWithoutCreationStackTraceTest.kt b/kotlinx-coroutines-debug/test/DumpWithoutCreationStackTraceTest.kt
index 601a180d..cb23972e 100644
--- a/kotlinx-coroutines-debug/test/DumpWithoutCreationStackTraceTest.kt
+++ b/kotlinx-coroutines-debug/test/DumpWithoutCreationStackTraceTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.debug
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import org.junit.Test
diff --git a/kotlinx-coroutines-debug/test/EnhanceStackTraceWithTreadDumpAsJsonTest.kt b/kotlinx-coroutines-debug/test/EnhanceStackTraceWithTreadDumpAsJsonTest.kt
index a8cc0ee1..72e61d6b 100644
--- a/kotlinx-coroutines-debug/test/EnhanceStackTraceWithTreadDumpAsJsonTest.kt
+++ b/kotlinx-coroutines-debug/test/EnhanceStackTraceWithTreadDumpAsJsonTest.kt
@@ -1,6 +1,7 @@
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
package kotlinx.coroutines.debug
+import kotlinx.coroutines.testing.*
import com.google.gson.*
import kotlinx.coroutines.*
import kotlinx.coroutines.debug.internal.*
diff --git a/kotlinx-coroutines-debug/test/LazyCoroutineTest.kt b/kotlinx-coroutines-debug/test/LazyCoroutineTest.kt
index bc41912b..8cf1f86a 100644
--- a/kotlinx-coroutines-debug/test/LazyCoroutineTest.kt
+++ b/kotlinx-coroutines-debug/test/LazyCoroutineTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.debug
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import kotlin.test.*
diff --git a/kotlinx-coroutines-debug/test/RunningThreadStackMergeTest.kt b/kotlinx-coroutines-debug/test/RunningThreadStackMergeTest.kt
index 175b93a9..2653de0f 100644
--- a/kotlinx-coroutines-debug/test/RunningThreadStackMergeTest.kt
+++ b/kotlinx-coroutines-debug/test/RunningThreadStackMergeTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.debug
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.debug.internal.*
import org.junit.Test
diff --git a/kotlinx-coroutines-debug/test/SanitizedProbesTest.kt b/kotlinx-coroutines-debug/test/SanitizedProbesTest.kt
index 745e6d98..114ddddd 100644
--- a/kotlinx-coroutines-debug/test/SanitizedProbesTest.kt
+++ b/kotlinx-coroutines-debug/test/SanitizedProbesTest.kt
@@ -1,6 +1,7 @@
@file:Suppress("PackageDirectoryMismatch")
package definitely.not.kotlinx.coroutines
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.debug.*
import kotlinx.coroutines.selects.*
@@ -29,7 +30,7 @@ class SanitizedProbesTest : DebugTestBase() {
"\tat _COROUTINE._CREATION._(CoroutineDebugging.kt)\n" +
"\tat kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt.createCoroutineUnintercepted(IntrinsicsJvm.kt:116)\n" +
"\tat kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:23)\n" +
- "\tat kotlinx.coroutines.TestBase.runTest\$default(TestBase.kt:141)\n" +
+ "\tat kotlinx.coroutines.testing.TestBase.runTest\$default(TestBase.kt:141)\n" +
"\tat definitely.not.kotlinx.coroutines.SanitizedProbesTest.testRecoveredStackTrace(SanitizedProbesTest.kt:33)",
"Caused by: java.util.concurrent.ExecutionException\n" +
"\tat definitely.not.kotlinx.coroutines.SanitizedProbesTest\$createDeferredNested\$1.invokeSuspend(SanitizedProbesTest.kt:57)\n" +
@@ -49,7 +50,7 @@ class SanitizedProbesTest : DebugTestBase() {
"\tat _COROUTINE._CREATION._(CoroutineDebugging.kt)\n" +
"\tat kotlin.coroutines.intrinsics.IntrinsicsKt__IntrinsicsJvmKt.createCoroutineUnintercepted(IntrinsicsJvm.kt:116)\n" +
"\tat kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:23)\n" +
- "\tat kotlinx.coroutines.TestBase.runTest\$default(TestBase.kt:141)\n" +
+ "\tat kotlinx.coroutines.testing.TestBase.runTest\$default(TestBase.kt:141)\n" +
"\tat definitely.not.kotlinx.coroutines.SanitizedProbesTest.testCoroutinesDump(SanitizedProbesTest.kt:56)",
"Coroutine \"coroutine#4\":DeferredCoroutine{Active}@75c072cb, state: SUSPENDED\n" +
@@ -64,7 +65,7 @@ class SanitizedProbesTest : DebugTestBase() {
"\tat definitely.not.kotlinx.coroutines.SanitizedProbesTest\$testCoroutinesDump\$1.invokeSuspend(SanitizedProbesTest.kt:57)\n" +
"\tat kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:32)\n" +
"\tat kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:237)\n" +
- "\tat kotlinx.coroutines.TestBase.runTest\$default(TestBase.kt:141)\n" +
+ "\tat kotlinx.coroutines.testing.TestBase.runTest\$default(TestBase.kt:141)\n" +
"\tat definitely.not.kotlinx.coroutines.SanitizedProbesTest.testCoroutinesDump(SanitizedProbesTest.kt:56)"
)
deferred.cancelAndJoin()
@@ -93,7 +94,7 @@ class SanitizedProbesTest : DebugTestBase() {
"\tat definitely.not.kotlinx.coroutines.SanitizedProbesTest\$testSelectBuilder\$1.invokeSuspend(SanitizedProbesTest.kt:89)\n" +
"\tat kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:32)\n" +
"\tat kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:233)\n" +
- "\tat kotlinx.coroutines.TestBase.runTest\$default(TestBase.kt:154)\n" +
+ "\tat kotlinx.coroutines.testing.TestBase.runTest\$default(TestBase.kt:154)\n" +
"\tat definitely.not.kotlinx.coroutines.SanitizedProbesTest.testSelectBuilder(SanitizedProbesTest.kt:88)")
finish(4)
selector.cancelAndJoin()
diff --git a/kotlinx-coroutines-debug/test/ScopedBuildersTest.kt b/kotlinx-coroutines-debug/test/ScopedBuildersTest.kt
index 3707c084..00e7fcca 100644
--- a/kotlinx-coroutines-debug/test/ScopedBuildersTest.kt
+++ b/kotlinx-coroutines-debug/test/ScopedBuildersTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.debug
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import kotlin.coroutines.*
diff --git a/kotlinx-coroutines-debug/test/StandardBuildersDebugTest.kt b/kotlinx-coroutines-debug/test/StandardBuildersDebugTest.kt
index a9b4c903..1a3076eb 100644
--- a/kotlinx-coroutines-debug/test/StandardBuildersDebugTest.kt
+++ b/kotlinx-coroutines-debug/test/StandardBuildersDebugTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.debug
+import kotlinx.coroutines.testing.*
import org.junit.Test
import kotlin.test.*
diff --git a/kotlinx-coroutines-debug/test/StartModeProbesTest.kt b/kotlinx-coroutines-debug/test/StartModeProbesTest.kt
index 2526da88..035873a6 100644
--- a/kotlinx-coroutines-debug/test/StartModeProbesTest.kt
+++ b/kotlinx-coroutines-debug/test/StartModeProbesTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.debug
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import org.junit.Test
diff --git a/kotlinx-coroutines-debug/test/ToStringTest.kt b/kotlinx-coroutines-debug/test/ToStringTest.kt
index b336930c..e4330b78 100644
--- a/kotlinx-coroutines-debug/test/ToStringTest.kt
+++ b/kotlinx-coroutines-debug/test/ToStringTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.debug
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import org.junit.*
diff --git a/kotlinx-coroutines-debug/test/WithContextUndispatchedTest.kt b/kotlinx-coroutines-debug/test/WithContextUndispatchedTest.kt
index bf0c5ca5..47274d86 100644
--- a/kotlinx-coroutines-debug/test/WithContextUndispatchedTest.kt
+++ b/kotlinx-coroutines-debug/test/WithContextUndispatchedTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.debug
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import org.junit.*
diff --git a/kotlinx-coroutines-debug/test/junit4/CoroutinesTimeoutDisabledTracesTest.kt b/kotlinx-coroutines-debug/test/junit4/CoroutinesTimeoutDisabledTracesTest.kt
index 4e02bc5d..8a243139 100644
--- a/kotlinx-coroutines-debug/test/junit4/CoroutinesTimeoutDisabledTracesTest.kt
+++ b/kotlinx-coroutines-debug/test/junit4/CoroutinesTimeoutDisabledTracesTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.debug.junit4
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import org.junit.runners.model.*
diff --git a/kotlinx-coroutines-debug/test/junit4/CoroutinesTimeoutEagerTest.kt b/kotlinx-coroutines-debug/test/junit4/CoroutinesTimeoutEagerTest.kt
index b02f8a2c..458d0eed 100644
--- a/kotlinx-coroutines-debug/test/junit4/CoroutinesTimeoutEagerTest.kt
+++ b/kotlinx-coroutines-debug/test/junit4/CoroutinesTimeoutEagerTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.debug.junit4
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import org.junit.runners.model.*
diff --git a/kotlinx-coroutines-debug/test/junit4/CoroutinesTimeoutTest.kt b/kotlinx-coroutines-debug/test/junit4/CoroutinesTimeoutTest.kt
index 3d5a4cc7..9a429d5b 100644
--- a/kotlinx-coroutines-debug/test/junit4/CoroutinesTimeoutTest.kt
+++ b/kotlinx-coroutines-debug/test/junit4/CoroutinesTimeoutTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.debug.junit4
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import org.junit.runners.model.*
diff --git a/kotlinx-coroutines-debug/test/junit5/CoroutinesTimeoutInheritanceTest.kt b/kotlinx-coroutines-debug/test/junit5/CoroutinesTimeoutInheritanceTest.kt
index 1e03d193..4aa90bb7 100644
--- a/kotlinx-coroutines-debug/test/junit5/CoroutinesTimeoutInheritanceTest.kt
+++ b/kotlinx-coroutines-debug/test/junit5/CoroutinesTimeoutInheritanceTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.debug.junit5
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.jupiter.api.*
diff --git a/kotlinx-coroutines-test/build.gradle.kts b/kotlinx-coroutines-test/build.gradle.kts
index 006f1d3e..2c1d0438 100644
--- a/kotlinx-coroutines-test/build.gradle.kts
+++ b/kotlinx-coroutines-test/build.gradle.kts
@@ -1,12 +1,6 @@
import org.jetbrains.kotlin.gradle.plugin.mpp.*
import org.jetbrains.kotlin.gradle.targets.js.dsl.*
-val experimentalAnnotations = listOf(
- "kotlin.Experimental",
- "kotlinx.coroutines.ExperimentalCoroutinesApi",
- "kotlinx.coroutines.InternalCoroutinesApi"
-)
-
kotlin {
targets.withType(KotlinNativeTargetWithTests::class.java).configureEach {
binaries.getTest("DEBUG").apply {
diff --git a/kotlinx-coroutines-test/common/test/Helpers.kt b/kotlinx-coroutines-test/common/test/Helpers.kt
index 8d8b91df..8679739d 100644
--- a/kotlinx-coroutines-test/common/test/Helpers.kt
+++ b/kotlinx-coroutines-test/common/test/Helpers.kt
@@ -1,35 +1,9 @@
package kotlinx.coroutines.test
-import kotlinx.atomicfu.*
-import kotlin.test.*
-import kotlin.time.*
-import kotlin.time.Duration.Companion.seconds
-
-/**
- * The number of milliseconds that is sure not to pass [assertRunsFast].
- */
-const val SLOW = 100_000L
-
-/**
- * Asserts that a block completed within [timeout].
- */
-@OptIn(ExperimentalTime::class)
-inline fun <T> assertRunsFast(timeout: Duration, block: () -> T): T {
- val result: T
- val elapsed = TimeSource.Monotonic.measureTime { result = block() }
- assertTrue("Should complete in $timeout, but took $elapsed") { elapsed < timeout }
- return result
-}
-
-/**
- * Asserts that a block completed within two seconds.
- */
-inline fun <T> assertRunsFast(block: () -> T): T = assertRunsFast(2.seconds, block)
-
/**
* Runs [test], and then invokes [block], passing to it the lambda that functionally behaves
* the same way [test] does.
-*/
+ */
fun testResultMap(block: (() -> Unit) -> Unit, test: () -> TestResult): TestResult = testResultChain(
block = test,
after = {
@@ -55,40 +29,3 @@ fun testResultChain(vararg chained: (Result<Unit>) -> TestResult, initialResult:
testResultChain(*chained.drop(1).toTypedArray(), initialResult = it)
}
}
-
-class TestException(message: String? = null): Exception(message)
-
-/**
- * A class inheriting from which allows to check the execution order inside tests.
- *
- * @see TestBase
- */
-open class OrderedExecutionTestBase {
- private val actionIndex = atomic(0)
- private val finished = atomic(false)
-
- /** Expect the next action to be [index] in order. */
- protected fun expect(index: Int) {
- val wasIndex = actionIndex.incrementAndGet()
- check(index == wasIndex) { "Expecting action index $index but it is actually $wasIndex" }
- }
-
- /** Expect this action to be final, with the given [index]. */
- protected fun finish(index: Int) {
- expect(index)
- check(!finished.getAndSet(true)) { "Should call 'finish(...)' at most once" }
- }
-
- @AfterTest
- fun ensureFinishCalls() {
- assertTrue(finished.value || actionIndex.value == 0, "Expected `finish` to be called")
- }
-}
-
-internal fun <T> T.void() { }
-
-@OptionalExpectation
-expect annotation class NoJs()
-
-@OptionalExpectation
-expect annotation class NoNative()
diff --git a/kotlinx-coroutines-test/common/test/RunTestTest.kt b/kotlinx-coroutines-test/common/test/RunTestTest.kt
index ca3114c6..799bcae2 100644
--- a/kotlinx-coroutines-test/common/test/RunTestTest.kt
+++ b/kotlinx-coroutines-test/common/test/RunTestTest.kt
@@ -3,8 +3,10 @@ package kotlinx.coroutines.test
import kotlinx.coroutines.*
import kotlinx.coroutines.internal.*
import kotlinx.coroutines.flow.*
+import kotlinx.coroutines.testing.*
import kotlin.coroutines.*
import kotlin.test.*
+import kotlin.test.assertFailsWith
import kotlin.time.*
import kotlin.time.Duration.Companion.milliseconds
diff --git a/kotlinx-coroutines-test/common/test/StandardTestDispatcherTest.kt b/kotlinx-coroutines-test/common/test/StandardTestDispatcherTest.kt
index 3001f2bc..c0334c89 100644
--- a/kotlinx-coroutines-test/common/test/StandardTestDispatcherTest.kt
+++ b/kotlinx-coroutines-test/common/test/StandardTestDispatcherTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.test
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-test/common/test/TestCoroutineSchedulerTest.kt b/kotlinx-coroutines-test/common/test/TestCoroutineSchedulerTest.kt
index e0f8c00e..ba539696 100644
--- a/kotlinx-coroutines-test/common/test/TestCoroutineSchedulerTest.kt
+++ b/kotlinx-coroutines-test/common/test/TestCoroutineSchedulerTest.kt
@@ -1,7 +1,9 @@
package kotlinx.coroutines.test
import kotlinx.coroutines.*
+import kotlinx.coroutines.testing.*
import kotlin.test.*
+import kotlin.test.assertFailsWith
import kotlin.time.*
import kotlin.time.Duration.Companion.seconds
import kotlin.time.Duration.Companion.milliseconds
diff --git a/kotlinx-coroutines-test/common/test/TestDispatchersTest.kt b/kotlinx-coroutines-test/common/test/TestDispatchersTest.kt
index f442814c..614c46ae 100644
--- a/kotlinx-coroutines-test/common/test/TestDispatchersTest.kt
+++ b/kotlinx-coroutines-test/common/test/TestDispatchersTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.test
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.test.internal.*
import kotlin.coroutines.*
diff --git a/kotlinx-coroutines-test/common/test/TestScopeTest.kt b/kotlinx-coroutines-test/common/test/TestScopeTest.kt
index 8dde491a..ca98c6d2 100644
--- a/kotlinx-coroutines-test/common/test/TestScopeTest.kt
+++ b/kotlinx-coroutines-test/common/test/TestScopeTest.kt
@@ -3,8 +3,10 @@ package kotlinx.coroutines.test
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.flow.*
+import kotlinx.coroutines.testing.*
import kotlin.coroutines.*
import kotlin.test.*
+import kotlin.test.assertFailsWith
import kotlin.time.Duration.Companion.milliseconds
class TestScopeTest {
diff --git a/kotlinx-coroutines-test/js/test/Helpers.kt b/kotlinx-coroutines-test/js/test/Helpers.kt
index b230c2b3..9464f8c7 100644
--- a/kotlinx-coroutines-test/js/test/Helpers.kt
+++ b/kotlinx-coroutines-test/js/test/Helpers.kt
@@ -1,7 +1,5 @@
package kotlinx.coroutines.test
-import kotlin.test.*
-
actual fun testResultChain(block: () -> TestResult, after: (Result<Unit>) -> TestResult): TestResult =
block().then(
{
@@ -9,5 +7,3 @@ actual fun testResultChain(block: () -> TestResult, after: (Result<Unit>) -> Tes
}, {
after(Result.failure(it))
})
-
-actual typealias NoJs = Ignore
diff --git a/kotlinx-coroutines-test/jvm/test/MemoryLeakTest.kt b/kotlinx-coroutines-test/jvm/test/MemoryLeakTest.kt
index fb0c062c..218d8aaa 100644
--- a/kotlinx-coroutines-test/jvm/test/MemoryLeakTest.kt
+++ b/kotlinx-coroutines-test/jvm/test/MemoryLeakTest.kt
@@ -1,5 +1,6 @@
import kotlinx.coroutines.*
import kotlinx.coroutines.test.*
+import kotlinx.coroutines.testing.*
import kotlin.test.*
class MemoryLeakTest {
diff --git a/kotlinx-coroutines-test/jvm/test/RunTestStressTest.kt b/kotlinx-coroutines-test/jvm/test/RunTestStressTest.kt
index 7bd9b0e0..d6469c54 100644
--- a/kotlinx-coroutines-test/jvm/test/RunTestStressTest.kt
+++ b/kotlinx-coroutines-test/jvm/test/RunTestStressTest.kt
@@ -1,6 +1,7 @@
package kotlinx.coroutines.test
import kotlinx.coroutines.*
+import kotlinx.coroutines.testing.*
import kotlin.concurrent.*
import kotlin.coroutines.*
import kotlin.test.*
@@ -20,4 +21,4 @@ class RunTestStressTest {
}
}
}
-} \ No newline at end of file
+}
diff --git a/kotlinx-coroutines-test/jvm/test/UncaughtExceptionsTest.kt b/kotlinx-coroutines-test/jvm/test/UncaughtExceptionsTest.kt
index 9f0f657a..57893b86 100644
--- a/kotlinx-coroutines-test/jvm/test/UncaughtExceptionsTest.kt
+++ b/kotlinx-coroutines-test/jvm/test/UncaughtExceptionsTest.kt
@@ -1,5 +1,7 @@
package kotlinx.coroutines.test
+import kotlinx.coroutines.*
+import kotlinx.coroutines.testing.*
import org.junit.Test
import kotlin.test.*
diff --git a/kotlinx-coroutines-test/jvm/test/migration/RunBlockingTestOnTestScopeTest.kt b/kotlinx-coroutines-test/jvm/test/migration/RunBlockingTestOnTestScopeTest.kt
index fe9be521..aec937d1 100644
--- a/kotlinx-coroutines-test/jvm/test/migration/RunBlockingTestOnTestScopeTest.kt
+++ b/kotlinx-coroutines-test/jvm/test/migration/RunBlockingTestOnTestScopeTest.kt
@@ -3,7 +3,9 @@ package kotlinx.coroutines.test
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.flow.*
+import kotlinx.coroutines.testing.*
import kotlin.test.*
+import kotlin.test.assertFailsWith
/** Copy of [RunTestTest], but for [runBlockingTestOnTestScope], where applicable. */
@Suppress("DEPRECATION")
diff --git a/kotlinx-coroutines-test/jvm/test/migration/RunTestLegacyScopeTest.kt b/kotlinx-coroutines-test/jvm/test/migration/RunTestLegacyScopeTest.kt
index 9d356913..caae1a5d 100644
--- a/kotlinx-coroutines-test/jvm/test/migration/RunTestLegacyScopeTest.kt
+++ b/kotlinx-coroutines-test/jvm/test/migration/RunTestLegacyScopeTest.kt
@@ -3,8 +3,10 @@ package kotlinx.coroutines.test
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.internal.*
+import kotlinx.coroutines.testing.*
import kotlin.coroutines.*
import kotlin.test.*
+import kotlin.test.assertFailsWith
/** Copy of [RunTestTest], but for [TestCoroutineScope] */
@Suppress("DEPRECATION")
diff --git a/kotlinx-coroutines-test/jvm/test/migration/TestBuildersTest.kt b/kotlinx-coroutines-test/jvm/test/migration/TestBuildersTest.kt
index d03fc9cf..d58d0f5a 100644
--- a/kotlinx-coroutines-test/jvm/test/migration/TestBuildersTest.kt
+++ b/kotlinx-coroutines-test/jvm/test/migration/TestBuildersTest.kt
@@ -1,6 +1,7 @@
package kotlinx.coroutines.test
import kotlinx.coroutines.*
+import kotlinx.coroutines.testing.*
import kotlin.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-test/jvm/test/migration/TestCoroutineDispatcherOrderTest.kt b/kotlinx-coroutines-test/jvm/test/migration/TestCoroutineDispatcherOrderTest.kt
index 03470f30..93792b5a 100644
--- a/kotlinx-coroutines-test/jvm/test/migration/TestCoroutineDispatcherOrderTest.kt
+++ b/kotlinx-coroutines-test/jvm/test/migration/TestCoroutineDispatcherOrderTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.test
+import kotlinx.coroutines.testing.*
import kotlinx.atomicfu.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-test/jvm/test/migration/TestCoroutineScopeTest.kt b/kotlinx-coroutines-test/jvm/test/migration/TestCoroutineScopeTest.kt
index b260c98a..c201623c 100644
--- a/kotlinx-coroutines-test/jvm/test/migration/TestCoroutineScopeTest.kt
+++ b/kotlinx-coroutines-test/jvm/test/migration/TestCoroutineScopeTest.kt
@@ -3,8 +3,10 @@
package kotlinx.coroutines.test
import kotlinx.coroutines.*
+import kotlinx.coroutines.testing.*
import kotlin.coroutines.*
import kotlin.test.*
+import kotlin.test.assertFailsWith
class TestCoroutineScopeTest {
/** Tests failing to create a [TestCoroutineScope] with incorrect contexts. */
@@ -211,4 +213,4 @@ class TestCoroutineScopeTest {
StandardTestDispatcher() + TestCoroutineScheduler(), // the dispatcher is not linked to the scheduler
)
}
-} \ No newline at end of file
+}
diff --git a/kotlinx-coroutines-test/jvm/test/migration/TestRunBlockingOrderTest.kt b/kotlinx-coroutines-test/jvm/test/migration/TestRunBlockingOrderTest.kt
index 95ef3eb8..a8315fc5 100644
--- a/kotlinx-coroutines-test/jvm/test/migration/TestRunBlockingOrderTest.kt
+++ b/kotlinx-coroutines-test/jvm/test/migration/TestRunBlockingOrderTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.test
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlin.test.*
diff --git a/kotlinx-coroutines-test/jvm/test/migration/TestRunBlockingTest.kt b/kotlinx-coroutines-test/jvm/test/migration/TestRunBlockingTest.kt
index 6633a758..f7d420d2 100644
--- a/kotlinx-coroutines-test/jvm/test/migration/TestRunBlockingTest.kt
+++ b/kotlinx-coroutines-test/jvm/test/migration/TestRunBlockingTest.kt
@@ -1,7 +1,9 @@
package kotlinx.coroutines.test
import kotlinx.coroutines.*
+import kotlinx.coroutines.testing.*
import kotlin.test.*
+import kotlin.test.assertFailsWith
@Suppress("DEPRECATION", "DEPRECATION_ERROR")
class TestRunBlockingTest {
diff --git a/kotlinx-coroutines-test/native/test/Helpers.kt b/kotlinx-coroutines-test/native/test/Helpers.kt
index 19de989e..ed3afa39 100644
--- a/kotlinx-coroutines-test/native/test/Helpers.kt
+++ b/kotlinx-coroutines-test/native/test/Helpers.kt
@@ -1,7 +1,5 @@
package kotlinx.coroutines.test
-import kotlin.test.*
-
actual fun testResultChain(block: () -> TestResult, after: (Result<Unit>) -> TestResult): TestResult {
try {
block()
@@ -10,5 +8,3 @@ actual fun testResultChain(block: () -> TestResult, after: (Result<Unit>) -> Tes
after(Result.failure(e))
}
}
-
-actual typealias NoNative = Ignore
diff --git a/kotlinx-coroutines-test/wasmJs/test/Helpers.kt b/kotlinx-coroutines-test/wasmJs/test/Helpers.kt
index 5c025091..a394c1f1 100644
--- a/kotlinx-coroutines-test/wasmJs/test/Helpers.kt
+++ b/kotlinx-coroutines-test/wasmJs/test/Helpers.kt
@@ -1,7 +1,5 @@
package kotlinx.coroutines.test
-import kotlin.test.*
-
actual fun testResultChain(block: () -> TestResult, after: (Result<Unit>) -> TestResult): TestResult =
block().then(
{
@@ -11,5 +9,3 @@ actual fun testResultChain(block: () -> TestResult, after: (Result<Unit>) -> Tes
after(Result.failure(it.toThrowableOrNull() ?: Throwable("Unexpected non-Kotlin exception $it")))
null
})
-
-actual typealias NoJs = Ignore \ No newline at end of file
diff --git a/reactive/knit.test.include b/reactive/knit.test.include
index 2de70623..8b62dcd4 100644
--- a/reactive/knit.test.include
+++ b/reactive/knit.test.include
@@ -1,6 +1,7 @@
// This file was automatically generated from ${file.name} by Knit tool. Do not edit.
package ${test.package}
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.guide.test.*
import org.junit.Test
diff --git a/reactive/kotlinx-coroutines-jdk9/test/AwaitTest.kt b/reactive/kotlinx-coroutines-jdk9/test/AwaitTest.kt
index 8fb93ed5..4b0b77c8 100644
--- a/reactive/kotlinx-coroutines-jdk9/test/AwaitTest.kt
+++ b/reactive/kotlinx-coroutines-jdk9/test/AwaitTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.jdk9
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import java.util.concurrent.Flow as JFlow
diff --git a/reactive/kotlinx-coroutines-jdk9/test/FlowAsPublisherTest.kt b/reactive/kotlinx-coroutines-jdk9/test/FlowAsPublisherTest.kt
index 9e702fdd..b09324cf 100644
--- a/reactive/kotlinx-coroutines-jdk9/test/FlowAsPublisherTest.kt
+++ b/reactive/kotlinx-coroutines-jdk9/test/FlowAsPublisherTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.jdk9
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import org.junit.Test
@@ -36,7 +37,7 @@ class FlowAsPublisherTest : TestBase() {
}
override fun onError(t: Throwable?) {
- assertTrue(t is TestException)
+ assertIs<TestException>(t)
expect(4)
}
})
diff --git a/reactive/kotlinx-coroutines-jdk9/test/IntegrationTest.kt b/reactive/kotlinx-coroutines-jdk9/test/IntegrationTest.kt
index 81e3f10d..400d11bb 100644
--- a/reactive/kotlinx-coroutines-jdk9/test/IntegrationTest.kt
+++ b/reactive/kotlinx-coroutines-jdk9/test/IntegrationTest.kt
@@ -1,12 +1,12 @@
package kotlinx.coroutines.jdk9
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
-import kotlinx.coroutines.exceptions.*
import org.junit.Test
import kotlinx.coroutines.flow.flowOn
+import kotlinx.coroutines.testing.exceptions.*
import org.junit.runner.*
import org.junit.runners.*
-import kotlin.contracts.*
import java.util.concurrent.Flow as JFlow
import kotlin.coroutines.*
import kotlin.test.*
@@ -129,18 +129,3 @@ class IntegrationTest(
}
-@OptIn(ExperimentalContracts::class)
-internal suspend inline fun <reified E: Throwable> assertCallsExceptionHandlerWith(
- crossinline operation: suspend (CoroutineExceptionHandler) -> Unit): E {
- contract {
- callsInPlace(operation, InvocationKind.EXACTLY_ONCE)
- }
- val handler = CapturingHandler()
- return withContext(handler) {
- operation(handler)
- handler.getException().let {
- assertTrue(it is E, it.toString())
- it
- }
- }
-}
diff --git a/reactive/kotlinx-coroutines-jdk9/test/PublishTest.kt b/reactive/kotlinx-coroutines-jdk9/test/PublishTest.kt
index aa4f6206..595c6788 100644
--- a/reactive/kotlinx-coroutines-jdk9/test/PublishTest.kt
+++ b/reactive/kotlinx-coroutines-jdk9/test/PublishTest.kt
@@ -1,7 +1,9 @@
package kotlinx.coroutines.jdk9
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
+import kotlinx.coroutines.testing.exceptions.*
import org.junit.Test
import java.util.concurrent.Flow as JFlow
import kotlin.test.*
@@ -68,7 +70,7 @@ class PublishTest : TestBase() {
override fun onComplete() { expectUnreached() }
override fun onError(t: Throwable) {
expect(6)
- assertTrue(t is RuntimeException)
+ assertIs<RuntimeException>(t)
assertEquals("OK", t.message)
}
})
@@ -82,7 +84,7 @@ class PublishTest : TestBase() {
expect(1)
val eh = CoroutineExceptionHandler { _, t ->
- assertTrue(t is RuntimeException)
+ assertIs<RuntimeException>(t)
expect(6)
}
val publisher = flowPublish<Unit>(Dispatchers.Unconfined + eh) {
@@ -195,29 +197,34 @@ class PublishTest : TestBase() {
}
}
expect(2)
- publisher.subscribe(object: JFlow.Subscriber<Int> {
+ publisher.subscribe(object : JFlow.Subscriber<Int> {
override fun onSubscribe(s: JFlow.Subscription) {
expect(3)
s.request(Long.MAX_VALUE)
}
+
override fun onNext(t: Int) {
expect(6)
assertEquals(1, t)
job!!.cancel()
throw TestException()
}
+
override fun onError(t: Throwable?) {
/* Correct changes to the implementation could lead to us entering or not entering this method, but
it only matters that if we do, it is the "correct" exception that was validly used to cancel the
coroutine that gets passed here and not `TestException`. */
- assertTrue(t is CancellationException)
+ assertIs<CancellationException>(t)
+ }
+
+ override fun onComplete() {
+ expectUnreached()
}
- override fun onComplete() { expectUnreached() }
})
expect(5)
val result: ChannelResult<Unit> = producerScope!!.trySend(1)
val e = result.exceptionOrNull()!!
- assertTrue(e is CancellationException, "The actual error: $e")
+ assertIs<CancellationException>(e, "The actual error: $e")
assertTrue(producerScope!!.isClosedForSend)
assertTrue(result.isFailure)
}
diff --git a/reactive/kotlinx-coroutines-jdk9/test/PublisherAsFlowTest.kt b/reactive/kotlinx-coroutines-jdk9/test/PublisherAsFlowTest.kt
index 12084acc..ae1708b9 100644
--- a/reactive/kotlinx-coroutines-jdk9/test/PublisherAsFlowTest.kt
+++ b/reactive/kotlinx-coroutines-jdk9/test/PublisherAsFlowTest.kt
@@ -1,8 +1,10 @@
package kotlinx.coroutines.jdk9
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.flow.*
+import kotlinx.coroutines.testing.flow.*
import kotlin.test.*
class PublisherAsFlowTest : TestBase() {
diff --git a/reactive/kotlinx-coroutines-jdk9/test/PublisherBackpressureTest.kt b/reactive/kotlinx-coroutines-jdk9/test/PublisherBackpressureTest.kt
index 303c8298..b7bbcbd2 100644
--- a/reactive/kotlinx-coroutines-jdk9/test/PublisherBackpressureTest.kt
+++ b/reactive/kotlinx-coroutines-jdk9/test/PublisherBackpressureTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.jdk9
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import java.util.concurrent.Flow as JFlow
diff --git a/reactive/kotlinx-coroutines-jdk9/test/PublisherCollectTest.kt b/reactive/kotlinx-coroutines-jdk9/test/PublisherCollectTest.kt
index 9288d7c5..aa2b6793 100644
--- a/reactive/kotlinx-coroutines-jdk9/test/PublisherCollectTest.kt
+++ b/reactive/kotlinx-coroutines-jdk9/test/PublisherCollectTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.jdk9
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.reactive.*
import org.junit.Test
diff --git a/reactive/kotlinx-coroutines-jdk9/test/PublisherCompletionStressTest.kt b/reactive/kotlinx-coroutines-jdk9/test/PublisherCompletionStressTest.kt
index b557020b..abacdec3 100644
--- a/reactive/kotlinx-coroutines-jdk9/test/PublisherCompletionStressTest.kt
+++ b/reactive/kotlinx-coroutines-jdk9/test/PublisherCompletionStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.jdk9
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import java.util.*
diff --git a/reactive/kotlinx-coroutines-jdk9/test/PublisherMultiTest.kt b/reactive/kotlinx-coroutines-jdk9/test/PublisherMultiTest.kt
index 020f593d..90fa5dda 100644
--- a/reactive/kotlinx-coroutines-jdk9/test/PublisherMultiTest.kt
+++ b/reactive/kotlinx-coroutines-jdk9/test/PublisherMultiTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.jdk9
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import kotlin.test.*
diff --git a/reactive/kotlinx-coroutines-reactive/test/AwaitCancellationStressTest.kt b/reactive/kotlinx-coroutines-reactive/test/AwaitCancellationStressTest.kt
index 50d570a0..03676c70 100644
--- a/reactive/kotlinx-coroutines-reactive/test/AwaitCancellationStressTest.kt
+++ b/reactive/kotlinx-coroutines-reactive/test/AwaitCancellationStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactive
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import org.reactivestreams.*
diff --git a/reactive/kotlinx-coroutines-reactive/test/AwaitTest.kt b/reactive/kotlinx-coroutines-reactive/test/AwaitTest.kt
index 3039dd77..22772048 100644
--- a/reactive/kotlinx-coroutines-reactive/test/AwaitTest.kt
+++ b/reactive/kotlinx-coroutines-reactive/test/AwaitTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactive
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import org.reactivestreams.*
diff --git a/reactive/kotlinx-coroutines-reactive/test/CancelledParentAttachTest.kt b/reactive/kotlinx-coroutines-reactive/test/CancelledParentAttachTest.kt
index 19db6673..05bb8789 100644
--- a/reactive/kotlinx-coroutines-reactive/test/CancelledParentAttachTest.kt
+++ b/reactive/kotlinx-coroutines-reactive/test/CancelledParentAttachTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactive
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import org.junit.*
diff --git a/reactive/kotlinx-coroutines-reactive/test/FlowAsPublisherTest.kt b/reactive/kotlinx-coroutines-reactive/test/FlowAsPublisherTest.kt
index 2a393ba2..18615e2b 100644
--- a/reactive/kotlinx-coroutines-reactive/test/FlowAsPublisherTest.kt
+++ b/reactive/kotlinx-coroutines-reactive/test/FlowAsPublisherTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactive
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.flow.*
@@ -37,7 +38,7 @@ class FlowAsPublisherTest : TestBase() {
}
override fun onError(t: Throwable?) {
- assertTrue(t is TestException)
+ assertIs<TestException>(t)
expect(4)
}
})
diff --git a/reactive/kotlinx-coroutines-reactive/test/IntegrationTest.kt b/reactive/kotlinx-coroutines-reactive/test/IntegrationTest.kt
index 29bbd7d3..51e9562a 100644
--- a/reactive/kotlinx-coroutines-reactive/test/IntegrationTest.kt
+++ b/reactive/kotlinx-coroutines-reactive/test/IntegrationTest.kt
@@ -1,14 +1,14 @@
package kotlinx.coroutines.reactive
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
-import kotlinx.coroutines.exceptions.*
+import kotlinx.coroutines.testing.exceptions.*
import org.junit.Test
import org.junit.runner.*
import org.junit.runners.*
import org.reactivestreams.*
import java.lang.IllegalStateException
import java.lang.RuntimeException
-import kotlin.contracts.*
import kotlin.coroutines.*
import kotlin.test.*
@@ -223,18 +223,3 @@ class IntegrationTest(
}
-@OptIn(ExperimentalContracts::class)
-internal suspend inline fun <reified E: Throwable> assertCallsExceptionHandlerWith(
- crossinline operation: suspend (CoroutineExceptionHandler) -> Unit): E {
- contract {
- callsInPlace(operation, InvocationKind.EXACTLY_ONCE)
- }
- val handler = CapturingHandler()
- return withContext(handler) {
- operation(handler)
- handler.getException().let {
- assertTrue(it is E, it.toString())
- it
- }
- }
-}
diff --git a/reactive/kotlinx-coroutines-reactive/test/PublishTest.kt b/reactive/kotlinx-coroutines-reactive/test/PublishTest.kt
index 15e22aa2..df01e471 100644
--- a/reactive/kotlinx-coroutines-reactive/test/PublishTest.kt
+++ b/reactive/kotlinx-coroutines-reactive/test/PublishTest.kt
@@ -1,10 +1,12 @@
package kotlinx.coroutines.reactive
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.sync.*
+import kotlinx.coroutines.testing.exceptions.*
import org.junit.Test
import org.reactivestreams.*
import java.util.concurrent.*
@@ -72,7 +74,7 @@ class PublishTest : TestBase() {
override fun onComplete() { expectUnreached() }
override fun onError(t: Throwable) {
expect(6)
- assertTrue(t is RuntimeException)
+ assertIs<RuntimeException>(t)
assertEquals("OK", t.message)
}
})
@@ -86,7 +88,7 @@ class PublishTest : TestBase() {
expect(1)
val eh = CoroutineExceptionHandler { _, t ->
- assertTrue(t is RuntimeException)
+ assertIs<RuntimeException>(t)
expect(6)
}
val publisher = publish<Unit>(Dispatchers.Unconfined + eh) {
@@ -199,29 +201,34 @@ class PublishTest : TestBase() {
}
}
expect(2)
- publisher.subscribe(object: Subscriber<Int> {
+ publisher.subscribe(object : Subscriber<Int> {
override fun onSubscribe(s: Subscription) {
expect(3)
s.request(Long.MAX_VALUE)
}
+
override fun onNext(t: Int) {
expect(6)
assertEquals(1, t)
job!!.cancel()
throw TestException()
}
+
override fun onError(t: Throwable?) {
/* Correct changes to the implementation could lead to us entering or not entering this method, but
it only matters that if we do, it is the "correct" exception that was validly used to cancel the
coroutine that gets passed here and not `TestException`. */
- assertTrue(t is CancellationException)
+ assertIs<CancellationException>(t)
+ }
+
+ override fun onComplete() {
+ expectUnreached()
}
- override fun onComplete() { expectUnreached() }
})
expect(5)
val result: ChannelResult<Unit> = producerScope!!.trySend(1)
val e = result.exceptionOrNull()!!
- assertTrue(e is CancellationException, "The actual error: $e")
+ assertIs<CancellationException>(e, "The actual error: $e")
assertTrue(producerScope!!.isClosedForSend)
assertTrue(result.isFailure)
}
diff --git a/reactive/kotlinx-coroutines-reactive/test/PublisherAsFlowTest.kt b/reactive/kotlinx-coroutines-reactive/test/PublisherAsFlowTest.kt
index 04f95587..42dd6817 100644
--- a/reactive/kotlinx-coroutines-reactive/test/PublisherAsFlowTest.kt
+++ b/reactive/kotlinx-coroutines-reactive/test/PublisherAsFlowTest.kt
@@ -1,8 +1,10 @@
package kotlinx.coroutines.reactive
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.flow.*
+import kotlinx.coroutines.testing.flow.*
import org.reactivestreams.*
import kotlin.test.*
diff --git a/reactive/kotlinx-coroutines-reactive/test/PublisherBackpressureTest.kt b/reactive/kotlinx-coroutines-reactive/test/PublisherBackpressureTest.kt
index c69664a2..8b8d0fc7 100644
--- a/reactive/kotlinx-coroutines-reactive/test/PublisherBackpressureTest.kt
+++ b/reactive/kotlinx-coroutines-reactive/test/PublisherBackpressureTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactive
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import org.reactivestreams.*
diff --git a/reactive/kotlinx-coroutines-reactive/test/PublisherCollectTest.kt b/reactive/kotlinx-coroutines-reactive/test/PublisherCollectTest.kt
index 841cd661..a7f94dfe 100644
--- a/reactive/kotlinx-coroutines-reactive/test/PublisherCollectTest.kt
+++ b/reactive/kotlinx-coroutines-reactive/test/PublisherCollectTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactive
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import org.reactivestreams.*
diff --git a/reactive/kotlinx-coroutines-reactive/test/PublisherCompletionStressTest.kt b/reactive/kotlinx-coroutines-reactive/test/PublisherCompletionStressTest.kt
index 2da63d0a..f3ea6854 100644
--- a/reactive/kotlinx-coroutines-reactive/test/PublisherCompletionStressTest.kt
+++ b/reactive/kotlinx-coroutines-reactive/test/PublisherCompletionStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactive
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import java.util.*
diff --git a/reactive/kotlinx-coroutines-reactive/test/PublisherMultiTest.kt b/reactive/kotlinx-coroutines-reactive/test/PublisherMultiTest.kt
index 22762bb0..2ac658d0 100644
--- a/reactive/kotlinx-coroutines-reactive/test/PublisherMultiTest.kt
+++ b/reactive/kotlinx-coroutines-reactive/test/PublisherMultiTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactive
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.selects.*
import org.junit.Test
diff --git a/reactive/kotlinx-coroutines-reactive/test/PublisherRequestStressTest.kt b/reactive/kotlinx-coroutines-reactive/test/PublisherRequestStressTest.kt
index f3b0428b..18ab7c31 100644
--- a/reactive/kotlinx-coroutines-reactive/test/PublisherRequestStressTest.kt
+++ b/reactive/kotlinx-coroutines-reactive/test/PublisherRequestStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactive
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.flow.Flow
diff --git a/reactive/kotlinx-coroutines-reactive/test/PublisherSubscriptionSelectTest.kt b/reactive/kotlinx-coroutines-reactive/test/PublisherSubscriptionSelectTest.kt
index 3589d485..ab22d12c 100644
--- a/reactive/kotlinx-coroutines-reactive/test/PublisherSubscriptionSelectTest.kt
+++ b/reactive/kotlinx-coroutines-reactive/test/PublisherSubscriptionSelectTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactive
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.selects.*
diff --git a/reactive/kotlinx-coroutines-reactive/test/ReactiveStreamTckTest.kt b/reactive/kotlinx-coroutines-reactive/test/ReactiveStreamTckTest.kt
index 74d082d0..9a4fc523 100644
--- a/reactive/kotlinx-coroutines-reactive/test/ReactiveStreamTckTest.kt
+++ b/reactive/kotlinx-coroutines-reactive/test/ReactiveStreamTckTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactive
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.reactivestreams.*
import org.reactivestreams.tck.*
diff --git a/reactive/kotlinx-coroutines-reactor/test/BackpressureTest.kt b/reactive/kotlinx-coroutines-reactor/test/BackpressureTest.kt
index 78427f01..16775eb5 100644
--- a/reactive/kotlinx-coroutines-reactor/test/BackpressureTest.kt
+++ b/reactive/kotlinx-coroutines-reactor/test/BackpressureTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactor
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.flow.*
diff --git a/reactive/kotlinx-coroutines-reactor/test/ConvertTest.kt b/reactive/kotlinx-coroutines-reactor/test/ConvertTest.kt
index 70ee6888..7da27cf2 100644
--- a/reactive/kotlinx-coroutines-reactor/test/ConvertTest.kt
+++ b/reactive/kotlinx-coroutines-reactor/test/ConvertTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactor
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.flow.*
diff --git a/reactive/kotlinx-coroutines-reactor/test/FlowAsFluxTest.kt b/reactive/kotlinx-coroutines-reactor/test/FlowAsFluxTest.kt
index d8807385..0a94c8e4 100644
--- a/reactive/kotlinx-coroutines-reactor/test/FlowAsFluxTest.kt
+++ b/reactive/kotlinx-coroutines-reactor/test/FlowAsFluxTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactor
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.reactive.*
diff --git a/reactive/kotlinx-coroutines-reactor/test/FluxCompletionStressTest.kt b/reactive/kotlinx-coroutines-reactor/test/FluxCompletionStressTest.kt
index 122cf6a1..6c3ca4c6 100644
--- a/reactive/kotlinx-coroutines-reactor/test/FluxCompletionStressTest.kt
+++ b/reactive/kotlinx-coroutines-reactor/test/FluxCompletionStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactor
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.reactive.*
import org.junit.*
diff --git a/reactive/kotlinx-coroutines-reactor/test/FluxContextTest.kt b/reactive/kotlinx-coroutines-reactor/test/FluxContextTest.kt
index 81c0e821..a9eb5226 100644
--- a/reactive/kotlinx-coroutines-reactor/test/FluxContextTest.kt
+++ b/reactive/kotlinx-coroutines-reactor/test/FluxContextTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactor
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.reactive.*
diff --git a/reactive/kotlinx-coroutines-reactor/test/FluxMultiTest.kt b/reactive/kotlinx-coroutines-reactor/test/FluxMultiTest.kt
index 8254b824..562f0a9b 100644
--- a/reactive/kotlinx-coroutines-reactor/test/FluxMultiTest.kt
+++ b/reactive/kotlinx-coroutines-reactor/test/FluxMultiTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactor
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.reactive.*
import org.junit.*
diff --git a/reactive/kotlinx-coroutines-reactor/test/FluxSingleTest.kt b/reactive/kotlinx-coroutines-reactor/test/FluxSingleTest.kt
index ebce20f8..6bc6dc1e 100644
--- a/reactive/kotlinx-coroutines-reactor/test/FluxSingleTest.kt
+++ b/reactive/kotlinx-coroutines-reactor/test/FluxSingleTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactor
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.reactive.*
import org.junit.*
diff --git a/reactive/kotlinx-coroutines-reactor/test/FluxTest.kt b/reactive/kotlinx-coroutines-reactor/test/FluxTest.kt
index 860be092..634bbcd5 100644
--- a/reactive/kotlinx-coroutines-reactor/test/FluxTest.kt
+++ b/reactive/kotlinx-coroutines-reactor/test/FluxTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactor
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.flow.*
@@ -37,7 +38,7 @@ class FluxTest : TestBase() {
expectUnreached()
}, { error ->
expect(5)
- assertTrue(error is RuntimeException)
+ assertIs<RuntimeException>(error)
assertEquals("OK", error.message)
})
expect(3)
diff --git a/reactive/kotlinx-coroutines-reactor/test/MonoAwaitStressTest.kt b/reactive/kotlinx-coroutines-reactor/test/MonoAwaitStressTest.kt
index f02b0641..a40ced83 100644
--- a/reactive/kotlinx-coroutines-reactor/test/MonoAwaitStressTest.kt
+++ b/reactive/kotlinx-coroutines-reactor/test/MonoAwaitStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactor
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import org.reactivestreams.*
diff --git a/reactive/kotlinx-coroutines-reactor/test/MonoTest.kt b/reactive/kotlinx-coroutines-reactor/test/MonoTest.kt
index 4ebcc749..80603570 100644
--- a/reactive/kotlinx-coroutines-reactor/test/MonoTest.kt
+++ b/reactive/kotlinx-coroutines-reactor/test/MonoTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactor
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.flow.*
@@ -49,7 +50,7 @@ class MonoTest : TestBase() {
expectUnreached()
}, { error ->
expect(5)
- assertTrue(error is RuntimeException)
+ assertIs<RuntimeException>(error)
assertEquals("OK", error.message)
})
expect(3)
@@ -233,7 +234,7 @@ class MonoTest : TestBase() {
mono.awaitSingle()
expectUnreached()
} catch (e: TestException) {
- assertTrue(e.suppressed[0] is TestException2)
+ assertIs<TestException2>(e.suppressed[0])
}
}
@@ -242,7 +243,7 @@ class MonoTest : TestBase() {
expect(1)
var subscription: Subscription? = null
val handler = BiFunction<Throwable, Any?, Throwable> { t, _ ->
- assertTrue(t is TestException)
+ assertIs<TestException>(t)
expect(5)
t
}
diff --git a/reactive/kotlinx-coroutines-reactor/test/ReactorContextTest.kt b/reactive/kotlinx-coroutines-reactor/test/ReactorContextTest.kt
index 577238be..5bc6d451 100644
--- a/reactive/kotlinx-coroutines-reactor/test/ReactorContextTest.kt
+++ b/reactive/kotlinx-coroutines-reactor/test/ReactorContextTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactor
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.flow.*
diff --git a/reactive/kotlinx-coroutines-reactor/test/SchedulerTest.kt b/reactive/kotlinx-coroutines-reactor/test/SchedulerTest.kt
index b945c526..7437d3a1 100644
--- a/reactive/kotlinx-coroutines-reactor/test/SchedulerTest.kt
+++ b/reactive/kotlinx-coroutines-reactor/test/SchedulerTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.reactor
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Before
import org.junit.Test
diff --git a/reactive/kotlinx-coroutines-rx2/test/BackpressureTest.kt b/reactive/kotlinx-coroutines-rx2/test/BackpressureTest.kt
index 497f94e1..033df379 100644
--- a/reactive/kotlinx-coroutines-rx2/test/BackpressureTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/BackpressureTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import io.reactivex.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
diff --git a/reactive/kotlinx-coroutines-rx2/test/CompletableTest.kt b/reactive/kotlinx-coroutines-rx2/test/CompletableTest.kt
index c1fb4d07..c271a2fb 100644
--- a/reactive/kotlinx-coroutines-rx2/test/CompletableTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/CompletableTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import io.reactivex.*
import io.reactivex.disposables.*
import io.reactivex.exceptions.*
@@ -35,7 +36,7 @@ class CompletableTest : TestBase() {
expectUnreached()
}, { error ->
expect(5)
- assertTrue(error is RuntimeException)
+ assertIs<RuntimeException>(error)
assertEquals("OK", error.message)
})
expect(3)
@@ -135,7 +136,7 @@ class CompletableTest : TestBase() {
completable.await()
expectUnreached()
} catch (e: TestException) {
- assertTrue(e.suppressed[0] is TestException2)
+ assertIs<TestException2>(e.suppressed[0])
}
}
@@ -195,7 +196,7 @@ class CompletableTest : TestBase() {
fun testFatalExceptionInSingle() = runTest {
rxCompletable(Dispatchers.Unconfined) {
throw LinkageError()
- }.subscribe({ expectUnreached() }, { expect(1); assertTrue(it is LinkageError) })
+ }.subscribe({ expectUnreached() }, { expect(1); assertIs<LinkageError>(it) })
finish(2)
}
}
diff --git a/reactive/kotlinx-coroutines-rx2/test/ConvertTest.kt b/reactive/kotlinx-coroutines-rx2/test/ConvertTest.kt
index 1bf53d26..d57f6fa0 100644
--- a/reactive/kotlinx-coroutines-rx2/test/ConvertTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/ConvertTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.flow.*
diff --git a/reactive/kotlinx-coroutines-rx2/test/FlowAsFlowableTest.kt b/reactive/kotlinx-coroutines-rx2/test/FlowAsFlowableTest.kt
index 41e25fe0..0bcacef0 100644
--- a/reactive/kotlinx-coroutines-rx2/test/FlowAsFlowableTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/FlowAsFlowableTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import org.junit.Test
diff --git a/reactive/kotlinx-coroutines-rx2/test/FlowAsObservableTest.kt b/reactive/kotlinx-coroutines-rx2/test/FlowAsObservableTest.kt
index a85f7c7f..c976d9b6 100644
--- a/reactive/kotlinx-coroutines-rx2/test/FlowAsObservableTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/FlowAsObservableTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import io.reactivex.*
import io.reactivex.disposables.*
import kotlinx.coroutines.*
@@ -37,7 +38,7 @@ class FlowAsObservableTest : TestBase() {
expect(2)
observable.subscribe({ expectUnreached() }, { error ->
expect(4)
- assertTrue(error is RuntimeException)
+ assertIs<RuntimeException>(error)
assertEquals("OK", error.message)
})
finish(5)
diff --git a/reactive/kotlinx-coroutines-rx2/test/FlowableContextTest.kt b/reactive/kotlinx-coroutines-rx2/test/FlowableContextTest.kt
index 692f4c28..295250e5 100644
--- a/reactive/kotlinx-coroutines-rx2/test/FlowableContextTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/FlowableContextTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import io.reactivex.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
diff --git a/reactive/kotlinx-coroutines-rx2/test/FlowableExceptionHandlingTest.kt b/reactive/kotlinx-coroutines-rx2/test/FlowableExceptionHandlingTest.kt
index e079631d..bcfd32aa 100644
--- a/reactive/kotlinx-coroutines-rx2/test/FlowableExceptionHandlingTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/FlowableExceptionHandlingTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import io.reactivex.exceptions.*
import kotlinx.coroutines.*
import org.junit.*
diff --git a/reactive/kotlinx-coroutines-rx2/test/FlowableTest.kt b/reactive/kotlinx-coroutines-rx2/test/FlowableTest.kt
index ef207476..94fc7d6f 100644
--- a/reactive/kotlinx-coroutines-rx2/test/FlowableTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/FlowableTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.reactive.*
import org.junit.*
@@ -36,7 +37,7 @@ class FlowableTest : TestBase() {
expectUnreached()
}, { error ->
expect(5)
- assertTrue(error is RuntimeException)
+ assertIs<RuntimeException>(error)
assertEquals("OK", error.message)
})
expect(3)
@@ -120,4 +121,4 @@ class FlowableTest : TestBase() {
finish(3)
}
}
-} \ No newline at end of file
+}
diff --git a/reactive/kotlinx-coroutines-rx2/test/IntegrationTest.kt b/reactive/kotlinx-coroutines-rx2/test/IntegrationTest.kt
index 652afe5f..8469af41 100644
--- a/reactive/kotlinx-coroutines-rx2/test/IntegrationTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/IntegrationTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import io.reactivex.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
diff --git a/reactive/kotlinx-coroutines-rx2/test/LeakedExceptionTest.kt b/reactive/kotlinx-coroutines-rx2/test/LeakedExceptionTest.kt
index 89f74145..4f169664 100644
--- a/reactive/kotlinx-coroutines-rx2/test/LeakedExceptionTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/LeakedExceptionTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import io.reactivex.*
import io.reactivex.exceptions.*
import kotlinx.coroutines.*
diff --git a/reactive/kotlinx-coroutines-rx2/test/MaybeTest.kt b/reactive/kotlinx-coroutines-rx2/test/MaybeTest.kt
index 5206a336..74bc8324 100644
--- a/reactive/kotlinx-coroutines-rx2/test/MaybeTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/MaybeTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import io.reactivex.*
import io.reactivex.disposables.*
import io.reactivex.exceptions.*
@@ -62,7 +63,7 @@ class MaybeTest : TestBase() {
expectUnreached()
}, { error ->
expect(5)
- assertTrue(error is RuntimeException)
+ assertIs<RuntimeException>(error)
assertEquals("OK", error.message)
})
expect(3)
@@ -316,7 +317,7 @@ class MaybeTest : TestBase() {
maybe.awaitSingleOrNull()
expectUnreached()
} catch (e: TestException) {
- assertTrue(e.suppressed[0] is TestException2)
+ assertIs<TestException2>(e.suppressed[0])
}
}
@@ -382,7 +383,7 @@ class MaybeTest : TestBase() {
fun testFatalExceptionInSingle() = runTest {
rxMaybe(Dispatchers.Unconfined) {
throw LinkageError()
- }.subscribe({ expectUnreached() }, { expect(1); assertTrue(it is LinkageError) })
+ }.subscribe({ expectUnreached() }, { expect(1); assertIs<LinkageError>(it) })
finish(2)
}
}
diff --git a/reactive/kotlinx-coroutines-rx2/test/ObservableAsFlowTest.kt b/reactive/kotlinx-coroutines-rx2/test/ObservableAsFlowTest.kt
index 0a5cacba..1391d7e8 100644
--- a/reactive/kotlinx-coroutines-rx2/test/ObservableAsFlowTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/ObservableAsFlowTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import io.reactivex.Observable
import io.reactivex.ObservableSource
import io.reactivex.Observer
@@ -8,6 +9,7 @@ import io.reactivex.subjects.PublishSubject
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.flow.*
+import kotlinx.coroutines.testing.flow.*
import kotlin.test.*
class ObservableAsFlowTest : TestBase() {
@@ -178,4 +180,4 @@ class ObservableAsFlowTest : TestBase() {
channel.consumeEach { result.add(it) }
assertEquals(expected, result)
}
-} \ No newline at end of file
+}
diff --git a/reactive/kotlinx-coroutines-rx2/test/ObservableCollectTest.kt b/reactive/kotlinx-coroutines-rx2/test/ObservableCollectTest.kt
index 1efaa939..59c886d9 100644
--- a/reactive/kotlinx-coroutines-rx2/test/ObservableCollectTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/ObservableCollectTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import io.reactivex.*
import io.reactivex.disposables.*
import kotlinx.coroutines.*
diff --git a/reactive/kotlinx-coroutines-rx2/test/ObservableCompletionStressTest.kt b/reactive/kotlinx-coroutines-rx2/test/ObservableCompletionStressTest.kt
index 52b1f891..3d2546af 100644
--- a/reactive/kotlinx-coroutines-rx2/test/ObservableCompletionStressTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/ObservableCompletionStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import java.util.*
diff --git a/reactive/kotlinx-coroutines-rx2/test/ObservableExceptionHandlingTest.kt b/reactive/kotlinx-coroutines-rx2/test/ObservableExceptionHandlingTest.kt
index 66a4a305..0d34a4e5 100644
--- a/reactive/kotlinx-coroutines-rx2/test/ObservableExceptionHandlingTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/ObservableExceptionHandlingTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import io.reactivex.exceptions.*
import kotlinx.coroutines.*
import org.junit.*
@@ -84,8 +85,8 @@ class ObservableExceptionHandlingTest : TestBase() {
expect(1)
val result = trySend(Unit)
val exception = result.exceptionOrNull()
- assertTrue(exception is UndeliverableException)
- assertTrue(exception.cause is LinkageError)
+ assertIs<UndeliverableException>(exception)
+ assertIs<LinkageError>(exception.cause)
assertTrue(isClosedForSend)
expect(4)
latch.countDown()
diff --git a/reactive/kotlinx-coroutines-rx2/test/ObservableMultiTest.kt b/reactive/kotlinx-coroutines-rx2/test/ObservableMultiTest.kt
index 7471c6de..09562fbb 100644
--- a/reactive/kotlinx-coroutines-rx2/test/ObservableMultiTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/ObservableMultiTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import io.reactivex.*
import kotlinx.coroutines.*
import kotlinx.coroutines.selects.*
diff --git a/reactive/kotlinx-coroutines-rx2/test/ObservableSingleTest.kt b/reactive/kotlinx-coroutines-rx2/test/ObservableSingleTest.kt
index acb0251d..5bd6d0d7 100644
--- a/reactive/kotlinx-coroutines-rx2/test/ObservableSingleTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/ObservableSingleTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import io.reactivex.*
import io.reactivex.disposables.*
import kotlinx.coroutines.*
@@ -60,7 +61,7 @@ class ObservableSingleTest : TestBase() {
}
checkErroneous(observable) {
- assertTrue(it is IllegalArgumentException)
+ assertIs<IllegalArgumentException>(it)
}
}
@@ -200,7 +201,7 @@ class ObservableSingleTest : TestBase() {
}
checkErroneous(observable) {
- assertTrue(it is IllegalStateException)
+ assertIs<IllegalStateException>(it)
assertEquals("OK", it.message)
}
}
diff --git a/reactive/kotlinx-coroutines-rx2/test/ObservableSourceAsFlowStressTest.kt b/reactive/kotlinx-coroutines-rx2/test/ObservableSourceAsFlowStressTest.kt
index f9532416..2e44de88 100644
--- a/reactive/kotlinx-coroutines-rx2/test/ObservableSourceAsFlowStressTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/ObservableSourceAsFlowStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import io.reactivex.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
diff --git a/reactive/kotlinx-coroutines-rx2/test/ObservableSubscriptionSelectTest.kt b/reactive/kotlinx-coroutines-rx2/test/ObservableSubscriptionSelectTest.kt
index 01a468c6..0c77a553 100644
--- a/reactive/kotlinx-coroutines-rx2/test/ObservableSubscriptionSelectTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/ObservableSubscriptionSelectTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.selects.*
diff --git a/reactive/kotlinx-coroutines-rx2/test/ObservableTest.kt b/reactive/kotlinx-coroutines-rx2/test/ObservableTest.kt
index f85d4d24..06ee05bd 100644
--- a/reactive/kotlinx-coroutines-rx2/test/ObservableTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/ObservableTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import io.reactivex.*
import io.reactivex.plugins.*
import kotlinx.coroutines.*
@@ -44,7 +45,7 @@ class ObservableTest : TestBase() {
expectUnreached()
}, { error ->
expect(5)
- assertTrue(error is RuntimeException)
+ assertIs<RuntimeException>(error)
assertEquals("OK", error.message)
})
expect(3)
@@ -157,4 +158,4 @@ class ObservableTest : TestBase() {
}
private fun timeBomb() = Single.timer(1, TimeUnit.MILLISECONDS).doOnSuccess { throw TestException() }
-} \ No newline at end of file
+}
diff --git a/reactive/kotlinx-coroutines-rx2/test/SchedulerStressTest.kt b/reactive/kotlinx-coroutines-rx2/test/SchedulerStressTest.kt
index c467c8f6..5b77e6aa 100644
--- a/reactive/kotlinx-coroutines-rx2/test/SchedulerStressTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/SchedulerStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import java.util.concurrent.*
diff --git a/reactive/kotlinx-coroutines-rx2/test/SchedulerTest.kt b/reactive/kotlinx-coroutines-rx2/test/SchedulerTest.kt
index 1ba15321..cf163b71 100644
--- a/reactive/kotlinx-coroutines-rx2/test/SchedulerTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/SchedulerTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import io.reactivex.*
import io.reactivex.disposables.*
import io.reactivex.plugins.*
diff --git a/reactive/kotlinx-coroutines-rx2/test/SingleTest.kt b/reactive/kotlinx-coroutines-rx2/test/SingleTest.kt
index cb75d51f..0d9f0f3a 100644
--- a/reactive/kotlinx-coroutines-rx2/test/SingleTest.kt
+++ b/reactive/kotlinx-coroutines-rx2/test/SingleTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx2
+import kotlinx.coroutines.testing.*
import io.reactivex.*
import io.reactivex.disposables.*
import io.reactivex.exceptions.*
@@ -46,7 +47,7 @@ class SingleTest : TestBase() {
expectUnreached()
}, { error ->
expect(5)
- assertTrue(error is RuntimeException)
+ assertIs<RuntimeException>(error)
assertEquals("OK", error.message)
})
expect(3)
@@ -218,7 +219,7 @@ class SingleTest : TestBase() {
single.await()
expectUnreached()
} catch (e: TestException) {
- assertTrue(e.suppressed[0] is TestException2)
+ assertIs<TestException2>(e.suppressed[0])
}
}
@@ -243,7 +244,7 @@ class SingleTest : TestBase() {
fun testFatalExceptionInSingle() = runTest {
rxSingle(Dispatchers.Unconfined) {
throw LinkageError()
- }.subscribe { _, e -> assertTrue(e is LinkageError); expect(1) }
+ }.subscribe { _, e -> assertIs<LinkageError>(e); expect(1) }
finish(2)
}
diff --git a/reactive/kotlinx-coroutines-rx3/test/BackpressureTest.kt b/reactive/kotlinx-coroutines-rx3/test/BackpressureTest.kt
index 0317c71f..bfffe15f 100644
--- a/reactive/kotlinx-coroutines-rx3/test/BackpressureTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/BackpressureTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import io.reactivex.rxjava3.core.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
diff --git a/reactive/kotlinx-coroutines-rx3/test/CompletableTest.kt b/reactive/kotlinx-coroutines-rx3/test/CompletableTest.kt
index eab81295..b9355cce 100644
--- a/reactive/kotlinx-coroutines-rx3/test/CompletableTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/CompletableTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import io.reactivex.rxjava3.core.*
import io.reactivex.rxjava3.disposables.*
import io.reactivex.rxjava3.exceptions.*
@@ -35,7 +36,7 @@ class CompletableTest : TestBase() {
expectUnreached()
}, { error ->
expect(5)
- assertTrue(error is RuntimeException)
+ assertIs<RuntimeException>(error)
assertEquals("OK", error.message)
})
expect(3)
@@ -135,7 +136,7 @@ class CompletableTest : TestBase() {
completable.await()
expectUnreached()
} catch (e: TestException) {
- assertTrue(e.suppressed[0] is TestException2)
+ assertIs<TestException2>(e.suppressed[0])
}
}
@@ -195,7 +196,7 @@ class CompletableTest : TestBase() {
fun testFatalExceptionInSingle() = runTest {
rxCompletable(Dispatchers.Unconfined) {
throw LinkageError()
- }.subscribe({ expectUnreached() }, { expect(1); assertTrue(it is LinkageError) })
+ }.subscribe({ expectUnreached() }, { expect(1); assertIs<LinkageError>(it) })
finish(2)
}
}
diff --git a/reactive/kotlinx-coroutines-rx3/test/ConvertTest.kt b/reactive/kotlinx-coroutines-rx3/test/ConvertTest.kt
index 3f0ed7fc..5013bb9d 100644
--- a/reactive/kotlinx-coroutines-rx3/test/ConvertTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/ConvertTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.flow.consumeAsFlow
diff --git a/reactive/kotlinx-coroutines-rx3/test/FlowAsFlowableTest.kt b/reactive/kotlinx-coroutines-rx3/test/FlowAsFlowableTest.kt
index 3090c815..cc565c83 100644
--- a/reactive/kotlinx-coroutines-rx3/test/FlowAsFlowableTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/FlowAsFlowableTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import org.junit.Test
diff --git a/reactive/kotlinx-coroutines-rx3/test/FlowAsObservableTest.kt b/reactive/kotlinx-coroutines-rx3/test/FlowAsObservableTest.kt
index 359e48ac..8bacb2f2 100644
--- a/reactive/kotlinx-coroutines-rx3/test/FlowAsObservableTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/FlowAsObservableTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import io.reactivex.rxjava3.core.*
import io.reactivex.rxjava3.disposables.*
import kotlinx.coroutines.*
@@ -37,7 +38,7 @@ class FlowAsObservableTest : TestBase() {
expect(2)
observable.subscribe({ expectUnreached() }, { error ->
expect(4)
- assertTrue(error is RuntimeException)
+ assertIs<RuntimeException>(error)
assertEquals("OK", error.message)
})
finish(5)
diff --git a/reactive/kotlinx-coroutines-rx3/test/FlowableContextTest.kt b/reactive/kotlinx-coroutines-rx3/test/FlowableContextTest.kt
index b417205c..5e87d71b 100644
--- a/reactive/kotlinx-coroutines-rx3/test/FlowableContextTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/FlowableContextTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import io.reactivex.rxjava3.core.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
diff --git a/reactive/kotlinx-coroutines-rx3/test/FlowableExceptionHandlingTest.kt b/reactive/kotlinx-coroutines-rx3/test/FlowableExceptionHandlingTest.kt
index 9db7aeee..d250de91 100644
--- a/reactive/kotlinx-coroutines-rx3/test/FlowableExceptionHandlingTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/FlowableExceptionHandlingTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import io.reactivex.rxjava3.exceptions.*
import kotlinx.coroutines.*
import org.junit.*
diff --git a/reactive/kotlinx-coroutines-rx3/test/FlowableTest.kt b/reactive/kotlinx-coroutines-rx3/test/FlowableTest.kt
index 969adc8b..2460bd64 100644
--- a/reactive/kotlinx-coroutines-rx3/test/FlowableTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/FlowableTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.reactive.*
import org.junit.Test
@@ -35,7 +36,7 @@ class FlowableTest : TestBase() {
expectUnreached()
}, { error ->
expect(5)
- assertTrue(error is RuntimeException)
+ assertIs<RuntimeException>(error)
assertEquals("OK", error.message)
})
expect(3)
diff --git a/reactive/kotlinx-coroutines-rx3/test/IntegrationTest.kt b/reactive/kotlinx-coroutines-rx3/test/IntegrationTest.kt
index 3cee2635..f51d7cd6 100644
--- a/reactive/kotlinx-coroutines-rx3/test/IntegrationTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/IntegrationTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import io.reactivex.rxjava3.core.*
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.consumeAsFlow
diff --git a/reactive/kotlinx-coroutines-rx3/test/LeakedExceptionTest.kt b/reactive/kotlinx-coroutines-rx3/test/LeakedExceptionTest.kt
index 1b17e2ab..5f9caf5c 100644
--- a/reactive/kotlinx-coroutines-rx3/test/LeakedExceptionTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/LeakedExceptionTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import io.reactivex.rxjava3.core.*
import io.reactivex.rxjava3.exceptions.*
import kotlinx.coroutines.*
diff --git a/reactive/kotlinx-coroutines-rx3/test/MaybeTest.kt b/reactive/kotlinx-coroutines-rx3/test/MaybeTest.kt
index 969b9d8d..3746d43d 100644
--- a/reactive/kotlinx-coroutines-rx3/test/MaybeTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/MaybeTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import io.reactivex.rxjava3.core.*
import io.reactivex.rxjava3.disposables.*
import io.reactivex.rxjava3.exceptions.*
@@ -62,7 +63,7 @@ class MaybeTest : TestBase() {
expectUnreached()
}, { error ->
expect(5)
- assertTrue(error is RuntimeException)
+ assertIs<RuntimeException>(error)
assertEquals("OK", error.message)
})
expect(3)
@@ -316,7 +317,7 @@ class MaybeTest : TestBase() {
maybe.awaitSingleOrNull()
expectUnreached()
} catch (e: TestException) {
- assertTrue(e.suppressed[0] is TestException2)
+ assertIs<TestException2>(e.suppressed[0])
}
}
@@ -382,7 +383,7 @@ class MaybeTest : TestBase() {
fun testFatalExceptionInSingle() = runTest {
rxMaybe(Dispatchers.Unconfined) {
throw LinkageError()
- }.subscribe({ expectUnreached() }, { expect(1); assertTrue(it is LinkageError) })
+ }.subscribe({ expectUnreached() }, { expect(1); assertIs<LinkageError>(it) })
finish(2)
}
}
diff --git a/reactive/kotlinx-coroutines-rx3/test/ObservableAsFlowTest.kt b/reactive/kotlinx-coroutines-rx3/test/ObservableAsFlowTest.kt
index 35424508..79d70525 100644
--- a/reactive/kotlinx-coroutines-rx3/test/ObservableAsFlowTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/ObservableAsFlowTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import io.reactivex.rxjava3.core.Observable
import io.reactivex.rxjava3.core.ObservableSource
import io.reactivex.rxjava3.core.Observer
@@ -8,6 +9,7 @@ import io.reactivex.rxjava3.subjects.PublishSubject
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.flow.*
+import kotlinx.coroutines.testing.flow.*
import kotlin.test.*
class ObservableAsFlowTest : TestBase() {
diff --git a/reactive/kotlinx-coroutines-rx3/test/ObservableCollectTest.kt b/reactive/kotlinx-coroutines-rx3/test/ObservableCollectTest.kt
index aebc15e2..ebfb8e6c 100644
--- a/reactive/kotlinx-coroutines-rx3/test/ObservableCollectTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/ObservableCollectTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import io.reactivex.rxjava3.core.ObservableSource
import io.reactivex.rxjava3.disposables.*
import kotlinx.coroutines.*
diff --git a/reactive/kotlinx-coroutines-rx3/test/ObservableCompletionStressTest.kt b/reactive/kotlinx-coroutines-rx3/test/ObservableCompletionStressTest.kt
index 37bf71ee..c0acd07d 100644
--- a/reactive/kotlinx-coroutines-rx3/test/ObservableCompletionStressTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/ObservableCompletionStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import java.util.*
diff --git a/reactive/kotlinx-coroutines-rx3/test/ObservableExceptionHandlingTest.kt b/reactive/kotlinx-coroutines-rx3/test/ObservableExceptionHandlingTest.kt
index 12761539..63fb73bf 100644
--- a/reactive/kotlinx-coroutines-rx3/test/ObservableExceptionHandlingTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/ObservableExceptionHandlingTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import io.reactivex.rxjava3.exceptions.*
import kotlinx.coroutines.*
import org.junit.*
@@ -84,8 +85,8 @@ class ObservableExceptionHandlingTest : TestBase() {
expect(1)
val result = trySend(Unit)
val exception = result.exceptionOrNull()
- assertTrue(exception is UndeliverableException)
- assertTrue(exception.cause is LinkageError)
+ assertIs<UndeliverableException>(exception)
+ assertIs<LinkageError>(exception.cause)
assertTrue(isClosedForSend)
expect(4)
latch.countDown()
diff --git a/reactive/kotlinx-coroutines-rx3/test/ObservableMultiTest.kt b/reactive/kotlinx-coroutines-rx3/test/ObservableMultiTest.kt
index cddacac1..83005e95 100644
--- a/reactive/kotlinx-coroutines-rx3/test/ObservableMultiTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/ObservableMultiTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import io.reactivex.rxjava3.core.*
import kotlinx.coroutines.*
import kotlinx.coroutines.selects.*
diff --git a/reactive/kotlinx-coroutines-rx3/test/ObservableSingleTest.kt b/reactive/kotlinx-coroutines-rx3/test/ObservableSingleTest.kt
index 60deb3dd..ea09a228 100644
--- a/reactive/kotlinx-coroutines-rx3/test/ObservableSingleTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/ObservableSingleTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import io.reactivex.rxjava3.core.*
import io.reactivex.rxjava3.disposables.*
import kotlinx.coroutines.*
@@ -60,7 +61,7 @@ class ObservableSingleTest : TestBase() {
}
checkErroneous(observable) {
- assertTrue(it is IllegalArgumentException)
+ assertIs<IllegalArgumentException>(it)
}
}
@@ -200,7 +201,7 @@ class ObservableSingleTest : TestBase() {
}
checkErroneous(observable) {
- assertTrue(it is IllegalStateException)
+ assertIs<IllegalStateException>(it)
assertEquals("OK", it.message)
}
}
diff --git a/reactive/kotlinx-coroutines-rx3/test/ObservableSourceAsFlowStressTest.kt b/reactive/kotlinx-coroutines-rx3/test/ObservableSourceAsFlowStressTest.kt
index 8fbd3da3..13b6a84e 100644
--- a/reactive/kotlinx-coroutines-rx3/test/ObservableSourceAsFlowStressTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/ObservableSourceAsFlowStressTest.kt
@@ -1,7 +1,7 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import io.reactivex.rxjava3.core.*
-import io.reactivex.rxjava3.exceptions.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.flow.*
diff --git a/reactive/kotlinx-coroutines-rx3/test/ObservableSubscriptionSelectTest.kt b/reactive/kotlinx-coroutines-rx3/test/ObservableSubscriptionSelectTest.kt
index f54e2e1a..7e21c5c0 100644
--- a/reactive/kotlinx-coroutines-rx3/test/ObservableSubscriptionSelectTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/ObservableSubscriptionSelectTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.*
import kotlinx.coroutines.selects.*
diff --git a/reactive/kotlinx-coroutines-rx3/test/ObservableTest.kt b/reactive/kotlinx-coroutines-rx3/test/ObservableTest.kt
index 619c6ad2..59031e32 100644
--- a/reactive/kotlinx-coroutines-rx3/test/ObservableTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/ObservableTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import io.reactivex.rxjava3.core.*
import io.reactivex.rxjava3.plugins.*
import kotlinx.coroutines.*
@@ -44,7 +45,7 @@ class ObservableTest : TestBase() {
expectUnreached()
}, { error ->
expect(5)
- assertTrue(error is RuntimeException)
+ assertIs<RuntimeException>(error)
assertEquals("OK", error.message)
})
expect(3)
diff --git a/reactive/kotlinx-coroutines-rx3/test/SchedulerStressTest.kt b/reactive/kotlinx-coroutines-rx3/test/SchedulerStressTest.kt
index 66ea6554..96e21416 100644
--- a/reactive/kotlinx-coroutines-rx3/test/SchedulerStressTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/SchedulerStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import java.util.concurrent.*
diff --git a/reactive/kotlinx-coroutines-rx3/test/SchedulerTest.kt b/reactive/kotlinx-coroutines-rx3/test/SchedulerTest.kt
index 0b1ccc36..fd595037 100644
--- a/reactive/kotlinx-coroutines-rx3/test/SchedulerTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/SchedulerTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import io.reactivex.rxjava3.core.*
import io.reactivex.rxjava3.disposables.*
import io.reactivex.rxjava3.plugins.*
diff --git a/reactive/kotlinx-coroutines-rx3/test/SingleTest.kt b/reactive/kotlinx-coroutines-rx3/test/SingleTest.kt
index 5efa2f83..381a9dfe 100644
--- a/reactive/kotlinx-coroutines-rx3/test/SingleTest.kt
+++ b/reactive/kotlinx-coroutines-rx3/test/SingleTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.rx3
+import kotlinx.coroutines.testing.*
import io.reactivex.rxjava3.core.*
import io.reactivex.rxjava3.disposables.*
import io.reactivex.rxjava3.exceptions.*
@@ -46,7 +47,7 @@ class SingleTest : TestBase() {
expectUnreached()
}, { error ->
expect(5)
- assertTrue(error is RuntimeException)
+ assertIs<RuntimeException>(error)
assertEquals("OK", error.message)
})
expect(3)
@@ -218,7 +219,7 @@ class SingleTest : TestBase() {
single.await()
expectUnreached()
} catch (e: TestException) {
- assertTrue(e.suppressed[0] is TestException2)
+ assertIs<TestException2>(e.suppressed[0])
}
}
@@ -243,7 +244,7 @@ class SingleTest : TestBase() {
fun testFatalExceptionInSingle() = runTest {
rxSingle(Dispatchers.Unconfined) {
throw LinkageError()
- }.subscribe { _, e -> assertTrue(e is LinkageError); expect(1) }
+ }.subscribe { _, e -> assertIs<LinkageError>(e); expect(1) }
finish(2)
}
diff --git a/settings.gradle.kts b/settings.gradle.kts
index dac2277d..423c613f 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -25,6 +25,7 @@ build_snapshot_train = if (prop != null && prop != "") "true" else "false"
// ---------------------------
include("benchmarks")
+module("test-utils")
include("kotlinx-coroutines-core")
diff --git a/test-utils/build.gradle.kts b/test-utils/build.gradle.kts
new file mode 100644
index 00000000..66074fbc
--- /dev/null
+++ b/test-utils/build.gradle.kts
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
+ */
+
+kotlin {
+ sourceSets {
+ commonMain.dependencies {
+ api("org.jetbrains.kotlin:kotlin-test-common:${version("kotlin")}")
+ api("org.jetbrains.kotlin:kotlin-test-annotations-common:${version("kotlin")}")
+ }
+ jvmMain.dependencies {
+ api("org.jetbrains.kotlin:kotlin-test:${version("kotlin")}")
+ // Workaround to make addSuppressed work in tests
+ api("org.jetbrains.kotlin:kotlin-reflect:${version("kotlin")}")
+ api("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${version("kotlin")}")
+ api("org.jetbrains.kotlin:kotlin-test-junit:${version("kotlin")}")
+ api("junit:junit:${version("junit")}")
+ }
+ jsMain.dependencies {
+ api("org.jetbrains.kotlin:kotlin-test-js:${version("kotlin")}")
+ }
+ val wasmJsMain by getting {
+ dependencies {
+ api("org.jetbrains.kotlin:kotlin-test-wasm-js:${version("kotlin")}")
+ }
+ }
+ }
+}
diff --git a/kotlinx-coroutines-core/common/test/flow/terminal/LaunchFlow.kt b/test-utils/common/src/LaunchFlow.kt
index 3130dfd1..c13e07f5 100644
--- a/kotlinx-coroutines-core/common/test/flow/terminal/LaunchFlow.kt
+++ b/test-utils/common/src/LaunchFlow.kt
@@ -1,6 +1,7 @@
-package kotlinx.coroutines.flow
+package kotlinx.coroutines.testing.flow
import kotlinx.coroutines.*
+import kotlinx.coroutines.flow.*
import kotlin.jvm.*
import kotlin.reflect.*
@@ -34,7 +35,7 @@ public class LaunchFlowBuilder<T> {
check(onEach != null) { "onEach block should be registered first" }
check(finally == null) { "exceptionHandlers block should be registered before finally block" }
@Suppress("UNCHECKED_CAST")
- exceptionHandlers[T::class] = action as Handler<Throwable>
+ exceptionHandlers[T::class] = action as Handler<Throwable>
}
public fun finally(action: suspend CoroutineScope.(cause: Throwable?) -> Unit) {
diff --git a/kotlinx-coroutines-core/common/test/MainDispatcherTestBase.kt b/test-utils/common/src/MainDispatcherTestBase.kt
index c4b21cdc..dd867a2d 100644
--- a/kotlinx-coroutines-core/common/test/MainDispatcherTestBase.kt
+++ b/test-utils/common/src/MainDispatcherTestBase.kt
@@ -1,5 +1,6 @@
-package kotlinx.coroutines
+package kotlinx.coroutines.testing
+import kotlinx.coroutines.*
import kotlin.test.*
abstract class MainDispatcherTestBase: TestBase() {
@@ -102,7 +103,12 @@ abstract class MainDispatcherTestBase: TestBase() {
}
private suspend fun checkDispatchRequirements() {
- isMainThread()?.let { assertNotEquals(it, Dispatchers.Main.immediate.isDispatchNeeded(currentCoroutineContext())) }
+ isMainThread()?.let {
+ assertNotEquals(
+ it,
+ Dispatchers.Main.immediate.isDispatchNeeded(currentCoroutineContext())
+ )
+ }
assertTrue(Dispatchers.Main.isDispatchNeeded(currentCoroutineContext()))
assertTrue(Dispatchers.Default.isDispatchNeeded(currentCoroutineContext()))
}
diff --git a/test-utils/common/src/TestBase.common.kt b/test-utils/common/src/TestBase.common.kt
new file mode 100644
index 00000000..5c0cba4e
--- /dev/null
+++ b/test-utils/common/src/TestBase.common.kt
@@ -0,0 +1,284 @@
+@file:Suppress("unused")
+package kotlinx.coroutines.testing
+
+import kotlinx.atomicfu.*
+import kotlinx.coroutines.flow.*
+import kotlinx.coroutines.*
+import kotlinx.coroutines.internal.*
+import kotlin.coroutines.*
+import kotlin.test.*
+import kotlin.time.*
+import kotlin.time.Duration.Companion.seconds
+
+/**
+ * The number of milliseconds that is sure not to pass [assertRunsFast].
+ */
+const val SLOW = 100_000L
+
+/**
+ * Asserts that a block completed within [timeout].
+ */
+inline fun <T> assertRunsFast(timeout: Duration, block: () -> T): T {
+ val result: T
+ val elapsed = TimeSource.Monotonic.measureTime { result = block() }
+ assertTrue("Should complete in $timeout, but took $elapsed") { elapsed < timeout }
+ return result
+}
+
+/**
+ * Asserts that a block completed within two seconds.
+ */
+inline fun <T> assertRunsFast(block: () -> T): T = assertRunsFast(2.seconds, block)
+
+/**
+ * Whether the tests should trace their calls to `expect` and `finish` with `println`.
+ * `false` by default. On the JVM, can be set to `true` by setting the `test.verbose` system property.
+ */
+expect val VERBOSE: Boolean
+
+interface OrderedExecution {
+ /** Expect the next action to be [index] in order. */
+ fun expect(index: Int)
+
+ /** Expect this action to be final, with the given [index]. */
+ fun finish(index: Int)
+
+ /** * Asserts that this line is never executed. */
+ fun expectUnreached()
+
+ /**
+ * Checks that [finish] was called.
+ *
+ * By default, it is allowed to not call [finish] if [expect] was not called.
+ * This is useful for tests that don't check the ordering of events.
+ * When [allowNotUsingExpect] is set to `false`, it is an error to not call [finish] in any case.
+ */
+ fun checkFinishCall(allowNotUsingExpect: Boolean = true)
+
+ class Impl : OrderedExecution {
+ private val actionIndex = atomic(0)
+
+ override fun expect(index: Int) {
+ val wasIndex = actionIndex.incrementAndGet()
+ if (VERBOSE) println("expect($index), wasIndex=$wasIndex")
+ check(index == wasIndex) {
+ if (wasIndex < 0) "Expecting action index $index but it is actually finished"
+ else "Expecting action index $index but it is actually $wasIndex"
+ }
+ }
+
+ override fun finish(index: Int) {
+ val wasIndex = actionIndex.getAndSet(Int.MIN_VALUE) + 1
+ if (VERBOSE) println("finish($index), wasIndex=${if (wasIndex < 0) "finished" else wasIndex}")
+ check(index == wasIndex) {
+ if (wasIndex < 0) "Finished more than once"
+ else "Finishing with action index $index but it is actually $wasIndex"
+ }
+ }
+
+ override fun expectUnreached() {
+ error("Should not be reached, ${
+ actionIndex.value.let {
+ when {
+ it < 0 -> "already finished"
+ it == 0 -> "'expect' was not called yet"
+ else -> "the last executed action was $it"
+ }
+ }
+ }")
+ }
+
+ override fun checkFinishCall(allowNotUsingExpect: Boolean) {
+ actionIndex.value.let {
+ assertTrue(
+ it < 0 || allowNotUsingExpect && it == 0,
+ "Expected `finish(${actionIndex.value + 1})` to be called, but the test finished"
+ )
+ }
+ }
+ }
+}
+
+interface ErrorCatching {
+ /**
+ * Returns `true` if errors were logged in the test.
+ */
+ fun hasError(): Boolean
+
+ /**
+ * Directly reports an error to the test catching facilities.
+ */
+ fun reportError(error: Throwable)
+
+ class Impl : ErrorCatching {
+
+ private val errors = mutableListOf<Throwable>()
+ private val lock = SynchronizedObject()
+ private var closed = false
+
+ override fun hasError(): Boolean = synchronized(lock) {
+ errors.isNotEmpty()
+ }
+
+ override fun reportError(error: Throwable) {
+ synchronized(lock) {
+ if (closed) {
+ lastResortReportException(error)
+ } else {
+ errors.add(error)
+ }
+ }
+ }
+
+ fun close() {
+ synchronized(lock) {
+ if (closed) {
+ lastResortReportException(IllegalStateException("ErrorCatching closed more than once"))
+ }
+ closed = true
+ errors.firstOrNull()?.let {
+ for (error in errors.drop(1))
+ it.addSuppressed(error)
+ throw it
+ }
+ }
+ }
+ }
+}
+
+/**
+ * Reports an error *somehow* so that it doesn't get completely forgotten.
+ */
+internal expect fun lastResortReportException(error: Throwable)
+
+/**
+ * Throws [IllegalStateException] when `value` is false, like `check` in stdlib, but also ensures that the
+ * test will not complete successfully even if this exception is consumed somewhere in the test.
+ */
+public inline fun ErrorCatching.check(value: Boolean, lazyMessage: () -> Any) {
+ if (!value) error(lazyMessage())
+}
+
+/**
+ * Throws [IllegalStateException], like `error` in stdlib, but also ensures that the test will not
+ * complete successfully even if this exception is consumed somewhere in the test.
+ */
+fun ErrorCatching.error(message: Any, cause: Throwable? = null): Nothing {
+ throw IllegalStateException(message.toString(), cause).also {
+ reportError(it)
+ }
+}
+
+/**
+ * A class inheriting from which allows to check the execution order inside tests.
+ *
+ * @see TestBase
+ */
+open class OrderedExecutionTestBase : OrderedExecution
+{
+ // TODO: move to by-delegation when [reset] is no longer needed.
+ private var orderedExecutionDelegate = OrderedExecution.Impl()
+
+ @AfterTest
+ fun checkFinished() { orderedExecutionDelegate.checkFinishCall() }
+
+ /** Resets counter and finish flag. Workaround for parametrized tests absence in common */
+ public fun reset() {
+ orderedExecutionDelegate.checkFinishCall()
+ orderedExecutionDelegate = OrderedExecution.Impl()
+ }
+
+ override fun expect(index: Int) = orderedExecutionDelegate.expect(index)
+
+ override fun finish(index: Int) = orderedExecutionDelegate.finish(index)
+
+ override fun expectUnreached() = orderedExecutionDelegate.expectUnreached()
+
+ override fun checkFinishCall(allowNotUsingExpect: Boolean) =
+ orderedExecutionDelegate.checkFinishCall(allowNotUsingExpect)
+}
+
+fun <T> T.void() {}
+
+@OptionalExpectation
+expect annotation class NoJs()
+
+@OptionalExpectation
+expect annotation class NoNative()
+
+expect val isStressTest: Boolean
+expect val stressTestMultiplier: Int
+expect val stressTestMultiplierSqrt: Int
+
+/**
+ * The result of a multiplatform asynchronous test.
+ * Aliases into Unit on K/JVM and K/N, and into Promise on K/JS.
+ */
+@Suppress("NO_ACTUAL_FOR_EXPECT")
+public expect class TestResult
+
+public expect open class TestBase(): OrderedExecutionTestBase, ErrorCatching {
+ public fun println(message: Any?)
+
+ public fun runTest(
+ expected: ((Throwable) -> Boolean)? = null,
+ unhandled: List<(Throwable) -> Boolean> = emptyList(),
+ block: suspend CoroutineScope.() -> Unit
+ ): TestResult
+}
+
+public suspend inline fun hang(onCancellation: () -> Unit) {
+ try {
+ suspendCancellableCoroutine<Unit> { }
+ } finally {
+ onCancellation()
+ }
+}
+
+suspend inline fun <reified T : Throwable> assertFailsWith(flow: Flow<*>) = assertFailsWith<T> { flow.collect() }
+
+public suspend fun Flow<Int>.sum() = fold(0) { acc, value -> acc + value }
+public suspend fun Flow<Long>.longSum() = fold(0L) { acc, value -> acc + value }
+
+// data is added to avoid stacktrace recovery because CopyableThrowable is not accessible from common modules
+public class TestException(message: String? = null, private val data: Any? = null) : Throwable(message)
+public class TestException1(message: String? = null, private val data: Any? = null) : Throwable(message)
+public class TestException2(message: String? = null, private val data: Any? = null) : Throwable(message)
+public class TestException3(message: String? = null, private val data: Any? = null) : Throwable(message)
+public class TestCancellationException(message: String? = null, private val data: Any? = null) :
+ CancellationException(message)
+
+public class TestRuntimeException(message: String? = null, private val data: Any? = null) : RuntimeException(message)
+public class RecoverableTestException(message: String? = null) : RuntimeException(message)
+public class RecoverableTestCancellationException(message: String? = null) : CancellationException(message)
+
+public fun wrapperDispatcher(context: CoroutineContext): CoroutineContext {
+ val dispatcher = context[ContinuationInterceptor] as CoroutineDispatcher
+ return object : CoroutineDispatcher() {
+ override fun isDispatchNeeded(context: CoroutineContext): Boolean =
+ dispatcher.isDispatchNeeded(context)
+
+ override fun dispatch(context: CoroutineContext, block: Runnable) =
+ dispatcher.dispatch(context, block)
+ }
+}
+
+public suspend fun wrapperDispatcher(): CoroutineContext = wrapperDispatcher(coroutineContext)
+class BadClass {
+ override fun equals(other: Any?): Boolean = error("equals")
+ override fun hashCode(): Int = error("hashCode")
+ override fun toString(): String = error("toString")
+}
+
+public expect val isJavaAndWindows: Boolean
+
+public expect val isNative: Boolean
+
+/*
+ * In common tests we emulate parameterized tests
+ * by iterating over parameters space in the single @Test method.
+ * This kind of tests is too slow for JS and does not fit into
+ * the default Mocha timeout, so we're using this flag to bail-out
+ * and run such tests only on JVM and K/N.
+ */
+public expect val isBoundByJsTestTimeout: Boolean
diff --git a/test-utils/js/src/TestBase.kt b/test-utils/js/src/TestBase.kt
new file mode 100644
index 00000000..61887af6
--- /dev/null
+++ b/test-utils/js/src/TestBase.kt
@@ -0,0 +1,97 @@
+package kotlinx.coroutines.testing
+
+import kotlinx.coroutines.*
+import kotlin.test.*
+import kotlin.js.*
+
+actual typealias NoJs = Ignore
+
+actual val VERBOSE = false
+
+actual val isStressTest: Boolean = false
+actual val stressTestMultiplier: Int = 1
+actual val stressTestMultiplierSqrt: Int = 1
+
+@Suppress("ACTUAL_WITHOUT_EXPECT", "ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE")
+actual typealias TestResult = Promise<Unit>
+
+internal actual fun lastResortReportException(error: Throwable) {
+ println(error)
+ console.log(error)
+}
+
+actual open class TestBase(
+ private val errorCatching: ErrorCatching.Impl
+): OrderedExecutionTestBase(), ErrorCatching by errorCatching {
+ private var lastTestPromise: Promise<*>? = null
+
+ actual constructor(): this(errorCatching = ErrorCatching.Impl())
+
+ actual fun println(message: Any?) {
+ kotlin.io.println(message)
+ }
+
+ actual fun runTest(
+ expected: ((Throwable) -> Boolean)?,
+ unhandled: List<(Throwable) -> Boolean>,
+ block: suspend CoroutineScope.() -> Unit
+ ): TestResult {
+ var exCount = 0
+ var ex: Throwable? = null
+ /*
+ * This is an additional sanity check against `runTest` mis-usage on JS.
+ * The only way to write an async test on JS is to return Promise from the test function.
+ * _Just_ launching promise and returning `Unit` won't suffice as the underlying test framework
+ * won't be able to detect an asynchronous failure in a timely manner.
+ * We cannot detect such situations, but we can detect the most common erroneous pattern
+ * in our code base, an attempt to use multiple `runTest` in the same `@Test` method,
+ * which typically is a premise to the same error:
+ * ```
+ * @Test
+ * fun incorrectTestForJs() { // <- promise is not returned
+ * for (parameter in parameters) {
+ * runTest {
+ * runTestForParameter(parameter)
+ * }
+ * }
+ * }
+ * ```
+ */
+ if (lastTestPromise != null) {
+ error("Attempt to run multiple asynchronous test within one @Test method")
+ }
+ val result = GlobalScope.promise(block = block, context = CoroutineExceptionHandler { _, e ->
+ if (e is CancellationException) return@CoroutineExceptionHandler // are ignored
+ exCount++
+ when {
+ exCount > unhandled.size ->
+ error("Too many unhandled exceptions $exCount, expected ${unhandled.size}, got: $e", e)
+ !unhandled[exCount - 1](e) ->
+ error("Unhandled exception was unexpected: $e", e)
+ }
+ }).catch { e ->
+ ex = e
+ if (expected != null) {
+ if (!expected(e)) {
+ console.log(e)
+ error("Unexpected exception $e", e)
+ }
+ } else
+ throw e
+ }.finally {
+ if (ex == null && expected != null) error("Exception was expected but none produced")
+ if (exCount < unhandled.size)
+ error("Too few unhandled exceptions $exCount, expected ${unhandled.size}")
+ errorCatching.close()
+ checkFinishCall()
+ }
+ lastTestPromise = result
+ return result
+ }
+}
+
+actual val isNative = false
+
+actual val isBoundByJsTestTimeout = true
+
+actual val isJavaAndWindows: Boolean get() = false
diff --git a/kotlinx-coroutines-core/jvm/test/exceptions/Exceptions.kt b/test-utils/jvm/src/Exceptions.kt
index b0dd853c..a06958b9 100644
--- a/kotlinx-coroutines-core/jvm/test/exceptions/Exceptions.kt
+++ b/test-utils/jvm/src/Exceptions.kt
@@ -1,19 +1,19 @@
-package kotlinx.coroutines.exceptions
+package kotlinx.coroutines.testing.exceptions
import kotlinx.coroutines.*
import java.io.*
import java.util.*
+import kotlin.contracts.*
import kotlin.coroutines.*
import kotlin.test.*
-internal inline fun <reified T : Throwable> checkException(exception: Throwable): Boolean {
- assertTrue(exception is T)
+inline fun <reified T : Throwable> checkException(exception: Throwable) {
+ assertIs<T>(exception)
assertTrue(exception.suppressed.isEmpty())
assertNull(exception.cause)
- return true
}
-internal fun checkCycles(t: Throwable) {
+fun checkCycles(t: Throwable) {
val sw = StringWriter()
t.printStackTrace(PrintWriter(sw))
assertFalse(sw.toString().contains("CIRCULAR REFERENCE"))
@@ -28,10 +28,6 @@ class CapturingHandler : AbstractCoroutineContextElement(CoroutineExceptionHandl
unhandled!!.add(exception)
}
- fun getExceptions(): List<Throwable> = synchronized(this) {
- return unhandled!!.also { unhandled = null }
- }
-
fun getException(): Throwable = synchronized(this) {
val size = unhandled!!.size
assert(size == 1) { "Expected one unhandled exception, but have $size: $unhandled" }
@@ -39,7 +35,7 @@ class CapturingHandler : AbstractCoroutineContextElement(CoroutineExceptionHandl
}
}
-internal fun captureExceptionsRun(
+fun captureExceptionsRun(
context: CoroutineContext = EmptyCoroutineContext,
block: suspend CoroutineScope.() -> Unit
): Throwable {
@@ -48,11 +44,15 @@ internal fun captureExceptionsRun(
return handler.getException()
}
-internal fun captureMultipleExceptionsRun(
- context: CoroutineContext = EmptyCoroutineContext,
- block: suspend CoroutineScope.() -> Unit
-): List<Throwable> {
+@OptIn(ExperimentalContracts::class)
+suspend inline fun <reified E: Throwable> assertCallsExceptionHandlerWith(
+ crossinline operation: suspend (CoroutineExceptionHandler) -> Unit): E {
+ contract {
+ callsInPlace(operation, InvocationKind.EXACTLY_ONCE)
+ }
val handler = CapturingHandler()
- runBlocking(context + handler, block = block)
- return handler.getExceptions()
+ return withContext(handler) {
+ operation(handler)
+ assertIs<E>(handler.getException())
+ }
}
diff --git a/kotlinx-coroutines-core/jvm/test/ExecutorRule.kt b/test-utils/jvm/src/ExecutorRule.kt
index a90621df..ed0c87f6 100644
--- a/kotlinx-coroutines-core/jvm/test/ExecutorRule.kt
+++ b/test-utils/jvm/src/ExecutorRule.kt
@@ -1,8 +1,10 @@
-package kotlinx.coroutines
+package kotlinx.coroutines.testing
+import kotlinx.coroutines.*
import org.junit.rules.*
import org.junit.runner.*
import org.junit.runners.model.*
+import java.lang.Runnable
import java.util.concurrent.*
import kotlin.coroutines.*
diff --git a/kotlinx-coroutines-core/jvm/test/FieldWalker.kt b/test-utils/jvm/src/FieldWalker.kt
index 85664945..a807ce64 100644
--- a/kotlinx-coroutines-core/jvm/test/FieldWalker.kt
+++ b/test-utils/jvm/src/FieldWalker.kt
@@ -1,4 +1,4 @@
-package kotlinx.coroutines
+package kotlinx.coroutines.testing
import java.lang.ref.*
import java.lang.reflect.*
diff --git a/kotlinx-coroutines-core/jvm/test/TestBase.kt b/test-utils/jvm/src/TestBase.kt
index f49eb31d..31ccd7e3 100644
--- a/kotlinx-coroutines-core/jvm/test/TestBase.kt
+++ b/test-utils/jvm/src/TestBase.kt
@@ -1,35 +1,42 @@
-package kotlinx.coroutines
+package kotlinx.coroutines.testing
-import kotlinx.coroutines.internal.*
import kotlinx.coroutines.scheduling.*
-import org.junit.*
import java.io.*
import java.util.*
-import java.util.concurrent.atomic.*
import kotlin.coroutines.*
+import kotlinx.coroutines.*
import kotlin.test.*
-private val VERBOSE = systemProp("test.verbose", false)
+actual val VERBOSE = try {
+ System.getProperty("test.verbose")?.toBoolean() ?: false
+} catch (e: SecurityException) {
+ false
+}
/**
* Is `true` when running in a nightly stress test mode.
*/
-public actual val isStressTest = System.getProperty("stressTest")?.toBoolean() ?: false
+actual val isStressTest = System.getProperty("stressTest")?.toBoolean() ?: false
-public actual val stressTestMultiplierSqrt = if (isStressTest) 5 else 1
+actual val stressTestMultiplierSqrt = if (isStressTest) 5 else 1
private const val SHUTDOWN_TIMEOUT = 1_000L // 1s at most to wait per thread
-public actual val isNative = false
-
/**
* Multiply various constants in stress tests by this factor, so that they run longer during nightly stress test.
*/
-public actual val stressTestMultiplier = stressTestMultiplierSqrt * stressTestMultiplierSqrt
+actual val stressTestMultiplier = stressTestMultiplierSqrt * stressTestMultiplierSqrt
@Suppress("ACTUAL_WITHOUT_EXPECT")
-public actual typealias TestResult = Unit
+actual typealias TestResult = Unit
+
+internal actual fun lastResortReportException(error: Throwable) {
+ System.err.println("${error.message}${error.cause?.let { ": $it" } ?: ""}")
+ error.cause?.printStackTrace(System.err)
+ System.err.println("--- Detected at ---")
+ Throwable().printStackTrace(System.err)
+}
/**
* Base class for tests, so that tests for predictable scheduling of actions in multiple coroutines sharing a single
@@ -50,15 +57,13 @@ public actual typealias TestResult = Unit
* }
* ```
*/
-public actual open class TestBase(private var disableOutCheck: Boolean) {
+actual open class TestBase(
+ private var disableOutCheck: Boolean,
+ private val errorCatching: ErrorCatching.Impl = ErrorCatching.Impl()
+): OrderedExecutionTestBase(), ErrorCatching by errorCatching {
actual constructor(): this(false)
- public actual val isBoundByJsTestTimeout = false
- private var actionIndex = AtomicInteger()
- private var finished = AtomicBoolean()
- private var error = AtomicReference<Throwable>()
-
// Shutdown sequence
private lateinit var threadsBefore: Set<Thread>
private val uncaughtExceptions = Collections.synchronizedList(ArrayList<Throwable>())
@@ -71,78 +76,6 @@ public actual open class TestBase(private var disableOutCheck: Boolean) {
*/
private lateinit var previousOut: PrintStream
- /**
- * Throws [IllegalStateException] like `error` in stdlib, but also ensures that the test will not
- * complete successfully even if this exception is consumed somewhere in the test.
- */
- public actual fun error(message: Any, cause: Throwable?): Nothing {
- throw makeError(message, cause)
- }
-
- public fun hasError() = error.get() != null
-
- private fun makeError(message: Any, cause: Throwable? = null): IllegalStateException =
- IllegalStateException(message.toString(), cause).also {
- setError(it)
- }
-
- private fun setError(exception: Throwable) {
- error.compareAndSet(null, exception)
- }
-
- private fun printError(message: String, cause: Throwable) {
- setError(cause)
- System.err.println("$message: $cause")
- cause.printStackTrace(System.err)
- System.err.println("--- Detected at ---")
- Throwable().printStackTrace(System.err)
- }
-
- /**
- * Throws [IllegalStateException] when `value` is false like `check` in stdlib, but also ensures that the
- * test will not complete successfully even if this exception is consumed somewhere in the test.
- */
- public inline fun check(value: Boolean, lazyMessage: () -> Any) {
- if (!value) error(lazyMessage())
- }
-
- /**
- * Asserts that this invocation is `index`-th in the execution sequence (counting from one).
- */
- public actual fun expect(index: Int) {
- val wasIndex = actionIndex.incrementAndGet()
- if (VERBOSE) println("expect($index), wasIndex=$wasIndex")
- check(index == wasIndex) { "Expecting action index $index but it is actually $wasIndex" }
- }
-
- /**
- * Asserts that this line is never executed.
- */
- public actual fun expectUnreached() {
- error("Should not be reached, current action index is ${actionIndex.get()}")
- }
-
- /**
- * Asserts that this is the last action in the test. It must be invoked by any test that used [expect].
- */
- public actual fun finish(index: Int) {
- expect(index)
- check(!finished.getAndSet(true)) { "Should call 'finish(...)' at most once" }
- }
-
- /**
- * Asserts that [finish] was invoked
- */
- public actual fun ensureFinished() {
- require(finished.get()) { "finish(...) should be caller prior to this check" }
- }
-
- public actual fun reset() {
- check(actionIndex.get() == 0 || finished.get()) { "Expecting that 'finish(...)' was invoked, but it was not" }
- actionIndex.set(0)
- finished.set(false)
- }
-
private object TestOutputStream : PrintStream(object : OutputStream() {
override fun write(b: Int) {
error("Detected unexpected call to 'println' from source code")
@@ -154,7 +87,7 @@ public actual open class TestBase(private var disableOutCheck: Boolean) {
else previousOut.println(message)
}
- @Before
+ @BeforeTest
fun before() {
initPoolsBeforeTest()
threadsBefore = currentThreads()
@@ -170,13 +103,11 @@ public actual open class TestBase(private var disableOutCheck: Boolean) {
}
}
- @After
+ @AfterTest
fun onCompletion() {
// onCompletion should not throw exceptions before it finishes all cleanup, so that other tests always
// start in a clear, restored state
- if (actionIndex.get() != 0 && !finished.get()) {
- makeError("Expecting that 'finish(${actionIndex.get() + 1})' was invoked, but it was not")
- }
+ checkFinishCall()
if (!disableOutCheck) { // Restore global System.out first
System.setOut(previousOut)
}
@@ -186,31 +117,20 @@ public actual open class TestBase(private var disableOutCheck: Boolean) {
runCatching {
checkTestThreads(threadsBefore)
}.onFailure {
- setError(it)
+ reportError(it)
}
// Restore original uncaught exception handler after the main shutdown sequence
Thread.setDefaultUncaughtExceptionHandler(originalUncaughtExceptionHandler)
if (uncaughtExceptions.isNotEmpty()) {
- makeError("Expected no uncaught exceptions, but got $uncaughtExceptions")
+ error("Expected no uncaught exceptions, but got $uncaughtExceptions")
}
// The very last action -- throw error if any was detected
- error.get()?.let { throw it }
- }
-
- fun initPoolsBeforeTest() {
- DefaultScheduler.usePrivateScheduler()
- }
-
- fun shutdownPoolsAfterTest() {
- DefaultScheduler.shutdown(SHUTDOWN_TIMEOUT)
- DefaultExecutor.shutdownForTests(SHUTDOWN_TIMEOUT)
- DefaultScheduler.restore()
+ errorCatching.close()
}
- @Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
- public actual fun runTest(
- expected: ((Throwable) -> Boolean)? = null,
- unhandled: List<(Throwable) -> Boolean> = emptyList(),
+ actual fun runTest(
+ expected: ((Throwable) -> Boolean)?,
+ unhandled: List<(Throwable) -> Boolean>,
block: suspend CoroutineScope.() -> Unit
): TestResult {
var exCount = 0
@@ -221,9 +141,9 @@ public actual open class TestBase(private var disableOutCheck: Boolean) {
exCount++
when {
exCount > unhandled.size ->
- printError("Too many unhandled exceptions $exCount, expected ${unhandled.size}, got: $e", e)
+ error("Too many unhandled exceptions $exCount, expected ${unhandled.size}, got: $e", e)
!unhandled[exCount - 1](e) ->
- printError("Unhandled exception was unexpected: $e", e)
+ error("Unhandled exception was unexpected: $e", e)
}
})
} catch (e: Throwable) {
@@ -241,18 +161,28 @@ public actual open class TestBase(private var disableOutCheck: Boolean) {
error("Too few unhandled exceptions $exCount, expected ${unhandled.size}")
}
- protected inline fun <reified T: Throwable> assertFailsWith(block: () -> Unit): T {
- val result = runCatching(block)
- assertTrue(result.exceptionOrNull() is T, "Expected ${T::class}, but had $result")
- return result.exceptionOrNull()!! as T
- }
-
protected suspend fun currentDispatcher() = coroutineContext[ContinuationInterceptor]!!
}
+@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
+fun initPoolsBeforeTest() {
+ DefaultScheduler.usePrivateScheduler()
+}
+
+@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
+fun shutdownPoolsAfterTest() {
+ DefaultScheduler.shutdown(SHUTDOWN_TIMEOUT)
+ DefaultExecutor.shutdownForTests(SHUTDOWN_TIMEOUT)
+ DefaultScheduler.restore()
+}
+
+actual val isNative = false
+
+actual val isBoundByJsTestTimeout = false
+
/*
* We ignore tests that test **real** non-virtualized tests with time on Windows, because
* our CI Windows is virtualized itself (oh, the irony) and its clock resolution is dozens of ms,
* which makes such tests flaky.
*/
-public actual val isJavaAndWindows: Boolean = System.getProperty("os.name")!!.contains("Windows")
+actual val isJavaAndWindows: Boolean = System.getProperty("os.name")!!.contains("Windows")
diff --git a/kotlinx-coroutines-core/jvm/test/Threads.kt b/test-utils/jvm/src/Threads.kt
index a2c24500..956b3348 100644
--- a/kotlinx-coroutines-core/jvm/test/Threads.kt
+++ b/test-utils/jvm/src/Threads.kt
@@ -1,4 +1,7 @@
-package kotlinx.coroutines
+package kotlinx.coroutines.testing
+
+import kotlinx.coroutines.*
+import java.lang.Runnable
private const val WAIT_LOST_THREADS = 10_000L // 10s
private val ignoreLostThreads = mutableSetOf<String>()
@@ -33,6 +36,15 @@ fun List<Thread>.dumpThreads(header: String) {
println("===")
}
+class PoolThread(
+ @JvmField val dispatcher: ExecutorCoroutineDispatcher, // for debugging & tests
+ target: Runnable, name: String
+) : Thread(target, name) {
+ init {
+ isDaemon = true
+ }
+}
+
fun ExecutorCoroutineDispatcher.dumpThreads(header: String) =
currentThreads().filter { it is PoolThread && it.dispatcher == this@dumpThreads }.dumpThreads(header)
diff --git a/test-utils/native/src/TestBase.kt b/test-utils/native/src/TestBase.kt
new file mode 100644
index 00000000..d0e0c1aa
--- /dev/null
+++ b/test-utils/native/src/TestBase.kt
@@ -0,0 +1,63 @@
+package kotlinx.coroutines.testing
+
+import kotlin.test.*
+import kotlinx.coroutines.*
+
+actual val VERBOSE = false
+
+actual typealias NoNative = Ignore
+
+public actual val isStressTest: Boolean = false
+public actual val stressTestMultiplier: Int = 1
+public actual val stressTestMultiplierSqrt: Int = 1
+
+@Suppress("ACTUAL_WITHOUT_EXPECT")
+public actual typealias TestResult = Unit
+
+internal actual fun lastResortReportException(error: Throwable) {
+ println(error)
+}
+
+public actual open class TestBase actual constructor(): OrderedExecutionTestBase(), ErrorCatching by ErrorCatching.Impl() {
+ actual fun println(message: Any?) {
+ kotlin.io.println(message)
+ }
+
+ public actual fun runTest(
+ expected: ((Throwable) -> Boolean)?,
+ unhandled: List<(Throwable) -> Boolean>,
+ block: suspend CoroutineScope.() -> Unit
+ ): TestResult {
+ var exCount = 0
+ var ex: Throwable? = null
+ try {
+ runBlocking(block = block, context = CoroutineExceptionHandler { _, e ->
+ if (e is CancellationException) return@CoroutineExceptionHandler // are ignored
+ exCount++
+ when {
+ exCount > unhandled.size ->
+ error("Too many unhandled exceptions $exCount, expected ${unhandled.size}, got: $e", e)
+ !unhandled[exCount - 1](e) ->
+ error("Unhandled exception was unexpected: $e", e)
+ }
+ })
+ } catch (e: Throwable) {
+ ex = e
+ if (expected != null) {
+ if (!expected(e))
+ error("Unexpected exception: $e", e)
+ } else
+ throw e
+ } finally {
+ if (ex == null && expected != null) error("Exception was expected but none produced")
+ }
+ if (exCount < unhandled.size)
+ error("Too few unhandled exceptions $exCount, expected ${unhandled.size}")
+ }
+}
+
+public actual val isNative = true
+
+public actual val isBoundByJsTestTimeout = false
+
+public actual val isJavaAndWindows: Boolean get() = false
diff --git a/test-utils/wasmJs/src/TestBase.kt b/test-utils/wasmJs/src/TestBase.kt
new file mode 100644
index 00000000..0edd291b
--- /dev/null
+++ b/test-utils/wasmJs/src/TestBase.kt
@@ -0,0 +1,98 @@
+package kotlinx.coroutines.testing
+
+import kotlin.test.*
+import kotlin.js.*
+import kotlinx.coroutines.*
+
+actual val VERBOSE = false
+
+actual typealias NoJs = Ignore
+
+actual val isStressTest: Boolean = false
+actual val stressTestMultiplier: Int = 1
+actual val stressTestMultiplierSqrt: Int = 1
+
+@Suppress("ACTUAL_WITHOUT_EXPECT", "ACTUAL_TYPE_ALIAS_TO_CLASS_WITH_DECLARATION_SITE_VARIANCE")
+actual typealias TestResult = Promise<JsAny?>
+
+internal actual fun lastResortReportException(error: Throwable) {
+ println(error)
+}
+
+actual open class TestBase(
+ private val errorCatching: ErrorCatching.Impl
+): OrderedExecutionTestBase(), ErrorCatching by errorCatching {
+ private var lastTestPromise: Promise<JsAny?>? = null
+
+ actual constructor(): this(errorCatching = ErrorCatching.Impl())
+
+ actual fun println(message: Any?) {
+ kotlin.io.println(message)
+ }
+
+ actual fun runTest(
+ expected: ((Throwable) -> Boolean)?,
+ unhandled: List<(Throwable) -> Boolean>,
+ block: suspend CoroutineScope.() -> Unit
+ ): TestResult {
+ var exCount = 0
+ var ex: Throwable? = null
+ /*
+ * This is an additional sanity check against `runTest` mis-usage on JS.
+ * The only way to write an async test on JS is to return Promise from the test function.
+ * _Just_ launching promise and returning `Unit` won't suffice as the underlying test framework
+ * won't be able to detect an asynchronous failure in a timely manner.
+ * We cannot detect such situations, but we can detect the most common erroneous pattern
+ * in our code base, an attempt to use multiple `runTest` in the same `@Test` method,
+ * which typically is a premise to the same error:
+ * ```
+ * @Test
+ * fun incorrectTestForJs() { // <- promise is not returned
+ * for (parameter in parameters) {
+ * runTest {
+ * runTestForParameter(parameter)
+ * }
+ * }
+ * }
+ * ```
+ */
+ if (lastTestPromise != null) {
+ error("Attempt to run multiple asynchronous test within one @Test method")
+ }
+ val result = GlobalScope.promise(block = block, context = CoroutineExceptionHandler { _, e ->
+ if (e is CancellationException) return@CoroutineExceptionHandler // are ignored
+ exCount++
+ when {
+ exCount > unhandled.size ->
+ error("Too many unhandled exceptions $exCount, expected ${unhandled.size}, got: $e", e)
+ !unhandled[exCount - 1](e) ->
+ error("Unhandled exception was unexpected: $e", e)
+ }
+ }).catch { jsE ->
+ val e = jsE.toThrowableOrNull() ?: error("Unexpected non-Kotlin exception $jsE")
+ ex = e
+ if (expected != null) {
+ if (!expected(e)) {
+ println(e)
+ error("Unexpected exception $e", e)
+ }
+ } else
+ throw e
+ null
+ }.finally {
+ if (ex == null && expected != null) error("Exception was expected but none produced")
+ if (exCount < unhandled.size)
+ error("Too few unhandled exceptions $exCount, expected ${unhandled.size}")
+ errorCatching.close()
+ checkFinishCall()
+ }
+ lastTestPromise = result
+ return result
+ }
+}
+
+actual val isNative = false
+
+actual val isBoundByJsTestTimeout = true
+
+actual val isJavaAndWindows: Boolean get() = false
diff --git a/ui/kotlinx-coroutines-android/android-unit-tests/test/ordered/tests/CustomizedRobolectricTest.kt b/ui/kotlinx-coroutines-android/android-unit-tests/test/ordered/tests/CustomizedRobolectricTest.kt
index 7b609380..69dd0edf 100644
--- a/ui/kotlinx-coroutines-android/android-unit-tests/test/ordered/tests/CustomizedRobolectricTest.kt
+++ b/ui/kotlinx-coroutines-android/android-unit-tests/test/ordered/tests/CustomizedRobolectricTest.kt
@@ -1,5 +1,6 @@
package ordered.tests
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.test.*
import org.junit.Test
diff --git a/ui/kotlinx-coroutines-android/android-unit-tests/test/ordered/tests/FirstMockedMainTest.kt b/ui/kotlinx-coroutines-android/android-unit-tests/test/ordered/tests/FirstMockedMainTest.kt
index 216dcf63..30f1796e 100644
--- a/ui/kotlinx-coroutines-android/android-unit-tests/test/ordered/tests/FirstMockedMainTest.kt
+++ b/ui/kotlinx-coroutines-android/android-unit-tests/test/ordered/tests/FirstMockedMainTest.kt
@@ -1,5 +1,6 @@
package ordered.tests
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import kotlinx.coroutines.test.*
import org.junit.*
diff --git a/ui/kotlinx-coroutines-android/test/AndroidExceptionPreHandlerTest.kt b/ui/kotlinx-coroutines-android/test/AndroidExceptionPreHandlerTest.kt
index c8a829e7..d35d4ff8 100644
--- a/ui/kotlinx-coroutines-android/test/AndroidExceptionPreHandlerTest.kt
+++ b/ui/kotlinx-coroutines-android/test/AndroidExceptionPreHandlerTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.android
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.Test
import org.junit.runner.*
diff --git a/ui/kotlinx-coroutines-android/test/DisabledHandlerTest.kt b/ui/kotlinx-coroutines-android/test/DisabledHandlerTest.kt
index e281c8d1..e5a877e3 100644
--- a/ui/kotlinx-coroutines-android/test/DisabledHandlerTest.kt
+++ b/ui/kotlinx-coroutines-android/test/DisabledHandlerTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.android
+import kotlinx.coroutines.testing.*
import android.os.*
import kotlinx.coroutines.*
import org.junit.*
diff --git a/ui/kotlinx-coroutines-android/test/HandlerDispatcherAsyncTest.kt b/ui/kotlinx-coroutines-android/test/HandlerDispatcherAsyncTest.kt
index bf9beb64..ee5bc240 100644
--- a/ui/kotlinx-coroutines-android/test/HandlerDispatcherAsyncTest.kt
+++ b/ui/kotlinx-coroutines-android/test/HandlerDispatcherAsyncTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.android
+import kotlinx.coroutines.testing.*
import android.os.*
import kotlinx.coroutines.*
import org.junit.Test
diff --git a/ui/kotlinx-coroutines-android/test/HandlerDispatcherTest.kt b/ui/kotlinx-coroutines-android/test/HandlerDispatcherTest.kt
index 3526a37a..89f027ad 100644
--- a/ui/kotlinx-coroutines-android/test/HandlerDispatcherTest.kt
+++ b/ui/kotlinx-coroutines-android/test/HandlerDispatcherTest.kt
@@ -1,7 +1,9 @@
package kotlinx.coroutines.android
+import kotlinx.coroutines.testing.*
import android.os.*
import kotlinx.coroutines.*
+import kotlinx.coroutines.testing.*
import org.junit.Test
import org.junit.runner.*
import org.robolectric.*
@@ -9,9 +11,6 @@ import org.robolectric.annotation.*
import org.robolectric.shadows.*
import java.util.concurrent.*
import kotlin.test.*
-import kotlin.time.*
-import kotlin.time.Duration.Companion.milliseconds
-import kotlin.time.Duration.Companion.seconds
@RunWith(RobolectricTestRunner::class)
@LooperMode(LooperMode.Mode.LEGACY)
diff --git a/ui/kotlinx-coroutines-android/test/R8ServiceLoaderOptimizationTest.kt b/ui/kotlinx-coroutines-android/test/R8ServiceLoaderOptimizationTest.kt
index a131e816..c7e24fa8 100644
--- a/ui/kotlinx-coroutines-android/test/R8ServiceLoaderOptimizationTest.kt
+++ b/ui/kotlinx-coroutines-android/test/R8ServiceLoaderOptimizationTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.android
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.jf.dexlib2.*
import org.junit.Test
diff --git a/ui/kotlinx-coroutines-javafx/build.gradle.kts b/ui/kotlinx-coroutines-javafx/build.gradle.kts
index 355da2ac..be99d663 100644
--- a/ui/kotlinx-coroutines-javafx/build.gradle.kts
+++ b/ui/kotlinx-coroutines-javafx/build.gradle.kts
@@ -22,16 +22,8 @@ javafx {
tasks {
test {
extensions.configure(org.javamodularity.moduleplugin.extensions.TestModuleOptions::class) {
- addReads["kotlinx.coroutines.core"] = "junit,kotlin.test"
- addReads["kotlinx.coroutines.javafx"] = "kotlin.test"
+ addReads["kotlinx.coroutines.javafx"] = "kotlin.test,test.utils.jvm"
+ addReads["test.utils.jvm"] = "junit,kotlin.test"
}
- jvmArgs = listOf(
- "--patch-module",
- "kotlinx.coroutines.core=${
- project(":kotlinx-coroutines-core").tasks.named<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>(
- "compileTestKotlinJvm"
- ).get().destinationDirectory.get()
- }"
- )
}
}
diff --git a/ui/kotlinx-coroutines-javafx/test/JavaFxDispatcherTest.kt b/ui/kotlinx-coroutines-javafx/test/JavaFxDispatcherTest.kt
index b3fabaa6..57289cb3 100644
--- a/ui/kotlinx-coroutines-javafx/test/JavaFxDispatcherTest.kt
+++ b/ui/kotlinx-coroutines-javafx/test/JavaFxDispatcherTest.kt
@@ -1,10 +1,10 @@
package kotlinx.coroutines.javafx
+import kotlinx.coroutines.testing.*
import javafx.application.*
import kotlinx.coroutines.*
import org.junit.*
import org.junit.Test
-import javax.swing.*
import kotlin.test.*
class JavaFxDispatcherTest : MainDispatcherTestBase.WithRealTimeDelay() {
diff --git a/ui/kotlinx-coroutines-javafx/test/JavaFxObservableAsFlowTest.kt b/ui/kotlinx-coroutines-javafx/test/JavaFxObservableAsFlowTest.kt
index bc40b0fd..ec210d27 100644
--- a/ui/kotlinx-coroutines-javafx/test/JavaFxObservableAsFlowTest.kt
+++ b/ui/kotlinx-coroutines-javafx/test/JavaFxObservableAsFlowTest.kt
@@ -1,7 +1,8 @@
package kotlinx.coroutines.javafx
+import kotlinx.coroutines.testing.*
import javafx.beans.property.SimpleIntegerProperty
-import kotlinx.coroutines.TestBase
+import kotlinx.coroutines.testing.TestBase
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import org.junit.Before
diff --git a/ui/kotlinx-coroutines-javafx/test/JavaFxStressTest.kt b/ui/kotlinx-coroutines-javafx/test/JavaFxStressTest.kt
index 5338835d..1634f59a 100644
--- a/ui/kotlinx-coroutines-javafx/test/JavaFxStressTest.kt
+++ b/ui/kotlinx-coroutines-javafx/test/JavaFxStressTest.kt
@@ -1,5 +1,6 @@
package kotlinx.coroutines.javafx
+import kotlinx.coroutines.testing.*
import javafx.beans.property.SimpleIntegerProperty
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.first
diff --git a/ui/kotlinx-coroutines-swing/test/SwingTest.kt b/ui/kotlinx-coroutines-swing/test/SwingTest.kt
index dcf33bfa..59808e96 100644
--- a/ui/kotlinx-coroutines-swing/test/SwingTest.kt
+++ b/ui/kotlinx-coroutines-swing/test/SwingTest.kt
@@ -1,10 +1,10 @@
package kotlinx.coroutines.swing
+import kotlinx.coroutines.testing.*
import kotlinx.coroutines.*
import org.junit.*
import org.junit.Test
import javax.swing.*
-import kotlin.coroutines.*
import kotlin.test.*
class SwingTest : MainDispatcherTestBase.WithRealTimeDelay() {