This repository has been archived by the owner on Feb 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Cleanup fx tests #90
Merged
Merged
Cleanup fx tests #90
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
270736f
draft cleanup fx tests
danimontoya 88b78f2
draft cleanup fx tests
danimontoya 1da81dd
some more cleanup
danimontoya 748a71d
Merge branch 'master' into dm-fx-tests-cleanup
danimontoya 9dd6e98
merge master
danimontoya 61e418f
Rename Generators from fx because somehow Generators from core was co…
danimontoya b0bd5af
Fix imports after renaming arrow.core.test
danimontoya a3384ec
Rename arrow.test to arrow.fx.test in arrow-fx-test module
danimontoya bc5a5c2
Move some eqK genK
danimontoya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
arrow-fx-test/src/main/kotlin/arrow/test/concurrency/SideEffect.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
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
35
arrow-fx-test/src/main/kotlin/arrow/test/generators/GenK2.kt
This file was deleted.
Oops, something went wrong.
134 changes: 0 additions & 134 deletions
134
arrow-fx-test/src/main/kotlin/arrow/test/generators/Generators.kt
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
arrow-fx-test/src/main/kotlin/arrow/test/generators/GeneratorsFx.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,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
63
arrow-fx-test/src/main/kotlin/arrow/test/laws/AlternativeLaws.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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