1
1
package generic
2
2
3
- import arrow.continuations.generic.ShortCircuit
4
3
import arrow.core.Left
5
4
import arrow.core.Right
6
5
import arrow.core.computations.either
7
- import arrow.fx.coroutines.ComputationPool
8
- import arrow.fx.coroutines.ExitCase
9
- import arrow.fx.coroutines.Promise
10
- import arrow.fx.coroutines.bracketCase
11
6
import io.kotlintest.fail
12
- import io.kotlintest.matchers.types.shouldBeInstanceOf
13
7
import io.kotlintest.shouldBe
14
8
import io.kotlintest.shouldThrow
15
9
import io.kotlintest.specs.StringSpec
@@ -125,26 +119,6 @@ class SuspendingComputationTest : StringSpec({
125
119
} shouldBe Left ("test")
126
120
}
127
121
128
- " Short-circuiting cancels Arrow Fx Coroutines" {
129
- val exit = Promise <ExitCase >()
130
-
131
- either<String , Int > {
132
- val i : Int = bracketCase(
133
- acquire = { Unit },
134
- use = {
135
- Left ("hello").invoke()
136
- },
137
- release = { _ , exitCase -> exit.complete(exitCase) }
138
- )
139
-
140
- 5
141
- } shouldBe Left ("hello")
142
-
143
- exit.get().shouldBeInstanceOf<ExitCase .Failure > {
144
- it.failure.shouldBeInstanceOf<ShortCircuit >()
145
- }
146
- }
147
-
148
122
" Short-circuiting cancels KotlinX Coroutines" {
149
123
val scope = CoroutineScope (Dispatchers .Default )
150
124
val latch = CompletableDeferred <Unit >()
@@ -192,7 +166,7 @@ suspend fun completeOnCancellation(latch: CompletableDeferred<Unit>, cancelled:
192
166
193
167
internal suspend fun Throwable.suspend (): Nothing =
194
168
suspendCoroutineUninterceptedOrReturn { cont ->
195
- suspend { throw this }.startCoroutine(Continuation (ComputationPool ) {
169
+ suspend { throw this }.startCoroutine(Continuation (Dispatchers . Default ) {
196
170
cont.intercepted().resumeWith(it)
197
171
})
198
172
@@ -201,7 +175,7 @@ internal suspend fun Throwable.suspend(): Nothing =
201
175
202
176
internal suspend fun <A > A.suspend (): A =
203
177
suspendCoroutineUninterceptedOrReturn { cont ->
204
- suspend { this }.startCoroutine(Continuation (ComputationPool ) {
178
+ suspend { this }.startCoroutine(Continuation (Dispatchers . Default ) {
205
179
cont.intercepted().resumeWith(it)
206
180
})
207
181
0 commit comments