File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
common/kotlinx-coroutines-core-common Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ public interface CoroutineScope {
8383 * This is a shorthand for `CoroutineScope(thisScope + context)`.
8484 */
8585public operator fun CoroutineScope.plus (context : CoroutineContext ): CoroutineScope =
86- CoroutineScope (context + context)
86+ CoroutineScope (coroutineContext + context)
8787
8888/* *
8989 * Returns `true` when current [Job] is still active (has not completed and was not cancelled yet).
Original file line number Diff line number Diff line change 44
55package kotlinx.coroutines.experimental
66
7+ import kotlin.coroutines.experimental.*
78import kotlin.test.*
89
910class CoroutineScopeTest : TestBase () {
@@ -191,4 +192,18 @@ class CoroutineScopeTest : TestBase() {
191192 finish(4 )
192193 }
193194 }
195+
196+ @Test
197+ fun testScopePlusContext () {
198+ assertSame(EmptyCoroutineContext , scopePlusContext(EmptyCoroutineContext , EmptyCoroutineContext ))
199+ assertSame(Dispatchers .Default , scopePlusContext(EmptyCoroutineContext , Dispatchers .Default ))
200+ assertSame(Dispatchers .Default , scopePlusContext(Dispatchers .Default , EmptyCoroutineContext ))
201+ assertSame(Dispatchers .Default , scopePlusContext(Dispatchers .Default , Dispatchers .Default ))
202+ assertSame(Dispatchers .Default , scopePlusContext(Dispatchers .Unconfined , Dispatchers .Default ))
203+ assertSame(Dispatchers .Unconfined , scopePlusContext(Dispatchers .Default , Dispatchers .Unconfined ))
204+ assertSame(Dispatchers .Unconfined , scopePlusContext(Dispatchers .Unconfined , Dispatchers .Unconfined ))
205+ }
206+
207+ private fun scopePlusContext (c1 : CoroutineContext , c2 : CoroutineContext ) =
208+ (CoroutineScope (c1) + c2).coroutineContext
194209}
You can’t perform that action at this time.
0 commit comments