Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
~ Fixup kotlinx-coroutines-rx3 module to internal API changes
- Loading branch information
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
package kotlinx.coroutines | ||
|
||
import org.junit.* | ||
import kotlin.coroutines.* | ||
|
||
class Scratch : TestBase() { | ||
|
||
@Test | ||
fun test1() = runTest(expected = { it is CancellationException }) { | ||
suspendCancellableCoroutine<Unit> { c -> | ||
c.invokeOnCancellation { | ||
println(it) | ||
} | ||
c.cancel() | ||
} | ||
} | ||
|
||
@Test | ||
fun test2() = runTest(expected = { it is CancellationException }) { | ||
suspendCancellableCoroutine<Unit> { c -> | ||
c.cancel() | ||
c.invokeOnCancellation { | ||
println(it) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun test3() = runTest { | ||
suspendCancellableCoroutine<Unit> { c -> | ||
c.invokeOnCancellation { | ||
println("Invoked") // Printed | ||
} | ||
assertFailsWith<IllegalStateException> { | ||
c.invokeOnCancellation { expectUnreached() } // Triggers ISE | ||
} | ||
c.resume(Unit) | ||
} | ||
} | ||
|
||
@Test | ||
fun test4() = runTest(expected = { it is IllegalStateException }) { | ||
suspendCancellableCoroutine<Unit> { c -> | ||
c.invokeOnCancellation { | ||
println("Invoked") // Not printed | ||
} | ||
c.resumeWith(Result.failure(IllegalStateException())) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters