blob: 1d48dd9e99dc464197e8f0714e5e3c7a149ecddf [file] [log] [blame]
package kotlinx.coroutines.experimental
import org.junit.Test
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
class CoroutineExceptionHandlerTest {
@Test
fun testCoroutineExceptionHandlerCreator() {
val latch = CountDownLatch(1)
var coroutineException: Throwable? = null
val handler = CoroutineExceptionHandler { _, ex ->
coroutineException = ex
latch.countDown()
}
launch(CommonPool + handler) {
throw TestException()
}
latch.await(10, TimeUnit.SECONDS)
check(coroutineException is TestException)
}
}
private class TestException: RuntimeException()