diff options
author | Roman Elizarov <elizarov@gmail.com> | 2019-08-26 19:50:31 +0300 |
---|---|---|
committer | Roman Elizarov <elizarov@gmail.com> | 2019-08-27 10:07:52 +0300 |
commit | a730f2573d7e358ad29817d09d6b1e0b91fe0825 (patch) | |
tree | 35882a78f9ceef528742579080d53592e3dde7eb | |
parent | 5ea2c05211a6ffe5aaf302291311fbc31c278c06 (diff) | |
download | platform_external_kotlinx.coroutines-a730f2573d7e358ad29817d09d6b1e0b91fe0825.tar.gz platform_external_kotlinx.coroutines-a730f2573d7e358ad29817d09d6b1e0b91fe0825.tar.bz2 platform_external_kotlinx.coroutines-a730f2573d7e358ad29817d09d6b1e0b91fe0825.zip |
Ensure that all guide 'main' functions return Unit
-rw-r--r-- | kotlinx-coroutines-core/jvm/test/guide/test/TestUtil.kt | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/kotlinx-coroutines-core/jvm/test/guide/test/TestUtil.kt b/kotlinx-coroutines-core/jvm/test/guide/test/TestUtil.kt index c72b60bd..bd7159fb 100644 --- a/kotlinx-coroutines-core/jvm/test/guide/test/TestUtil.kt +++ b/kotlinx-coroutines-core/jvm/test/guide/test/TestUtil.kt @@ -26,7 +26,7 @@ private const val SHUTDOWN_TIMEOUT = 5000L // 5 sec at most to wait private val OUT_ENABLED = systemProp("guide.tests.sout", false) @Suppress("DEPRECATION") -fun test(name: String, block: () -> Unit): List<String> = outputException(name) { +fun <R> test(name: String, block: () -> R): List<String> = outputException(name) { val sout = System.out val oldOut = if (OUT_ENABLED) System.out else NullOut val oldErr = System.err @@ -45,7 +45,8 @@ fun test(name: String, block: () -> Unit): List<String> = outputException(name) var bytes = ByteArray(0) withVirtualTimeSource(oldOut) { try { - block() + val result = block() + require(result === Unit) { "Test 'main' shall return Unit" } } catch (e: Throwable) { System.err.print("Exception in thread \"main\" ") e.printStackTrace() |