Skip to content

Commit cefc6b9

Browse files
committed
backgroundWorkScope -> backgroundScope
1 parent 6fa024c commit cefc6b9

File tree

6 files changed

+20
-20
lines changed

6 files changed

+20
-20
lines changed

kotlinx-coroutines-test/api/kotlinx-coroutines-test.api

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public final class kotlinx/coroutines/test/TestDispatchers {
105105
}
106106

107107
public abstract interface class kotlinx/coroutines/test/TestScope : kotlinx/coroutines/CoroutineScope {
108-
public abstract fun getBackgroundWorkScope ()Lkotlinx/coroutines/CoroutineScope;
108+
public abstract fun getBackgroundScope ()Lkotlinx/coroutines/CoroutineScope;
109109
public abstract fun getTestScheduler ()Lkotlinx/coroutines/test/TestCoroutineScheduler;
110110
}
111111

kotlinx-coroutines-test/common/src/TestBuilders.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public fun TestScope.runTest(
165165
it.enter()
166166
createTestResult {
167167
runTestCoroutine(it, dispatchTimeoutMs, TestScopeImpl::tryGetCompletionCause, testBody) {
168-
backgroundWorkScope.cancel()
168+
backgroundScope.cancel()
169169
testScheduler.advanceUntilIdleOr { false }
170170
it.leave()
171171
}

kotlinx-coroutines-test/common/src/TestCoroutineScheduler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ internal fun checkSchedulerInContext(scheduler: TestCoroutineScheduler, context:
249249

250250
/**
251251
* A coroutine context key denoting that the work is to be executed in the background.
252-
* @see [TestScope.backgroundWorkScope]
252+
* @see [TestScope.backgroundScope]
253253
*/
254254
internal object BackgroundWork : CoroutineContext.Key<BackgroundWork>, CoroutineContext.Element {
255255
override val key: CoroutineContext.Key<*>

kotlinx-coroutines-test/common/src/TestScope.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public sealed interface TestScope : CoroutineScope {
6262
* the production environment.
6363
*/
6464
@ExperimentalCoroutinesApi
65-
public val backgroundWorkScope: CoroutineScope
65+
public val backgroundScope: CoroutineScope
6666
}
6767

6868
/**
@@ -187,7 +187,7 @@ internal class TestScopeImpl(context: CoroutineContext) :
187187
private val uncaughtExceptions = mutableListOf<Throwable>()
188188
private val lock = SynchronizedObject()
189189

190-
override val backgroundWorkScope: CoroutineScope =
190+
override val backgroundScope: CoroutineScope =
191191
CoroutineScope(coroutineContext + SupervisorJob() + BackgroundWork)
192192

193193
/** Called upon entry to [runTest]. Will throw if called more than once. */

kotlinx-coroutines-test/common/test/TestScopeTest.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,10 @@ class TestScopeTest {
176176
fun testBackgroundWorkBeingRun(): TestResult = runTest {
177177
var i = 0
178178
var j = 0
179-
backgroundWorkScope.launch {
179+
backgroundScope.launch {
180180
++i
181181
}
182-
backgroundWorkScope.launch {
182+
backgroundScope.launch {
183183
delay(10)
184184
++j
185185
}
@@ -205,7 +205,7 @@ class TestScopeTest {
205205
}) {
206206
runTest {
207207
var i = 0
208-
backgroundWorkScope.launch {
208+
backgroundScope.launch {
209209
try {
210210
while (isActive) {
211211
++i
@@ -228,13 +228,13 @@ class TestScopeTest {
228228
fun testBackgroundWorkTimeControl(): TestResult = runTest {
229229
var i = 0
230230
var j = 0
231-
backgroundWorkScope.launch {
231+
backgroundScope.launch {
232232
while (true) {
233233
++i
234234
delay(100)
235235
}
236236
}
237-
backgroundWorkScope.launch {
237+
backgroundScope.launch {
238238
while (true) {
239239
++j
240240
delay(50)
@@ -284,7 +284,7 @@ class TestScopeTest {
284284
}
285285
}) {
286286
runTest {
287-
backgroundWorkScope.launch {
287+
backgroundScope.launch {
288288
throw exception
289289
}
290290
delay(1000)
@@ -311,7 +311,7 @@ class TestScopeTest {
311311
}) {
312312
runTest {
313313
repeat(nTasks) {
314-
backgroundWorkScope.launch {
314+
backgroundScope.launch {
315315
try {
316316
while (true) {
317317
delay(1)
@@ -341,7 +341,7 @@ class TestScopeTest {
341341
delay(1)
342342
}
343343
}
344-
val stateFlow = myFlow.stateIn(backgroundWorkScope, SharingStarted.Eagerly, 0)
344+
val stateFlow = myFlow.stateIn(backgroundScope, SharingStarted.Eagerly, 0)
345345
var j = 0
346346
repeat(100) {
347347
assertEquals(j++, stateFlow.value)
@@ -350,12 +350,12 @@ class TestScopeTest {
350350
}
351351

352352
/**
353-
* A test from the documentation of [TestScope.backgroundWorkScope].
353+
* A test from the documentation of [TestScope.backgroundScope].
354354
*/
355355
@Test
356356
fun testExampleBackgroundJob2() = runTest {
357357
val channel = Channel<Int>()
358-
backgroundWorkScope.launch {
358+
backgroundScope.launch {
359359
var i = 0
360360
while (true) {
361361
channel.send(i++)
@@ -379,12 +379,12 @@ class TestScopeTest {
379379
}
380380
}) {
381381
runTest(dispatchTimeoutMs = 100) {
382-
backgroundWorkScope.launch {
382+
backgroundScope.launch {
383383
while (true) {
384384
yield()
385385
}
386386
}
387-
backgroundWorkScope.launch {
387+
backgroundScope.launch {
388388
while (true) {
389389
delay(1)
390390
}
@@ -407,14 +407,14 @@ class TestScopeTest {
407407
runTest(UnconfinedTestDispatcher(), dispatchTimeoutMs = 100) {
408408
/**
409409
* Having a coroutine like this will still cause the test to hang:
410-
backgroundWorkScope.launch {
410+
backgroundScope.launch {
411411
while (true) {
412412
yield()
413413
}
414414
}
415415
* The reason is that even the initial [advanceUntilIdle] will never return in this case.
416416
*/
417-
backgroundWorkScope.launch {
417+
backgroundScope.launch {
418418
while (true) {
419419
delay(1)
420420
}

kotlinx-coroutines-test/jvm/src/migration/TestBuildersDeprecated.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public fun runBlockingTestOnTestScope(
9292
} catch (e: IllegalStateException) {
9393
null // the deferred was not completed yet; `scope.leave()` should complain then about unfinished jobs
9494
}
95-
scope.backgroundWorkScope.cancel()
95+
scope.backgroundScope.cancel()
9696
scope.testScheduler.advanceUntilIdleOr { false }
9797
throwable?.let {
9898
val exceptions = try {

0 commit comments

Comments
 (0)