@@ -247,6 +247,31 @@ class CoroutineScopeTest : TestBase() {
247
247
finish(7 )
248
248
}
249
249
250
+ @Test
251
+ fun testLaunchContainsDefaultDispatcher () = runTest {
252
+ val scopeWithoutDispatcher = CoroutineScope (coroutineContext.minusKey(ContinuationInterceptor ))
253
+ scopeWithoutDispatcher.launch(Dispatchers .Default ) {
254
+ assertSame(Dispatchers .Default , coroutineContext[ContinuationInterceptor ])
255
+ }.join()
256
+ scopeWithoutDispatcher.launch {
257
+ assertSame(Dispatchers .Default , coroutineContext[ContinuationInterceptor ])
258
+ }.join()
259
+ }
260
+
261
+ @Test
262
+ fun testNewCoroutineContextDispatcher () {
263
+ fun newContextDispatcher (c1 : CoroutineContext , c2 : CoroutineContext ) =
264
+ ContextScope (c1).newCoroutineContext(c2)[ContinuationInterceptor ]
265
+
266
+ assertSame(Dispatchers .Default , newContextDispatcher(EmptyCoroutineContext , EmptyCoroutineContext ))
267
+ assertSame(Dispatchers .Default , newContextDispatcher(EmptyCoroutineContext , Dispatchers .Default ))
268
+ assertSame(Dispatchers .Default , newContextDispatcher(Dispatchers .Default , EmptyCoroutineContext ))
269
+ assertSame(Dispatchers .Default , newContextDispatcher(Dispatchers .Default , Dispatchers .Default ))
270
+ assertSame(Dispatchers .Default , newContextDispatcher(Dispatchers .Unconfined , Dispatchers .Default ))
271
+ assertSame(Dispatchers .Unconfined , newContextDispatcher(Dispatchers .Default , Dispatchers .Unconfined ))
272
+ assertSame(Dispatchers .Unconfined , newContextDispatcher(Dispatchers .Unconfined , Dispatchers .Unconfined ))
273
+ }
274
+
250
275
@Test
251
276
fun testScopePlusContext () {
252
277
assertSame(EmptyCoroutineContext , scopePlusContext(EmptyCoroutineContext , EmptyCoroutineContext ))
0 commit comments