How can I blockingly get all emissions from a chan...
# coroutines
t
How can I blockingly get all emissions from a channel? Consider this block of code:
Copy code
@Test
fun channelEmissionsTest() {
    fun CoroutineScope.produceInts(amount: Int = 10): ReceiveChannel<Int> =
            produce {
                (0..amount).onEach {
                    offer(it)
                }
            }

    GlobalScope.launch(Dispatchers.Unconfined) {
        val list = produceInts().toList()
        assertEquals(11, list.size)
    }
}
Exception in thread "main @coroutine#1" java.lang.AssertionError: expected:<11> but was:<1>