aboutsummaryrefslogtreecommitdiff
path: root/kotlinx-coroutines-core
diff options
context:
space:
mode:
authorRoman Elizarov <elizarov@gmail.com>2019-08-26 19:50:31 +0300
committerRoman Elizarov <elizarov@gmail.com>2019-08-27 10:07:52 +0300
commita730f2573d7e358ad29817d09d6b1e0b91fe0825 (patch)
tree35882a78f9ceef528742579080d53592e3dde7eb /kotlinx-coroutines-core
parent5ea2c05211a6ffe5aaf302291311fbc31c278c06 (diff)
downloadkotlinx.coroutines-a730f2573d7e358ad29817d09d6b1e0b91fe0825.tar.gz
Ensure that all guide 'main' functions return Unit
Diffstat (limited to 'kotlinx-coroutines-core')
-rw-r--r--kotlinx-coroutines-core/jvm/test/guide/test/TestUtil.kt5
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()