• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package kotlinx.coroutines
2 
3 import kotlinx.coroutines.testing.*
4 import kotlin.test.*
5 
6 class AwaitCancellationTest : TestBase() {
7 
8     @Test
testCancellationnull9     fun testCancellation() = runTest(expected = { it is CancellationException }) {
10         expect(1)
<lambda>null11         coroutineScope {
12             val deferred: Deferred<Nothing> = async {
13                 expect(2)
14                 awaitCancellation()
15             }
16             yield()
17             expect(3)
18             require(deferred.isActive)
19             deferred.cancel()
20             finish(4)
21             deferred.await()
22         }
23     }
24 }
25