Roman Elizarov | 1f74a2d | 2018-06-29 19:19:45 +0300 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
| 3 | */ |
| 4 | |
Vsevolod Tolstopyatov | 9619134 | 2018-04-20 18:13:33 +0300 | [diff] [blame] | 5 | package kotlinx.coroutines.experimental.channels |
| 6 | |
| 7 | import kotlinx.coroutines.experimental.* |
| 8 | import org.junit.Test |
| 9 | import kotlin.test.* |
| 10 | |
| 11 | class ChannelsJvmTest : TestBase() { |
| 12 | |
| 13 | @Test |
| 14 | fun testBlocking() { |
| 15 | val ch = Channel<Int>() |
| 16 | val sum = async { |
| 17 | ch.sumBy { it } |
| 18 | } |
| 19 | repeat(10) { |
| 20 | ch.sendBlocking(it) |
| 21 | } |
| 22 | ch.close() |
| 23 | assertEquals(45, runBlocking { sum.await() }) |
| 24 | } |
| 25 | } |