Skip to content

Commit 4e8e608

Browse files
committed
Autorefactor the deprecated definitions
1 parent 59a3a60 commit 4e8e608

File tree

52 files changed

+159
-151
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+159
-151
lines changed

integration/kotlinx-coroutines-guava/test/ListenableFutureTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ class ListenableFutureTest : TestBase() {
749749
}
750750
}
751751
future.set(1)
752-
withTimeout(60_000) {
752+
kotlinx.coroutines.time.withTimeout(60_000) {
753753
children.forEach { it.join() }
754754
assertEquals(count, completed.get())
755755
}

kotlinx-coroutines-core/common/test/BuilderContractsTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class BuilderContractsTest : TestBase() {
3434
consume(wctx)
3535

3636
val wt: Int
37-
withTimeout(Long.MAX_VALUE) {
37+
kotlinx.coroutines.time.withTimeout(Long.MAX_VALUE) {
3838
wt = 123
3939
}
4040
consume(wt)

kotlinx-coroutines-core/common/test/CancelledParentAttachTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class CancelledParentAttachTest : TestBase() {
9696
testScope { coroutineScope { } }
9797
testScope { supervisorScope { } }
9898
testScope { flowScope { } }
99-
testScope { withTimeout(Long.MAX_VALUE) { } }
99+
testScope { kotlinx.coroutines.time.withTimeout(Long.MAX_VALUE) { } }
100100
testScope { withContext(Job()) { } }
101101
testScope { withContext(CoroutineName("")) { } }
102102
}

kotlinx-coroutines-core/common/test/ParentCancellationTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class ParentCancellationTest : TestBase() {
9090
@Test
9191
fun testWithTimeoutChild() = runTest {
9292
testParentCancellation(expectParentActive = true, expectRethrows = true, runsInScopeContext = true) { fail ->
93-
withTimeout(1000) { fail() }
93+
kotlinx.coroutines.time.withTimeout(1000) { fail() }
9494
}
9595
}
9696

@@ -168,4 +168,4 @@ class ParentCancellationTest : TestBase() {
168168
}
169169
finish(3)
170170
}
171-
}
171+
}

kotlinx-coroutines-core/common/test/UndispatchedResultTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class UndispatchedResultTest : TestBase() {
2121

2222
@Test
2323
fun testWithTimeout() = runTest {
24-
invokeTest { block -> withTimeout(Long.MAX_VALUE, block) }
24+
invokeTest { block -> kotlinx.coroutines.time.withTimeout(Long.MAX_VALUE, block) }
2525
}
2626

2727
@Test

kotlinx-coroutines-core/common/test/WithTimeoutDurationTest.kt

+12-12
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class WithTimeoutDurationTest : TestBase() {
1818
@Test
1919
fun testBasicNoSuspend() = runTest {
2020
expect(1)
21-
val result = withTimeout(10.seconds) {
21+
val result = kotlinx.coroutines.time.withTimeout(10.seconds) {
2222
expect(2)
2323
"OK"
2424
}
@@ -32,7 +32,7 @@ class WithTimeoutDurationTest : TestBase() {
3232
@Test
3333
fun testBasicSuspend() = runTest {
3434
expect(1)
35-
val result = withTimeout(10.seconds) {
35+
val result = kotlinx.coroutines.time.withTimeout(10.seconds) {
3636
expect(2)
3737
yield()
3838
expect(3)
@@ -55,7 +55,7 @@ class WithTimeoutDurationTest : TestBase() {
5555
}
5656
expect(2)
5757
// test that it does not yield to the above job when started
58-
val result = withTimeout(1.seconds) {
58+
val result = kotlinx.coroutines.time.withTimeout(1.seconds) {
5959
expect(3)
6060
yield() // yield only now
6161
expect(5)
@@ -75,7 +75,7 @@ class WithTimeoutDurationTest : TestBase() {
7575
fun testYieldBlockingWithTimeout() = runTest(
7676
expected = { it is CancellationException }
7777
) {
78-
withTimeout(100.milliseconds) {
78+
kotlinx.coroutines.time.withTimeout(100.milliseconds) {
7979
while (true) {
8080
yield()
8181
}
@@ -88,7 +88,7 @@ class WithTimeoutDurationTest : TestBase() {
8888
@Test
8989
fun testWithTimeoutChildWait() = runTest {
9090
expect(1)
91-
withTimeout(100.milliseconds) {
91+
kotlinx.coroutines.time.withTimeout(100.milliseconds) {
9292
expect(2)
9393
// launch child with timeout
9494
launch {
@@ -103,7 +103,7 @@ class WithTimeoutDurationTest : TestBase() {
103103
@Test
104104
fun testBadClass() = runTest {
105105
val bad = BadClass()
106-
val result = withTimeout(100.milliseconds) {
106+
val result = kotlinx.coroutines.time.withTimeout(100.milliseconds) {
107107
bad
108108
}
109109
assertSame(bad, result)
@@ -119,7 +119,7 @@ class WithTimeoutDurationTest : TestBase() {
119119
fun testExceptionOnTimeout() = runTest {
120120
expect(1)
121121
try {
122-
withTimeout(100.milliseconds) {
122+
kotlinx.coroutines.time.withTimeout(100.milliseconds) {
123123
expect(2)
124124
delay(1000.milliseconds)
125125
expectUnreached()
@@ -136,7 +136,7 @@ class WithTimeoutDurationTest : TestBase() {
136136
expected = { it is CancellationException }
137137
) {
138138
expect(1)
139-
withTimeout(100.milliseconds) {
139+
kotlinx.coroutines.time.withTimeout(100.milliseconds) {
140140
expect(2)
141141
try {
142142
delay(1000.milliseconds)
@@ -152,7 +152,7 @@ class WithTimeoutDurationTest : TestBase() {
152152
fun testSuppressExceptionWithAnotherException() = runTest {
153153
expect(1)
154154
try {
155-
withTimeout(100.milliseconds) {
155+
kotlinx.coroutines.time.withTimeout(100.milliseconds) {
156156
expect(2)
157157
try {
158158
delay(1000.milliseconds)
@@ -173,7 +173,7 @@ class WithTimeoutDurationTest : TestBase() {
173173
fun testNegativeTimeout() = runTest {
174174
expect(1)
175175
try {
176-
withTimeout(-1.milliseconds) {
176+
kotlinx.coroutines.time.withTimeout(-1.milliseconds) {
177177
expectUnreached()
178178
"OK"
179179
}
@@ -188,7 +188,7 @@ class WithTimeoutDurationTest : TestBase() {
188188
expect(1)
189189
try {
190190
expect(2)
191-
withTimeout(1.seconds) {
191+
kotlinx.coroutines.time.withTimeout(1.seconds) {
192192
expect(3)
193193
throw TestException()
194194
}
@@ -201,7 +201,7 @@ class WithTimeoutDurationTest : TestBase() {
201201
@Test
202202
fun testIncompleteWithTimeoutState() = runTest {
203203
lateinit var timeoutJob: Job
204-
val handle = withTimeout(Duration.INFINITE) {
204+
val handle = kotlinx.coroutines.time.withTimeout(Duration.INFINITE) {
205205
timeoutJob = coroutineContext[Job]!!
206206
timeoutJob.invokeOnCompletion { }
207207
}

kotlinx-coroutines-core/common/test/WithTimeoutOrNullDurationTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class WithTimeoutOrNullDurationTest : TestBase() {
105105
expected = { it is CancellationException }
106106
) {
107107
withTimeoutOrNull(1000.milliseconds) {
108-
withTimeout(10.milliseconds) {
108+
kotlinx.coroutines.time.withTimeout(10.milliseconds) {
109109
while (true) {
110110
yield()
111111
}
@@ -120,7 +120,7 @@ class WithTimeoutOrNullDurationTest : TestBase() {
120120
fun testNestedTimeout() = runTest(expected = { it is TimeoutCancellationException }) {
121121
withTimeoutOrNull(Duration.INFINITE) {
122122
// Exception from this withTimeout is not suppressed by withTimeoutOrNull
123-
withTimeout(10.milliseconds) {
123+
kotlinx.coroutines.time.withTimeout(10.milliseconds) {
124124
delay(Duration.INFINITE)
125125
1
126126
}

kotlinx-coroutines-core/common/test/WithTimeoutOrNullTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class WithTimeoutOrNullTest : TestBase() {
102102
expected = { it is CancellationException }
103103
) {
104104
withTimeoutOrNull(1000) {
105-
withTimeout(10) {
105+
kotlinx.coroutines.time.withTimeout(10) {
106106
while (true) {
107107
yield()
108108
}
@@ -117,7 +117,7 @@ class WithTimeoutOrNullTest : TestBase() {
117117
fun testNestedTimeout() = runTest(expected = { it is TimeoutCancellationException }) {
118118
withTimeoutOrNull(Long.MAX_VALUE) {
119119
// Exception from this withTimeout is not suppressed by withTimeoutOrNull
120-
withTimeout(10) {
120+
kotlinx.coroutines.time.withTimeout(10) {
121121
delay(Long.MAX_VALUE)
122122
1
123123
}

kotlinx-coroutines-core/common/test/WithTimeoutTest.kt

+12-12
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class WithTimeoutTest : TestBase() {
1616
@Test
1717
fun testBasicNoSuspend() = runTest {
1818
expect(1)
19-
val result = withTimeout(10_000) {
19+
val result = kotlinx.coroutines.time.withTimeout(10_000) {
2020
expect(2)
2121
"OK"
2222
}
@@ -30,7 +30,7 @@ class WithTimeoutTest : TestBase() {
3030
@Test
3131
fun testBasicSuspend() = runTest {
3232
expect(1)
33-
val result = withTimeout(10_000) {
33+
val result = kotlinx.coroutines.time.withTimeout(10_000) {
3434
expect(2)
3535
yield()
3636
expect(3)
@@ -53,7 +53,7 @@ class WithTimeoutTest : TestBase() {
5353
}
5454
expect(2)
5555
// test that it does not yield to the above job when started
56-
val result = withTimeout(1000) {
56+
val result = kotlinx.coroutines.time.withTimeout(1000) {
5757
expect(3)
5858
yield() // yield only now
5959
expect(5)
@@ -73,7 +73,7 @@ class WithTimeoutTest : TestBase() {
7373
fun testYieldBlockingWithTimeout() = runTest(
7474
expected = { it is CancellationException }
7575
) {
76-
withTimeout(100) {
76+
kotlinx.coroutines.time.withTimeout(100) {
7777
while (true) {
7878
yield()
7979
}
@@ -86,7 +86,7 @@ class WithTimeoutTest : TestBase() {
8686
@Test
8787
fun testWithTimeoutChildWait() = runTest {
8888
expect(1)
89-
withTimeout(100) {
89+
kotlinx.coroutines.time.withTimeout(100) {
9090
expect(2)
9191
// launch child with timeout
9292
launch {
@@ -101,7 +101,7 @@ class WithTimeoutTest : TestBase() {
101101
@Test
102102
fun testBadClass() = runTest {
103103
val bad = BadClass()
104-
val result = withTimeout(100) {
104+
val result = kotlinx.coroutines.time.withTimeout(100) {
105105
bad
106106
}
107107
assertSame(bad, result)
@@ -111,7 +111,7 @@ class WithTimeoutTest : TestBase() {
111111
fun testExceptionOnTimeout() = runTest {
112112
expect(1)
113113
try {
114-
withTimeout(100) {
114+
kotlinx.coroutines.time.withTimeout(100) {
115115
expect(2)
116116
delay(1000)
117117
expectUnreached()
@@ -128,7 +128,7 @@ class WithTimeoutTest : TestBase() {
128128
expected = { it is CancellationException }
129129
) {
130130
expect(1)
131-
withTimeout(100) {
131+
kotlinx.coroutines.time.withTimeout(100) {
132132
expect(2)
133133
try {
134134
delay(1000)
@@ -144,7 +144,7 @@ class WithTimeoutTest : TestBase() {
144144
fun testSuppressExceptionWithAnotherException() = runTest{
145145
expect(1)
146146
try {
147-
withTimeout(100) {
147+
kotlinx.coroutines.time.withTimeout(100) {
148148
expect(2)
149149
try {
150150
delay(1000)
@@ -165,7 +165,7 @@ class WithTimeoutTest : TestBase() {
165165
fun testNegativeTimeout() = runTest {
166166
expect(1)
167167
try {
168-
withTimeout(-1) {
168+
kotlinx.coroutines.time.withTimeout(-1) {
169169
expectUnreached()
170170
"OK"
171171
}
@@ -180,7 +180,7 @@ class WithTimeoutTest : TestBase() {
180180
expect(1)
181181
try {
182182
expect(2)
183-
withTimeout(1000) {
183+
kotlinx.coroutines.time.withTimeout(1000) {
184184
expect(3)
185185
throw TestException()
186186
}
@@ -193,7 +193,7 @@ class WithTimeoutTest : TestBase() {
193193
@Test
194194
fun testIncompleteWithTimeoutState() = runTest {
195195
lateinit var timeoutJob: Job
196-
val handle = withTimeout(Long.MAX_VALUE) {
196+
val handle = kotlinx.coroutines.time.withTimeout(Long.MAX_VALUE) {
197197
timeoutJob = coroutineContext[Job]!!
198198
timeoutJob.invokeOnCompletion { }
199199
}

kotlinx-coroutines-core/common/test/flow/channels/ChannelFlowTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class ChannelFlowTest : TestBase() {
126126
launch {
127127
expect(4)
128128
collect {
129-
withTimeout(-1) {
129+
kotlinx.coroutines.time.withTimeout(-1) {
130130
send(it)
131131
}
132132
expectUnreached()

kotlinx-coroutines-core/common/test/flow/operators/CatchTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class CatchTest : TestBase() {
6161
@Test
6262
fun testWithTimeoutCatch() = runTest {
6363
val flow = flow<Int> {
64-
withTimeout(1) {
64+
kotlinx.coroutines.time.withTimeout(1) {
6565
hang { expect(1) }
6666
}
6767
expectUnreached()

kotlinx-coroutines-core/common/test/flow/operators/FlowOnTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ class FlowOnTest : TestBase() {
239239
val flow = flow {
240240
emit(1)
241241
yield()
242-
withTimeout(-1) {}
242+
kotlinx.coroutines.time.withTimeout(-1) {}
243243
emit(42)
244244
}.flowOn(NamedDispatchers("foo")).onEach {
245245
expect(1)
@@ -255,7 +255,7 @@ class FlowOnTest : TestBase() {
255255
hang { expect(2) }
256256
}.flowOn(NamedDispatchers("foo")).onEach {
257257
expect(1)
258-
withTimeout(-1) {}
258+
kotlinx.coroutines.time.withTimeout(-1) {}
259259
}
260260
assertFailsWith<TimeoutCancellationException>(flow)
261261
finish(3)

kotlinx-coroutines-core/common/test/flow/operators/RetryTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class RetryTest : TestBase() {
7575
val flow = flow {
7676
if (state++ == 0) {
7777
expect(1)
78-
withTimeout(1) {
78+
kotlinx.coroutines.time.withTimeout(1) {
7979
hang { expect(2) }
8080
}
8181
expectUnreached()

kotlinx-coroutines-core/common/test/flow/sharing/ShareInTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ class ShareInTest : TestBase() {
198198
val started: Boolean get() = _started.value
199199
fun start() = check(_started.compareAndSet(expect = false, update = true))
200200
fun stop() = check(_started.compareAndSet(expect = true, update = false))
201-
suspend fun awaitStart() = withTimeout(timeLimit) { _started.first { it } }
202-
suspend fun awaitStop() = withTimeout(timeLimit) { _started.first { !it } }
201+
suspend fun awaitStart() = kotlinx.coroutines.time.withTimeout(timeLimit) { _started.first { it } }
202+
suspend fun awaitStop() = kotlinx.coroutines.time.withTimeout(timeLimit) { _started.first { !it } }
203203
}
204204

205205
private suspend fun FlowState.track(block: suspend () -> Unit) {

kotlinx-coroutines-core/concurrent/test/channels/BroadcastChannelSubStressTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class BroadcastChannelSubStressTest: TestBase() {
5151
check(curSent > prevSent) { "Send stalled at $curSent events" }
5252
prevSent = curSent
5353
}
54-
withTimeout(5000) {
54+
kotlinx.coroutines.time.withTimeout(5000) {
5555
sender.cancelAndJoin()
5656
receiver.cancelAndJoin()
5757
}

kotlinx-coroutines-core/concurrent/test/channels/ConflatedBroadcastChannelNotifyStressTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class ConflatedBroadcastChannelNotifyStressTest : TestBase() {
6060
}
6161
}
6262
try {
63-
withTimeout(timeLimit) {
63+
kotlinx.coroutines.time.withTimeout(timeLimit) {
6464
senders.forEach { it.join() }
6565
broadcast.trySend(nEvents) // last event to signal receivers termination
6666
receivers.forEach { it.join() }

kotlinx-coroutines-core/jvm/test/RejectedExecutionTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class RejectedExecutionTest : TestBase() {
119119
withContext(executor.asCoroutineDispatcher()) {
120120
expect(2)
121121
assertExecutorThread()
122-
withTimeout(1000) {
122+
kotlinx.coroutines.time.withTimeout(1000) {
123123
expect(3) // atomic entry into the block (legacy behavior, it seem to be Ok with way)
124124
assertEquals(true, coroutineContext[Job]?.isCancelled) // but the job is already cancelled
125125
}
@@ -168,4 +168,4 @@ class RejectedExecutionTest : TestBase() {
168168
if (thread !is CoroutineScheduler.Worker) error("Not a thread from Dispatchers.IO: $thread")
169169
assertEquals(CoroutineScheduler.WorkerState.BLOCKING, thread.state)
170170
}
171-
}
171+
}

0 commit comments

Comments
 (0)