Closed github-actions[bot] closed 4 years ago
https://github.com/arrow-kt/arrow-fx/commit/d868a6783dd1dffcf1994bce09c22e6d38a90ad5/checks
diff --cc arrow-fx-kotlinx-coroutines/src/test/kotlin/arrow/integrations/kotlinx/CoroutinesIntegrationTest.kt index 2b2f72e,92e84a4..0000000 --- a/arrow-fx-kotlinx-coroutines/src/test/kotlin/arrow/integrations/kotlinx/CoroutinesIntegrationTest.kt +++ b/arrow-fx-kotlinx-coroutines/src/test/kotlin/arrow/integrations/kotlinx/CoroutinesIntegrationTest.kt @@@ -1,35 -1,29 +1,56 @@@ package arrow.integrations.kotlinx +import arrow.core.Right +import arrow.core.Some import arrow.Kind -import arrow.core.Either -import arrow.core.extensions.either.eq.eq import arrow.core.extensions.eq import arrow.core.internal.AtomicRefW ++<<<<<<< HEAD ++======= + import arrow.core.right + import arrow.core.test.UnitSpec + import arrow.core.test.generators.throwable + import arrow.core.test.laws.equalUnderTheLaw + import arrow.fx.ForIO ++>>>>>>> origin/master import arrow.fx.IO -import arrow.fx.extensions.exitcase.eq.eq +import arrow.fx.IOPartialOf +import arrow.fx.IOResult +import arrow.fx.bracketCase +import arrow.fx.extensions.exitcase2.eq.eq import arrow.fx.extensions.fx ++<<<<<<< HEAD +import arrow.fx.extensions.io.async.effectMap +import arrow.fx.extensions.io.applicative.applicative +import arrow.fx.extensions.io.monad.followedBy +import arrow.fx.extensions.io.concurrent.waitFor +import arrow.fx.fix +import arrow.fx.handleErrorWith +import arrow.fx.flatMap +import arrow.fx.onCancel ++======= + import arrow.fx.extensions.io.applicative.applicative + import arrow.fx.extensions.io.applicativeError.attempt + import arrow.fx.extensions.io.bracket.onCancel + import arrow.fx.extensions.io.concurrent.waitFor + import arrow.fx.fix + import arrow.fx.handleErrorWith ++>>>>>>> origin/master import arrow.fx.typeclasses.Duration -import arrow.fx.typeclasses.ExitCase +import arrow.fx.typeclasses.ExitCase2 import arrow.fx.typeclasses.milliseconds import arrow.fx.typeclasses.seconds ++<<<<<<< HEAD +import arrow.fx.unsafeRunAsync +import arrow.fx.unsafeRunSync +import arrow.test.UnitSpec +import arrow.test.eq +import arrow.test.generators.throwable +import arrow.test.laws.equalUnderTheLaw +import arrow.test.laws.shouldBeEq ++======= + import arrow.fx.test.laws.shouldBeEq ++>>>>>>> origin/master import arrow.typeclasses.Eq import arrow.typeclasses.EqK import io.kotlintest.fail diff --cc arrow-fx-reactor/src/test/kotlin/arrow/fx/FluxKTest.kt index 9d2c29c,918ef45..0000000 --- a/arrow-fx-reactor/src/test/kotlin/arrow/fx/FluxKTest.kt +++ b/arrow-fx-reactor/src/test/kotlin/arrow/fx/FluxKTest.kt @@@ -11,9 -18,8 +14,14 @@@ import arrow.fx.reactor.fi import arrow.fx.reactor.k import arrow.fx.reactor.value import arrow.fx.typeclasses.ExitCase ++<<<<<<< HEAD +import arrow.test.UnitSpec +import arrow.test.generators.GenK +import arrow.test.generators.throwable ++======= + import arrow.fx.test.laws.AsyncLaws + import arrow.fx.test.laws.TimerLaws ++>>>>>>> origin/master import arrow.typeclasses.Eq import arrow.typeclasses.EqK import io.kotlintest.matchers.startWith @@@ -145,6 -152,19 +153,22 @@@ class FluxKTest : UnitSpec() ec shouldBe ExitCase.Cancelled } ++<<<<<<< HEAD ++======= + "FluxK should cancel KindConnection on dispose" { + Promise.uncancellable<ForFluxK, Unit>(FluxK.async()).flatMap { latch -> + FluxK { + FluxK.async<Unit> { conn, _ -> + conn.push(latch.complete(Unit)) + }.flux.subscribe().dispose() + }.flatMap { latch.get() } + }.value() + .test() + .expectNext(Unit) + .expectComplete() + } + ++>>>>>>> origin/master "FluxK async should be cancellable" { Promise.uncancellable<ForFluxK, Unit>(FluxK.async()) .flatMap { latch -> @@@ -160,6 -180,14 +184,17 @@@ .expectNext(Unit) .expectComplete() } ++<<<<<<< HEAD ++======= + + "KindConnection can cancel upstream" { + FluxK.async<Unit> { connection, _ -> + connection.cancel().value().subscribe() + }.value() + .test() + .expectError(ConnectionCancellationException::class) + } ++>>>>>>> origin/master } } diff --cc arrow-fx-reactor/src/test/kotlin/arrow/fx/MonoKTest.kt index a2a3d0b,3973397..0000000 --- a/arrow-fx-reactor/src/test/kotlin/arrow/fx/MonoKTest.kt +++ b/arrow-fx-reactor/src/test/kotlin/arrow/fx/MonoKTest.kt @@@ -13,8 -17,10 +13,15 @@@ import arrow.fx.reactor. import arrow.fx.reactor.unsafeRunSync import arrow.fx.reactor.value import arrow.fx.typeclasses.ExitCase ++<<<<<<< HEAD +import arrow.test.UnitSpec +import arrow.test.generators.GenK ++======= + import arrow.core.test.UnitSpec + import arrow.core.test.generators.GenK + import arrow.fx.test.laws.AsyncLaws + import arrow.fx.test.laws.TimerLaws ++>>>>>>> origin/master import arrow.typeclasses.Eq import arrow.typeclasses.EqK import io.kotlintest.matchers.startWith diff --cc arrow-fx-rx2/src/test/kotlin/arrow/fx/FlowableKTests.kt index d0b8881,45ed133..0000000 --- a/arrow-fx-rx2/src/test/kotlin/arrow/fx/FlowableKTests.kt +++ b/arrow-fx-rx2/src/test/kotlin/arrow/fx/FlowableKTests.kt @@@ -13,7 -26,8 +16,12 @@@ import arrow.fx.rx2.fi import arrow.fx.rx2.k import arrow.fx.rx2.value import arrow.fx.typeclasses.ExitCase ++<<<<<<< HEAD +import arrow.test.generators.GenK ++======= + import arrow.fx.test.laws.AsyncLaws + import arrow.fx.test.laws.ConcurrentLaws ++>>>>>>> origin/master import arrow.typeclasses.Eq import arrow.typeclasses.EqK import io.kotlintest.properties.Gen @@@ -137,14 -151,14 +145,14 @@@ class FlowableKTests : RxJavaSpec() ec shouldBe ExitCase.Cancelled } - "FlowableK should cancel KindConnection on dispose" { + "FlowableK.cancellable should cancel CancelToken on dispose" { Promise.uncancellable<ForFlowableK, Unit>(FlowableK.async()).flatMap { latch -> - FlowableK { - FlowableK.cancellable<Unit>(fa = { - latch.complete(Unit) - }).flowable.subscribe().dispose() - }.flatMap { latch.get() } - }.value() + FlowableK { + FlowableK.cancellable<Unit>(fa = { + latch.complete(Unit) + }).flowable.subscribe().dispose() + }.flatMap { latch.get() } + }.value() .test() .assertValue(Unit) .awaitTerminalEvent(100, TimeUnit.MILLISECONDS) diff --cc arrow-fx-rx2/src/test/kotlin/arrow/fx/MaybeKTests.kt index 82c1534,df8ffc2..0000000 --- a/arrow-fx-rx2/src/test/kotlin/arrow/fx/MaybeKTests.kt +++ b/arrow-fx-rx2/src/test/kotlin/arrow/fx/MaybeKTests.kt @@@ -14,8 -18,9 +14,14 @@@ import arrow.fx.rx2. import arrow.fx.rx2.unsafeRunSync import arrow.fx.rx2.value import arrow.fx.typeclasses.ExitCase ++<<<<<<< HEAD +import arrow.test.generators.GenK +import arrow.test.generators.throwable ++======= + import arrow.core.test.generators.GenK + import arrow.core.test.generators.throwable + import arrow.fx.test.laws.ConcurrentLaws ++>>>>>>> origin/master import arrow.typeclasses.Eq import arrow.typeclasses.EqK import io.kotlintest.properties.Gen diff --cc arrow-fx-rx2/src/test/kotlin/arrow/fx/ObservableKTests.kt index 0daf526,8473e83..0000000 --- a/arrow-fx-rx2/src/test/kotlin/arrow/fx/ObservableKTests.kt +++ b/arrow-fx-rx2/src/test/kotlin/arrow/fx/ObservableKTests.kt @@@ -13,8 -17,9 +13,14 @@@ import arrow.fx.rx2.fi import arrow.fx.rx2.k import arrow.fx.rx2.value import arrow.fx.typeclasses.ExitCase ++<<<<<<< HEAD +import arrow.test.generators.GenK +import arrow.test.generators.throwable ++======= + import arrow.core.test.generators.GenK + import arrow.core.test.generators.throwable + import arrow.fx.test.laws.ConcurrentLaws ++>>>>>>> origin/master import arrow.typeclasses.Eq import arrow.typeclasses.EqK import io.kotlintest.properties.Gen diff --cc arrow-fx-rx2/src/test/kotlin/arrow/fx/SingleKTests.kt index c48d983,907735c..0000000 --- a/arrow-fx-rx2/src/test/kotlin/arrow/fx/SingleKTests.kt +++ b/arrow-fx-rx2/src/test/kotlin/arrow/fx/SingleKTests.kt @@@ -15,9 -19,10 +15,16 @@@ import arrow.fx.rx2. import arrow.fx.rx2.unsafeRunSync import arrow.fx.rx2.value import arrow.fx.typeclasses.ExitCase ++<<<<<<< HEAD +import arrow.test.generators.GenK +import arrow.test.generators.throwable +import arrow.test.laws.forFew ++======= + import arrow.core.test.generators.GenK + import arrow.core.test.generators.throwable + import arrow.fx.test.laws.ConcurrentLaws + import arrow.fx.test.laws.forFew ++>>>>>>> origin/master import arrow.typeclasses.Eq import arrow.typeclasses.EqK import io.kotlintest.properties.Gen diff --cc arrow-fx/src/test/kotlin/arrow/fx/EffectsSuspendDSLTests.kt index 676ce1c,d2d72c0..0000000 --- a/arrow-fx/src/test/kotlin/arrow/fx/EffectsSuspendDSLTests.kt +++ b/arrow-fx/src/test/kotlin/arrow/fx/EffectsSuspendDSLTests.kt @@@ -5,17 -4,15 +5,20 @@@ import arrow.core.Eithe import arrow.core.Left import arrow.core.Right import arrow.core.Tuple2 - import arrow.core.internal.AtomicIntW import arrow.core.identity ++<<<<<<< HEAD +import arrow.fx.IO.Companion.effect ++======= + import arrow.core.internal.AtomicIntW + import arrow.core.test.UnitSpec ++>>>>>>> origin/master import arrow.fx.extensions.fx import arrow.fx.extensions.io.concurrent.concurrent -import arrow.fx.extensions.io.unsafeRun.runBlocking -import arrow.fx.extensions.io.unsafeRun.unsafeRun +import arrow.fx.extensions.io.dispatchers.dispatchers +import arrow.fx.extensions.runBlocking +import arrow.fx.extensions.unsafeRun import arrow.fx.typeclasses.Concurrent import arrow.fx.typeclasses.UnsafeRun - import arrow.test.UnitSpec import arrow.unsafe import io.kotlintest.shouldBe import io.kotlintest.shouldThrow diff --cc arrow-fx/src/test/kotlin/arrow/fx/FiberTest.kt index 0d5702c,3ff04ce..0000000 --- a/arrow-fx/src/test/kotlin/arrow/fx/FiberTest.kt +++ b/arrow-fx/src/test/kotlin/arrow/fx/FiberTest.kt @@@ -23,30 -18,11 +18,36 @@@ import io.kotlintest.properties.Ge class FiberTest : UnitSpec() { init { ++<<<<<<< HEAD + fun EQ(): Eq<FiberOf<IOPartialOf<Nothing>, Int>> = object : Eq<FiberOf<IOPartialOf<Nothing>, Int>> { + override fun FiberOf<IOPartialOf<Nothing>, Int>.eqv(b: FiberOf<IOPartialOf<Nothing>, Int>): Boolean = EQ<Nothing, Int>().run { + fix().join().eqv(b.fix().join()) + } + } + + fun EQK() = object : EqK<FiberPartialOf<IOPartialOf<Nothing>>> { + override fun <A> Kind<FiberPartialOf<IOPartialOf<Nothing>>, A>.eqK(other: Kind<FiberPartialOf<IOPartialOf<Nothing>>, A>, EQ: Eq<A>): Boolean = + EQ<Nothing, A>(EQ).run { + this@eqK.fix().join().eqv(other.fix().join()) + } + } + + fun <F> GENK(A: Applicative<F>) = object : GenK<FiberPartialOf<F>> { + override fun <A> genK(gen: Gen<A>): Gen<Kind<FiberPartialOf<F>, A>> = gen.map { + Fiber(A.just(it), A.just(Unit)) + } + } + + testLaws( + ApplicativeLaws.laws<FiberPartialOf<IOPartialOf<Nothing>>>(Fiber.applicative(IO.concurrent()), Fiber.functor(IO.concurrent()), GENK(IO.applicative()), EQK()), + MonoidLaws.laws(Fiber.monoid(IO.concurrent<Nothing>(), Int.monoid()), Gen.int().map { i -> ++======= + testLaws( + ApplicativeLaws.laws(Fiber.applicative(IO.concurrent()), Fiber.functor(IO.concurrent()), Fiber.genK(IO.applicative()), Fiber.eqK()), + MonoidLaws.laws(Fiber.monoid(IO.concurrent(), Int.monoid()), Gen.int().map { i -> ++>>>>>>> origin/master Fiber(IO.just(i), IO.unit) - }, EQ()) + }, Fiber.eq(IO.eq())) ) } } diff --cc arrow-fx/src/test/kotlin/arrow/fx/IOConnectionTests.kt index a28172c,420893f..0000000 --- a/arrow-fx/src/test/kotlin/arrow/fx/IOConnectionTests.kt +++ b/arrow-fx/src/test/kotlin/arrow/fx/IOConnectionTests.kt @@@ -1,15 -1,13 +1,18 @@@ package arrow.fx - import arrow.test.UnitSpec - import arrow.test.laws.shouldBeEq - import arrow.typeclasses.Eq + import arrow.core.test.UnitSpec + import arrow.fx.test.eq.eq + import arrow.fx.test.laws.shouldBeEq import io.kotlintest.shouldBe -class KindConnectionTests : UnitSpec() { +class IOConnectionTests : UnitSpec() { init { ++<<<<<<< HEAD:arrow-fx/src/test/kotlin/arrow/fx/IOConnectionTests.kt + val EQ = IO.eqK<Nothing>().liftEq(Eq.any()) + ++======= ++>>>>>>> origin/master:arrow-fx/src/test/kotlin/arrow/fx/KindConnectionTests.kt "cancellation is only executed once" { var effect = 0 val initial = IO { effect += 1 } diff --cc arrow-fx/src/test/kotlin/arrow/fx/IOTest.kt index 4bc5f19,d9e45ea..0000000 --- a/arrow-fx/src/test/kotlin/arrow/fx/IOTest.kt +++ b/arrow-fx/src/test/kotlin/arrow/fx/IOTest.kt @@@ -9,14 -8,16 +8,21 @@@ import arrow.core.Som import arrow.core.Tuple2 import arrow.core.Tuple3 import arrow.core.Tuple4 +import arrow.core.identity import arrow.core.right ++<<<<<<< HEAD ++======= + import arrow.core.some + import arrow.core.test.UnitSpec + import arrow.core.test.concurrency.SideEffect + import arrow.core.test.laws.SemigroupKLaws ++>>>>>>> origin/master import arrow.fx.IO.Companion.just import arrow.fx.extensions.fx -import arrow.fx.extensions.io.applicative.applicative import arrow.fx.extensions.io.async.async import arrow.fx.extensions.io.concurrent.concurrent +import arrow.fx.extensions.io.concurrent.raceN +import arrow.fx.extensions.io.applicative.applicative import arrow.fx.extensions.io.dispatchers.dispatchers import arrow.fx.extensions.io.functor.functor import arrow.fx.extensions.io.monad.flatMap @@@ -25,20 -26,14 +31,15 @@@ import arrow.fx.extensions.io.monad.mon import arrow.fx.extensions.io.semigroupK.semigroupK import arrow.fx.extensions.timer import arrow.fx.extensions.toIO +import arrow.fx.extensions.toIOException import arrow.fx.internal.parMap2 import arrow.fx.internal.parMap3 -import arrow.fx.typeclasses.ExitCase +import arrow.fx.typeclasses.ExitCase2 import arrow.fx.typeclasses.milliseconds import arrow.fx.typeclasses.seconds - import arrow.test.UnitSpec - import arrow.test.concurrency.SideEffect - import arrow.test.generators.GenK - import arrow.test.generators.throwable - import arrow.test.laws.ConcurrentLaws - import arrow.test.laws.SemigroupKLaws - import arrow.typeclasses.Eq - import arrow.typeclasses.EqK + import arrow.fx.test.eq.eqK + import arrow.fx.test.generators.genK + import arrow.fx.test.laws.ConcurrentLaws import io.kotlintest.fail import io.kotlintest.properties.Gen import io.kotlintest.properties.forAll @@@ -461,7 -436,7 +462,11 @@@ class IOTest : UnitSpec() IO.parTupledN(all, IO { Thread.currentThread().name }, IO.defer { just(Thread.currentThread().name) }, ++<<<<<<< HEAD + IO.async<Nothing, String> { cb -> cb(IOResult.Success(Thread.currentThread().name)) }, ++======= + IO.async<String> { cb -> cb(Thread.currentThread().name.right()) }, ++>>>>>>> origin/master IO(other) { Thread.currentThread().name }) .unsafeRunSync() @@@ -546,33 -519,33 +551,53 @@@ } "Cancellable should run CancelToken" { ++<<<<<<< HEAD + IO.fx<Unit> { + val p = !Promise<Unit>() + IO.cancellable<Nothing, Unit> { + p.complete(Unit) + }.unsafeRunAsyncCancellable { } ++======= + Promise.uncancellable<ForIO, Unit>(IO.async()).flatMap { p -> + IO.concurrent().cancellable<Unit> { + p.complete(Unit) + }.fix() + .unsafeRunAsyncCancellable { } ++>>>>>>> origin/master .invoke() - p.get() + !p.get() }.unsafeRunSync() shouldBe Unit } "CancellableF should run CancelToken" { ++<<<<<<< HEAD + IO.fx<Unit> { + val p = !Promise<Unit>() + IO.cancellableF<Nothing, Unit> { + IO { p.complete(Unit) } + }.unsafeRunAsyncCancellable { } ++======= + Promise.uncancellable<ForIO, Unit>(IO.async()).flatMap { p -> + IO.concurrent().cancellableF<Unit> { + IO { p.complete(Unit) } + }.fix() + .unsafeRunAsyncCancellable { } ++>>>>>>> origin/master .invoke() - p.get() + !p.get() }.unsafeRunSync() shouldBe Unit } "IO should cancel cancellable on dispose" { - Promise.uncancellable<ForIO, Unit>(IO.async()).flatMap { latch -> + Promise.uncancellable<IOPartialOf<Nothing>, Unit>(IO.async()).flatMap { latch -> IO { ++<<<<<<< HEAD + IO.cancellable<Nothing, Unit> { ++======= + IO.cancellable<Unit> { ++>>>>>>> origin/master latch.complete(Unit) }.unsafeRunAsyncCancellable { } .invoke() @@@ -730,17 -703,3 +755,20 @@@ internal class TestContext : AbstractCo override fun toString(): String = "TestContext(${Integer.toHexString(hashCode())})" } ++<<<<<<< HEAD + +internal fun <E> IO.Companion.eqK() = object : EqK<IOPartialOf<E>> { + override fun <A> Kind<IOPartialOf<E>, A>.eqK(other: Kind<IOPartialOf<E>, A>, EQ: Eq<A>): Boolean = EQ<E, A>(EQ).run { + fix().eqv(other.fix()) + } +} + +internal fun IO.Companion.genK() = object : GenK<IOPartialOf<Nothing>> { + override fun <A> genK(gen: Gen<A>): Gen<Kind<IOPartialOf<Nothing>, A>> = + Gen.oneOf( + gen.map(IO.Companion::just), + Gen.throwable().map { raiseException<A>(it) } + ) +} ++======= ++>>>>>>> origin/master diff --cc arrow-fx/src/test/kotlin/arrow/fx/MVarTest.kt index 1c849d5,60ab6dc..0000000 --- a/arrow-fx/src/test/kotlin/arrow/fx/MVarTest.kt +++ b/arrow-fx/src/test/kotlin/arrow/fx/MVarTest.kt @@@ -8,17 -8,18 +8,18 @@@ import arrow.core.Tuple import arrow.core.Tuple4 import arrow.core.Tuple7 import arrow.core.extensions.eq + import arrow.core.test.UnitSpec + import arrow.core.test.laws.equalUnderTheLaw import arrow.core.toT +import arrow.fx.IO.Companion.effect import arrow.fx.extensions.fx +import arrow.fx.extensions.io.apply.map2 import arrow.fx.extensions.io.async.async import arrow.fx.extensions.io.concurrent.concurrent import arrow.fx.extensions.io.concurrent.parSequence -import arrow.fx.extensions.io.monad.flatMap -import arrow.fx.extensions.io.monad.followedBy import arrow.fx.typeclasses.milliseconds - import arrow.test.UnitSpec - import arrow.test.laws.equalUnderTheLaw - import arrow.test.laws.shouldBeEq + import arrow.fx.test.eq.eq + import arrow.fx.test.laws.shouldBeEq import io.kotlintest.properties.Gen import io.kotlintest.properties.forAll import io.kotlintest.shouldBe @@@ -41,8 -39,8 +42,13 @@@ class MVarTest : UnitSpec() val r1 = av.take().bind() av.put(b).bind() val r2 = av.take().bind() ++<<<<<<< HEAD + !IO.effect { Tuple4(isEmpty, isNotEmpty, r1, r2) shouldBe Tuple4(true, true, a, b) } + }.test() ++======= + Tuple4(isEmpty, isNotEmpty, r1, r2) + }.equalUnderTheLaw(IO.just(Tuple4(true, true, a, b)), IO.eq()) ++>>>>>>> origin/master } } @@@ -58,11 -56,8 +64,16 @@@ val r2 = av.tryTake().bind() av.put(c).bind() val r3 = av.take().bind() ++<<<<<<< HEAD + !IO.effect { + Tuple7(isEmpty, p1, p2, isNotEmpty, r1, r2, r3) shouldBe + Tuple7(true, true, false, true, Some(a), None, c) + } + }.test() ++======= + Tuple7(isEmpty, p1, p2, isNotEmpty, r1, r2, r3) + }.equalUnderTheLaw(IO.just(Tuple7(true, true, false, true, Some(a), None, c)), IO.eq()) ++>>>>>>> origin/master } } @@@ -79,8 -74,8 +90,13 @@@ val aa = f1.join().bind() val bb = f2.join().bind() ++<<<<<<< HEAD + !IO.effect { setOf(aa, bb) shouldBe setOf(10, 20) } + }.test() ++======= + setOf(aa, bb) + }.shouldBeEq(IO.just(setOf(10, 20)), IO.eq()) ++>>>>>>> origin/master } "$label - empty; put; put; put; take; take; take" { @@@ -99,8 -94,8 +115,13 @@@ f2.join().bind() f3.join().bind() ++<<<<<<< HEAD + !IO.effect { setOf(aa, bb, cc) shouldBe setOf(10, 20, 30) } + }.test() ++======= + setOf(aa, bb, cc) + }.shouldBeEq(IO.just(setOf(10, 20, 30)), IO.eq()) ++>>>>>>> origin/master } "$label - empty; take; take; take; put; put; put" { @@@ -119,8 -114,8 +140,13 @@@ val bb = f2.join().bind() val cc = f3.join().bind() ++<<<<<<< HEAD + !IO.effect { setOf(aa, bb, cc) shouldBe setOf(10, 20, 30) } + }.test() ++======= + setOf(aa, bb, cc) + }.shouldBeEq(IO.just(setOf(10, 20, 30)), IO.eq()) ++>>>>>>> origin/master } "$label - initial; isNotEmpty; take; put; take" { @@@ -132,8 -127,8 +158,13 @@@ av.put(b).bind() val r2 = av.take().bind() ++<<<<<<< HEAD + !IO.effect { Tuple3(isNotEmpty, r1, r2) shouldBe Tuple3(true, a, b) } + }.test() ++======= + Tuple3(isNotEmpty, r1, r2) + }.equalUnderTheLaw(IO.just(Tuple3(true, a, b)), IO.eq()) ++>>>>>>> origin/master } } @@@ -156,8 -151,8 +187,13 @@@ val av = mvar.just(i).bind() val read = av.read().bind() val take = av.take().bind() ++<<<<<<< HEAD + !IO.effect { (read toT take) shouldBe (i toT i) } + }.test() ++======= + read toT take + }.equalUnderTheLaw(IO.just(i toT i), IO.eq()) ++>>>>>>> origin/master } } @@@ -245,13 -240,13 +281,13 @@@ val consumerFiber = !consumer(channel, 0L).fork() !producerFiber.join() !consumerFiber.join() - }.shouldBeEq(IO.just(count * (count - 1) / 2), EQ(Long.eq())) + }.shouldBeEq(IO.just(count * (count - 1) / 2), IO.eq(Long.eq())) } - fun testStackSequential(channel: MVar<ForIO, Int>): Tuple3<Int, IO<Int>, IO<Unit>> { + fun testStackSequential(channel: MVar<IOPartialOf<Nothing>, Int>): Tuple3<Int, IO<Nothing, Int>, IO<Nothing, Unit>> { val count = 10000 - fun readLoop(n: Int, acc: Int): IO<Int> = + fun readLoop(n: Int, acc: Int): IO<Nothing, Int> = if (n > 0) channel.read().followedBy(channel.take().flatMap { readLoop(n - 1, acc + 1) }) else IO.just(acc) @@@ -341,9 -336,9 +377,9 @@@ !IO.sleep(100.milliseconds) // Give read callback a chance to register !fiber.cancel() !mVar.put(10) - val fallback = sleep(200.milliseconds).followedBy(IO.just(0)) + val fallback = IO.sleep(200.milliseconds).followedBy(IO.just(0)) !IO.raceN(finished.get(), fallback) - }.shouldBeEq(IO.just(Right(0)), EQ()) + }.shouldBeEq(IO.just(Right(0)), IO.eq()) } } diff --cc arrow-fx/src/test/kotlin/arrow/fx/QueueTest.kt index 5797c3f,040ca5e..0000000 --- a/arrow-fx/src/test/kotlin/arrow/fx/QueueTest.kt +++ b/arrow-fx/src/test/kotlin/arrow/fx/QueueTest.kt @@@ -4,21 -5,17 +5,27 @@@ import arrow.core.Non import arrow.core.Some import arrow.core.Tuple2 import arrow.core.Tuple3 - import arrow.core.Left import arrow.core.extensions.list.traverse.traverse import arrow.core.fix + import arrow.core.test.UnitSpec + import arrow.core.test.generators.nonEmptyList + import arrow.core.test.generators.tuple2 + import arrow.core.test.generators.tuple3 import arrow.fx.extensions.fx +import arrow.fx.extensions.io.apply.mapN import arrow.fx.extensions.io.applicative.applicative import arrow.fx.extensions.io.concurrent.concurrent import arrow.fx.extensions.io.dispatchers.dispatchers +import arrow.fx.extensions.io.monad.map import arrow.fx.typeclasses.milliseconds ++<<<<<<< HEAD +import arrow.test.UnitSpec +import arrow.test.generators.nonEmptyList +import arrow.test.generators.tuple2 +import arrow.test.generators.tuple3 +import arrow.test.laws.equalUnderTheLaw ++======= ++>>>>>>> origin/master import io.kotlintest.fail import io.kotlintest.matchers.types.shouldBeInstanceOf import io.kotlintest.properties.Gen diff --cc arrow-fx/src/test/kotlin/arrow/fx/ResourceTest.kt index 7d54842,b00dfd4..0000000 --- a/arrow-fx/src/test/kotlin/arrow/fx/ResourceTest.kt +++ b/arrow-fx/src/test/kotlin/arrow/fx/ResourceTest.kt @@@ -26,10 -25,10 +26,10 @@@ import io.kotlintest.properties.Ge class ResourceTest : UnitSpec() { init { - val EQ = Resource.eqK().liftEq(Int.eq()) + val EQ: Eq<Kind<Kind<Kind<ForResource, ForIO>, Throwable>, Int>> = Resource.eqK().liftEq(Int.eq()) testLaws( - MonadLaws.laws( + MonadLaws.laws<ResourcePartialOf<IOPartialOf<Nothing>, Throwable>>( Resource.monad(IO.bracket()), Resource.functor(IO.bracket()), Resource.applicative(IO.bracket()), @@@ -53,8 -52,8 +53,13 @@@ } } ++<<<<<<< HEAD +private fun Resource.Companion.eqK() = object : EqK<ResourcePartialOf<IOPartialOf<Nothing>, Throwable>> { + override fun <A> Kind<ResourcePartialOf<IOPartialOf<Nothing>, Throwable>, A>.eqK(other: Kind<ResourcePartialOf<IOPartialOf<Nothing>, Throwable>, A>, EQ: Eq<A>): Boolean = ++======= + fun Resource.Companion.eqK() = object : EqK<ResourcePartialOf<ForIO, Throwable>> { + override fun <A> Kind<ResourcePartialOf<ForIO, Throwable>, A>.eqK(other: Kind<ResourcePartialOf<ForIO, Throwable>, A>, EQ: Eq<A>): Boolean = ++>>>>>>> origin/master (this.fix() to other.fix()).let { val ls = it.first.use(IO.Companion::just).fix().attempt() val rs = it.second.use(IO.Companion::just).fix().attempt() @@@ -64,8 -63,8 +69,13 @@@ } } ++<<<<<<< HEAD +private fun Resource.Companion.genK() = object : GenK<ResourcePartialOf<IOPartialOf<Nothing>, Throwable>> { + override fun <A> genK(gen: Gen<A>): Gen<Kind<ResourcePartialOf<IOPartialOf<Nothing>, Throwable>, A>> { ++======= + fun Resource.Companion.genK() = object : GenK<ResourcePartialOf<ForIO, Throwable>> { + override fun <A> genK(gen: Gen<A>): Gen<Kind<ResourcePartialOf<ForIO, Throwable>, A>> { ++>>>>>>> origin/master val allocate = gen.map { Resource({ IO.just(it) }, { _ -> IO.unit }, IO.bracket()) } return Gen.oneOf( diff --cc arrow-fx/src/test/kotlin/arrow/fx/SemaphoreTest.kt index cfd069d,0512a81..0000000 --- a/arrow-fx/src/test/kotlin/arrow/fx/SemaphoreTest.kt +++ b/arrow-fx/src/test/kotlin/arrow/fx/SemaphoreTest.kt @@@ -135,12 -136,12 +136,19 @@@ class SemaphoreTest : UnitSpec() } tests("UncancellableSemaphore") { Semaphore.uncancellable(it, IO.async()) } - tests("cancellableSemaphore") { Semaphore(it, IO.concurrent()) } - + tests("CancellableSemaphore") { Semaphore(it, IO.concurrent()) } + ++<<<<<<< HEAD + "CancellableSemaphore - supports cancellation of acquire" { + Semaphore(0, IO.concurrent<Nothing>()).flatMap { s -> + s.acquire() + }.unsafeRunAsyncCancellable { } ++======= + "cancellableSemaphore - supports cancellation of acquire" { + Semaphore(0, IO.concurrent()).flatMap { s -> + s.acquire() + }.unsafeRunAsyncCancellable { } ++>>>>>>> origin/master .invoke() } } diff --cc arrow-fx/src/test/kotlin/arrow/fx/predef.kt index 26553b1,e09fef0..0000000 --- a/arrow-fx/src/test/kotlin/arrow/fx/predef.kt +++ b/arrow-fx/src/test/kotlin/arrow/fx/predef.kt @@@ -1,12 -1,5 +1,15 @@@ package arrow.fx ++<<<<<<< HEAD +import arrow.Kind +import arrow.fx.extensions.io.applicative.applicative +import arrow.fx.extensions.io.concurrent.waitFor +import arrow.fx.typeclasses.Duration +import arrow.fx.typeclasses.seconds +import arrow.test.eq +import arrow.typeclasses.Eq ++======= ++>>>>>>> origin/master import kotlinx.atomicfu.atomic import java.util.concurrent.ExecutorService import java.util.concurrent.SynchronousQueue @@@ -14,14 -7,6 +17,17 @@@ import java.util.concurrent.ThreadFacto import java.util.concurrent.ThreadPoolExecutor import java.util.concurrent.TimeUnit ++<<<<<<< HEAD +fun <E, A> EQ(EQA: Eq<A> = Eq.any(), timeout: Duration = 5.seconds): Eq<Kind<IOPartialOf<E>, A>> = Eq { a, b -> + IOResult.eq(Eq.any(), EQA, Eq.any()).run { + IO.applicative<Nothing>().mapN(a.fix().result(), b.fix().result()) { (a, b) -> a.eqv(b) } + .waitFor(timeout) + .unsafeRunSync() + } +} + ++======= ++>>>>>>> origin/master /** * This [ExecutorService] doesn't keep any Thread alive, so the maximumPoolSize should be equal to the # of scheduled tasks. * diff --cc arrow-streams/src/test/kotlin/arrow/streams/internal/FreeCTest.kt index 0d68eb2,42f6c85..0000000 --- a/arrow-streams/src/test/kotlin/arrow/streams/internal/FreeCTest.kt +++ b/arrow-streams/src/test/kotlin/arrow/streams/internal/FreeCTest.kt @@@ -24,16 -21,22 +24,26 @@@ import arrow.core.fi import arrow.core.identity import arrow.core.right import arrow.core.some -import arrow.fx.ForIO -import arrow.fx.IO +import arrow.fx.IOPartialOf +import arrow.fx.unsafeRunSync import arrow.fx.extensions.io.monadError.monadError -import arrow.fx.fix import arrow.higherkind -import arrow.streams.internal.freec.applicative.applicative import arrow.streams.internal.freec.eq.eq -import arrow.streams.internal.freec.functor.functor import arrow.streams.internal.freec.monad.monad ++<<<<<<< HEAD +import arrow.test.UnitSpec +import arrow.test.generators.GenK +import arrow.test.generators.functionAToB +import arrow.test.generators.throwable ++======= + import arrow.streams.internal.freec.monadDefer.monadDefer + import arrow.core.test.UnitSpec + import arrow.core.test.generators.GenK + import arrow.core.test.generators.functionAToB + import arrow.core.test.generators.throwable + import arrow.core.test.laws.EqLaws + import arrow.fx.test.laws.MonadDeferLaws ++>>>>>>> origin/master import arrow.typeclasses.Eq import arrow.typeclasses.EqK import io.kotlintest.properties.Gen * Unmerged path arrow-fx-test/src/main/kotlin/arrow/test/laws/ApplicativeErrorLaws.kt * Unmerged path arrow-fx-test/src/main/kotlin/arrow/test/laws/TraverseLaws.kt
Duplicated #128
Error log
https://github.com/arrow-kt/arrow-fx/commit/d868a6783dd1dffcf1994bce09c22e6d38a90ad5/checks
Conflicts