-
Notifications
You must be signed in to change notification settings - Fork 449
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
140 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
arrow-libs/core/arrow-autoclose/src/jvmMain/kotlin/arrow/AutoCloseableExtensions.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/ResourceAutoCloseTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package arrow.fx.coroutines | ||
|
||
import arrow.atomic.AtomicBoolean | ||
import io.kotest.assertions.throwables.shouldThrow | ||
import io.kotest.matchers.shouldBe | ||
import io.kotest.property.Arb | ||
import io.kotest.property.checkAll | ||
import kotlinx.coroutines.test.runTest | ||
import kotlin.test.Test | ||
|
||
class ResourceAutoCloseTest { | ||
|
||
class AutoCloseableTest : AutoCloseable { | ||
val didClose = AtomicBoolean(false) | ||
override fun close() = didClose.set(true) | ||
} | ||
|
||
@Test | ||
fun autoCloseableCloses() = runTest { | ||
val t = AutoCloseableTest() | ||
resourceScope { | ||
autoCloseable { t } | ||
} | ||
|
||
t.didClose.get() shouldBe true | ||
} | ||
|
||
@Test | ||
fun autoCloseableClosesOnError() = runTest { | ||
checkAll(10, Arb.throwable()) { throwable -> | ||
val t = AutoCloseableTest() | ||
|
||
shouldThrow<Exception> { | ||
resourceScope { | ||
autoCloseable { t } | ||
throw throwable | ||
} | ||
} shouldBe throwable | ||
|
||
t.didClose.get() shouldBe true | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...w-libs/fx/arrow-fx-coroutines/src/jsMain/kotlin/arrow/fx/coroutines/ResourceExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package arrow.fx.coroutines | ||
|
||
import kotlinx.coroutines.CoroutineDispatcher | ||
import kotlinx.coroutines.Dispatchers | ||
|
||
internal actual val IODispatcher: CoroutineDispatcher = Dispatchers.Main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.