commit | 4cb5d19f337a42a6dc7aa7d19d14248c6bbf01d6 | [log] [tgz] |
---|---|---|
author | Vsevolod Tolstopyatov <qwwdfsad@gmail.com> | Wed Apr 11 17:42:16 2018 +0300 |
committer | Roman Elizarov <elizarov@gmail.com> | Thu Apr 12 13:22:56 2018 +0300 |
tree | 19487df01332ff687d63213c011e3c448d792918 | |
parent | 590c8889c2bb5341f15ee20e440c5599342fe34b [diff] [blame] |
Allow negative timeouts in delay, withTimeout and onTimeout on JVM Fixes #310
diff --git a/common/kotlinx-coroutines-core-common/src/test/kotlin/kotlinx/coroutines/experimental/WithTimeoutTest.kt b/common/kotlinx-coroutines-core-common/src/test/kotlin/kotlinx/coroutines/experimental/WithTimeoutTest.kt index 1aa2368..220a12b 100644 --- a/common/kotlinx-coroutines-core-common/src/test/kotlin/kotlinx/coroutines/experimental/WithTimeoutTest.kt +++ b/common/kotlinx-coroutines-core-common/src/test/kotlin/kotlinx/coroutines/experimental/WithTimeoutTest.kt
@@ -179,5 +179,19 @@ } private class TestException : Exception() + + @Test + fun testNegativeTimeout() = runTest { + expect(1) + try { + withTimeout(-1) { + expectUnreached() + "OK" + } + } catch (e: CancellationException) { + assertEquals("Timed out immediately", e.message) + finish(2) + } + } }