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 {
83
83
* This is a shorthand for `CoroutineScope(thisScope + context)`.
84
84
*/
85
85
public operator fun CoroutineScope.plus (context : CoroutineContext ): CoroutineScope =
86
- CoroutineScope (context + context)
86
+ CoroutineScope (coroutineContext + context)
87
87
88
88
/* *
89
89
* 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 4
4
5
5
package kotlinx.coroutines.experimental
6
6
7
+ import kotlin.coroutines.experimental.*
7
8
import kotlin.test.*
8
9
9
10
class CoroutineScopeTest : TestBase () {
@@ -191,4 +192,18 @@ class CoroutineScopeTest : TestBase() {
191
192
finish(4 )
192
193
}
193
194
}
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
194
209
}
You can’t perform that action at this time.
0 commit comments