Skip to content

Commit

Permalink
~ Fixup kotlinx-coroutines-rx3 module to internal API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
elizarov committed Jun 16, 2020
1 parent 1ae9e0c commit 8c11a31
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
54 changes: 54 additions & 0 deletions kotlinx-coroutines-core/jvm/test/Scratch.kt
@@ -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()))
}
}
}
2 changes: 1 addition & 1 deletion reactive/kotlinx-coroutines-rx3/src/RxChannel.kt
Expand Up @@ -54,7 +54,7 @@ public suspend inline fun <T> ObservableSource<T>.collect(action: (T) -> Unit):

@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
private class SubscriptionChannel<T> :
LinkedListChannel<T>(), Observer<T>, MaybeObserver<T>
LinkedListChannel<T>(null), Observer<T>, MaybeObserver<T>
{
private val _subscription = atomic<Disposable?>(null)

Expand Down

0 comments on commit 8c11a31

Please sign in to comment.