Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Cleanup fx tests #90

Merged
merged 9 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions arrow-fx-test/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
plugins {
id "maven-publish"
id "base"
id "org.jetbrains.kotlin.jvm"
id "org.jetbrains.kotlin.kapt"
Expand All @@ -8,15 +9,11 @@ plugins {
}

apply from: "$SUBPROJECT_CONF"
apply from: "$PUBLISH_CONF"

dependencies {
compile project(":arrow-fx")
compile "io.arrow-kt:arrow-core-test:$VERSION_NAME", excludeArrow
compile "io.arrow-kt:arrow-mtl:$VERSION_NAME", excludeArrow
compile "io.arrow-kt:arrow-mtl-data:$VERSION_NAME", excludeArrow
compile "io.arrow-kt:arrow-free:$VERSION_NAME", excludeArrow
compile "io.arrow-kt:arrow-free-data:$VERSION_NAME", excludeArrow
compile "io.arrow-kt:arrow-recursion-data:$VERSION_NAME", excludeArrow
api "io.arrow-kt:arrow-core-test:$VERSION_NAME", excludeArrow
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$KOTLIN_VERSION"
compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:$KOTLINX_COROUTINES_VERSION"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #93 for the removal of this dependency. This is low priority so not blocking for 0.10.x

testRuntime "org.junit.vintage:junit-vintage-engine:$JUNIT_VINTAGE_VERSION"
Expand Down
25 changes: 0 additions & 25 deletions arrow-fx-test/src/main/kotlin/arrow/test/UnitSpec.kt

This file was deleted.

This file was deleted.

53 changes: 53 additions & 0 deletions arrow-fx-test/src/main/kotlin/arrow/test/eq/EqK.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package arrow.test.eq
danimontoya marked this conversation as resolved.
Show resolved Hide resolved

import arrow.Kind
import arrow.core.extensions.either.eq.eq
import arrow.fx.ForIO
import arrow.fx.IO
import arrow.fx.extensions.io.applicative.applicative
import arrow.fx.extensions.io.applicativeError.attempt
import arrow.fx.extensions.io.concurrent.waitFor
import arrow.fx.fix
import arrow.fx.typeclasses.Duration
import arrow.fx.typeclasses.Fiber
import arrow.fx.typeclasses.FiberOf
import arrow.fx.typeclasses.FiberPartialOf
import arrow.fx.typeclasses.fix
import arrow.fx.typeclasses.seconds
import arrow.typeclasses.Eq
import arrow.typeclasses.EqK

fun <A> IO.Companion.eq(EQA: Eq<A> = Eq.any(), timeout: Duration = 5.seconds): Eq<Kind<ForIO, A>> = Eq { a, b ->
arrow.core.Either.eq(Eq.any(), EQA).run {
IO.applicative().mapN(a.attempt(), b.attempt()) { (a, b) -> a.eqv(b) }
.waitFor(timeout)
.unsafeRunSync()
}
}

fun IO.Companion.eqK() = object : EqK<ForIO> {
override fun <A> Kind<ForIO, A>.eqK(other: Kind<ForIO, A>, EQ: Eq<A>): Boolean = eq(EQ).run {
fix().eqv(other.fix())
}
}

fun <F, A> Fiber.Companion.eq(EQ: Eq<Kind<F, A>>): Eq<FiberOf<F, A>> = object : Eq<FiberOf<F, A>> {
override fun FiberOf<F, A>.eqv(b: FiberOf<F, A>): Boolean = EQ.run {
fix().join().eqv(b.fix().join())
}
}

fun Fiber.Companion.eqK() = object : EqK<FiberPartialOf<ForIO>> {
override fun <A> Kind<FiberPartialOf<ForIO>, A>.eqK(other: Kind<FiberPartialOf<ForIO>, A>, EQ: Eq<A>): Boolean =
IO.eq<A>().run {
fix().join().eqv(other.fix().join())
}
}

/**
* Comparing Throwable is not safe due to their structure (stacktrace),
* so we structurally compare type and message instead.
*/
fun throwableEq() = Eq { a: Throwable, b ->
a::class == b::class && a.message == b.message
}
35 changes: 0 additions & 35 deletions arrow-fx-test/src/main/kotlin/arrow/test/generators/GenK2.kt

This file was deleted.

134 changes: 0 additions & 134 deletions arrow-fx-test/src/main/kotlin/arrow/test/generators/Generators.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package arrow.test.generators

import arrow.Kind
import arrow.fx.ForIO
import arrow.fx.IO
import arrow.fx.typeclasses.Fiber
import arrow.fx.typeclasses.FiberPartialOf
import arrow.typeclasses.Applicative
import arrow.typeclasses.ApplicativeError
import io.kotlintest.properties.Gen
import java.util.concurrent.TimeUnit

fun <F, A, E> Gen<E>.raiseError(AP: ApplicativeError<F, E>): Gen<Kind<F, A>> =
map { AP.raiseError<A>(it) }

fun Gen.Companion.timeUnit(): Gen<TimeUnit> = Gen.from(TimeUnit.values())

fun IO.Companion.genK() = object : GenK<ForIO> {
override fun <A> genK(gen: Gen<A>): Gen<Kind<ForIO, A>> = Gen.oneOf(
gen.map(IO.Companion::just),
Gen.throwable().map(IO.Companion::raiseError)
)
}

fun <F> Fiber.Companion.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))
}
}
63 changes: 0 additions & 63 deletions arrow-fx-test/src/main/kotlin/arrow/test/laws/AlternativeLaws.kt

This file was deleted.

Loading