5
5
package kotlinx.coroutines.experimental.channels
6
6
7
7
import kotlinx.coroutines.experimental.*
8
+ import kotlin.coroutines.experimental.*
8
9
import kotlin.math.*
9
10
import kotlin.test.*
10
11
@@ -132,7 +133,7 @@ class ChannelsTest: TestBase() {
132
133
133
134
@Test
134
135
fun testMapToSendChannel () = runTest {
135
- val c = produce<Int > {
136
+ val c = produce<Int >(coroutineContext) {
136
137
testList.asReceiveChannel().mapTo(channel) { it + 10 }
137
138
}
138
139
assertEquals(testList.map { it + 10 }, c.toList())
@@ -327,7 +328,7 @@ class ChannelsTest: TestBase() {
327
328
@Test
328
329
fun testFilterToSendChannel () = runTest {
329
330
repeat(3 ) { mod ->
330
- val c = produce<Int > {
331
+ val c = produce<Int >(coroutineContext) {
331
332
testList.asReceiveChannel().filterTo(channel) { it % 2 == mod }
332
333
}
333
334
assertEquals(testList.filter { it % 2 == mod }, c.toList())
@@ -354,7 +355,7 @@ class ChannelsTest: TestBase() {
354
355
@Test
355
356
fun testFilterNotToSendChannel () = runTest {
356
357
repeat(3 ) { mod ->
357
- val c = produce<Int > {
358
+ val c = produce<Int >(coroutineContext) {
358
359
testList.asReceiveChannel().filterNotTo(channel) { it % 2 == mod }
359
360
}
360
361
assertEquals(testList.filterNot { it % 2 == mod }, c.toList())
@@ -381,7 +382,7 @@ class ChannelsTest: TestBase() {
381
382
@Test
382
383
fun testFilterNotNullToSendChannel () = runTest {
383
384
repeat(3 ) { mod ->
384
- val c = produce<Int > {
385
+ val c = produce<Int >(coroutineContext) {
385
386
testList.asReceiveChannel().map { it.takeIf { it % 2 == mod } }.filterNotNullTo(channel)
386
387
}
387
388
assertEquals(testList.map { it.takeIf { it % 2 == mod } }.filterNotNull(), c.toList())
@@ -408,7 +409,7 @@ class ChannelsTest: TestBase() {
408
409
@Test
409
410
fun testFilterIndexedToChannel () = runTest {
410
411
repeat(3 ) { mod ->
411
- val c = produce<Int > {
412
+ val c = produce<Int >(coroutineContext) {
412
413
testList.asReceiveChannel().filterIndexedTo(channel) { index, _ -> index % 2 == mod }
413
414
}
414
415
assertEquals(testList.filterIndexed { index, _ -> index % 2 == mod }, c.toList())
@@ -425,7 +426,7 @@ class ChannelsTest: TestBase() {
425
426
426
427
@Test
427
428
fun testToChannel () = runTest {
428
- val c = produce<Int > {
429
+ val c = produce<Int >(coroutineContext) {
429
430
testList.asReceiveChannel().toChannel(channel)
430
431
}
431
432
assertEquals(testList, c.toList())
@@ -446,7 +447,7 @@ class ChannelsTest: TestBase() {
446
447
447
448
@Test
448
449
fun testMapIndexedToSendChannel () = runTest {
449
- val c = produce<Int > {
450
+ val c = produce<Int >(coroutineContext) {
450
451
testList.asReceiveChannel().mapIndexedTo(channel) { index, i -> index + i }
451
452
}
452
453
assertEquals(testList.mapIndexed { index, i -> index + i }, c.toList())
@@ -472,7 +473,7 @@ class ChannelsTest: TestBase() {
472
473
@Test
473
474
fun testMapNotNullToSendChannel () = runTest {
474
475
repeat(3 ) { mod ->
475
- val c = produce<Int > {
476
+ val c = produce<Int >(coroutineContext) {
476
477
testList.asReceiveChannel().mapNotNullTo(channel) { i -> i.takeIf { i % 2 == mod } }
477
478
}
478
479
assertEquals(testList.mapNotNull { i -> i.takeIf { i % 2 == mod } }, c.toList())
@@ -499,7 +500,7 @@ class ChannelsTest: TestBase() {
499
500
@Test
500
501
fun testMapIndexedNotNullToSendChannel () = runTest {
501
502
repeat(3 ) { mod ->
502
- val c = produce<Int > {
503
+ val c = produce<Int >(coroutineContext) {
503
504
testList.asReceiveChannel().mapIndexedNotNullTo(channel) { index, i -> index.takeIf { i % 2 == mod } }
504
505
}
505
506
assertEquals(testList.mapIndexedNotNull { index, i -> index.takeIf { i % 2 == mod } }, c.toList())
0 commit comments