Skip to content

Commit 3ba936b

Browse files
committed
Update lincheck tests
1 parent de18150 commit 3ba936b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

kotlinx-coroutines-core/jvm/test/lincheck/ChannelsLincheckTest.kt

+7-7
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ abstract class ChannelLincheckTestBase(
6666
fun trySend(@Param(name = "value") value: Int): Any = c.trySend(value)
6767
.onSuccess { return true }
6868
.onFailure {
69-
if (it is NumberedCancellationException) return it.testResult
70-
else throw it!!
69+
return if (it is NumberedCancellationException) it.testResult
70+
else false
7171
}
7272

7373
// TODO: this operation should be (and can be!) linearizable, but is not
@@ -85,11 +85,11 @@ abstract class ChannelLincheckTestBase(
8585
e.testResult
8686
}
8787

88-
@Operation
88+
// @Operation TODO Lincheck doesn't work with inline classes
8989
fun tryReceive(): Any? =
9090
c.tryReceive()
91-
.onSuccess { it }
92-
.onFailure { if (it is NumberedCancellationException) it.testResult else throw it!! }
91+
.onSuccess { return it }
92+
.onFailure { return if (it is NumberedCancellationException) it.testResult else null }
9393

9494
// TODO: this operation should be (and can be!) linearizable, but is not
9595
// @Operation
@@ -131,15 +131,15 @@ abstract class SequentialIntChannelBase(private val capacity: Int) : VerifierSta
131131
private val buffer = ArrayList<Int>()
132132
private var closedMessage: String? = null
133133

134-
suspend fun send(x: Int): Any = when (val offerRes = offer(x)) {
134+
suspend fun send(x: Int): Any = when (val offerRes = trySend(x)) {
135135
true -> Unit
136136
false -> suspendCancellableCoroutine { cont ->
137137
senders.add(cont to x)
138138
}
139139
else -> offerRes
140140
}
141141

142-
fun offer(element: Int): Any {
142+
fun trySend(element: Int): Any {
143143
if (closedMessage !== null) return closedMessage!!
144144
if (capacity == CONFLATED) {
145145
if (resumeFirstReceiver(element)) return true

0 commit comments

Comments
 (0)