1 /* 2 * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. 3 */ 4 5 package kotlinx.coroutines 6 7 import kotlin.test.* 8 9 class AwaitCancellationTest : TestBase() { 10 11 @Test testCancellationnull12 fun testCancellation() = runTest(expected = { it is CancellationException }) { 13 expect(1) <lambda>null14 coroutineScope { 15 val deferred: Deferred<Nothing> = async { 16 expect(2) 17 awaitCancellation() 18 } 19 yield() 20 expect(3) 21 require(deferred.isActive) 22 deferred.cancel() 23 finish(4) 24 deferred.await() 25 } 26 } 27 } 28