Flatten packages

Remove modules prefix
This commit is contained in:
2020-11-11 22:32:23 +01:00
parent e6a7af840a
commit 8439782430
155 changed files with 51 additions and 33 deletions
+42
View File
@@ -0,0 +1,42 @@
package be.simplenotes.domain.testutils
import arrow.core.Either
import com.natpryce.hamkrest.MatchResult
import com.natpryce.hamkrest.Matcher
fun isLeft() = object : Matcher<Either<*, *>> {
override val description: String
get() = "is Either.Left<>"
override fun invoke(actual: Either<*, *>) = when {
actual.isLeft() -> MatchResult.Match
else -> MatchResult.Mismatch("is Either.Right<>")
}
}
fun isRight() = object : Matcher<Either<*, *>> {
override val description: String
get() = "is Either.Right<>"
override fun invoke(actual: Either<*, *>) = when (actual) {
is Either.Right -> MatchResult.Match
is Either.Left -> {
val valueA = actual.a
MatchResult.Mismatch("is Either.Left<${if (valueA == null) "Null" else valueA::class.simpleName}>")
}
}
}
inline fun <reified A> isLeftOfType() = object : Matcher<Either<*, *>> {
override val description: String
get() = "is Either.Left<${A::class.qualifiedName}>"
override fun invoke(actual: Either<*, *>) = when (actual) {
is Either.Right -> MatchResult.Mismatch("was Either.Right<>")
is Either.Left -> {
val valueA = actual.a
if (valueA is A) MatchResult.Match
else MatchResult.Mismatch("was Left<${if (valueA == null) "Null" else valueA::class.simpleName}>")
}
}
}