Vsevolod Tolstopyatov | 993c192 | 2020-10-19 03:01:50 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
| 3 | */ |
| 4 | package kotlinx.coroutines.debug |
| 5 | |
| 6 | import kotlinx.coroutines.* |
| 7 | import org.junit.Test |
| 8 | import kotlin.test.* |
| 9 | |
| 10 | class LazyCoroutineTest : DebugTestBase() { |
| 11 | |
| 12 | @Test |
| 13 | fun testLazyCompletedCoroutine() = runTest { |
| 14 | val job = launch(start = CoroutineStart.LAZY) {} |
| 15 | job.invokeOnCompletion { expect(2) } |
| 16 | expect(1) |
| 17 | job.cancelAndJoin() |
| 18 | expect(3) |
| 19 | assertEquals(1, DebugProbes.dumpCoroutinesInfo().size) // Outer runBlocking |
| 20 | verifyPartialDump(1, "BlockingCoroutine{Active}") |
| 21 | finish(4) |
| 22 | } |
| 23 | } |