From d38c768f14736c99a83ecacb1c4e9c10f5afaaf1 Mon Sep 17 00:00:00 2001 From: Tejas Mate Date: Sat, 4 Nov 2023 15:42:31 +0530 Subject: [PATCH] Update ParZip7Test.kt (#3267) --- .../kotlin/arrow/fx/coroutines/ParZip7Test.kt | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/ParZip7Test.kt b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/ParZip7Test.kt index 90e15fa4d0b..3c4be417dd5 100644 --- a/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/ParZip7Test.kt +++ b/arrow-libs/fx/arrow-fx-coroutines/src/commonTest/kotlin/arrow/fx/coroutines/ParZip7Test.kt @@ -10,7 +10,6 @@ import arrow.fx.coroutines.awaitExitCase import arrow.fx.coroutines.leftException import arrow.fx.coroutines.parZip import arrow.fx.coroutines.throwable -import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.should import io.kotest.matchers.shouldBe import io.kotest.matchers.types.shouldBeTypeOf @@ -24,9 +23,12 @@ import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.async import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.test.runTest +import kotlin.test.Test -class ParZip7Test : StringSpec({ - "parZip 7 runs in parallel" { +class ParZip7Test { + @Test + fun parZip7RunsInParallel() = runTest { checkAll(Arb.int(), Arb.int(), Arb.int(), Arb.int(), Arb.int(), Arb.int(), Arb.int()) { a, b, c, d, e, f, g -> val r = Atomic("") val modifyGate1 = CompletableDeferred() @@ -77,8 +79,9 @@ class ParZip7Test : StringSpec({ r.value shouldBe "$g$f$e$d$c$b$a" } } - - "Cancelling parZip 7 cancels all participants" { + + @Test + fun CancellingParZip7CancelsAllParticipants() = runTest { val s = Channel() val pa = CompletableDeferred() val pb = CompletableDeferred() @@ -113,8 +116,9 @@ class ParZip7Test : StringSpec({ pf.await().shouldBeTypeOf() pg.await().shouldBeTypeOf() } - - "parZip 7 cancels losers if a failure occurs in one of the tasks" { + + @Test + fun parZip7CancelsLosersIfAFailureOccursInOneOfTheTasks() = runTest { checkAll( Arb.throwable(), Arb.element(listOf(1, 2, 3, 4, 5, 6, 7)) @@ -157,8 +161,9 @@ class ParZip7Test : StringSpec({ r should leftException(e) } } - - "parZip CancellationException on right can cancel rest" { + + @Test + fun parZipCancellationExceptionOnRightCanCancelRest() = runTest { checkAll(Arb.string(), Arb.int(1..7)) { msg, cancel -> val s = Channel() val pa = CompletableDeferred() @@ -197,5 +202,4 @@ class ParZip7Test : StringSpec({ pf.await().shouldBeTypeOf() } } - } -) +}