From ba5aefcc031f85bf6858de6ca133155c64671c7f Mon Sep 17 00:00:00 2001 From: i-walker <46971368+i-walker@users.noreply.github.com> Date: Wed, 29 Jun 2022 20:22:18 +0200 Subject: [PATCH 1/4] deprecate arrow-core-test --- .../kotlin/arrow/core/test/Platform.kt | 6 +++ .../kotlin/arrow/core/test/UnitSpec.kt | 22 +++++++++++ .../arrow/core/test/concurrency/SideEffect.kt | 5 +++ .../arrow/core/test/generators/Generators.kt | 39 ++++++++++++++++++- .../arrow/core/test/generators/utils.kt | 3 ++ .../kotlin/arrow/core/test/laws/FxLaws.kt | 6 +++ .../kotlin/arrow/core/test/laws/Law.kt | 3 ++ .../kotlin/arrow/core/test/laws/MonoidLaws.kt | 7 ++++ .../arrow/core/test/laws/SemigroupLaws.kt | 4 ++ .../arrow/core/test/laws/SemiringLaws.kt | 3 ++ .../kotlin/arrow.core/test/Platform-js.kt | 5 +++ .../kotlin/arrow/core/test/Platform-jvm.kt | 5 +++ .../core/test/generators/GeneratorsJvm.kt | 3 ++ .../kotlin/arrow/core/test/Platform-native.kt | 5 +++ .../kotlin/arrow/fx/coroutines/ArrowFxSpec.kt | 2 + .../kotlin/arrow/fx/coroutines/predef-test.kt | 26 +++++++++++++ 16 files changed, 143 insertions(+), 1 deletion(-) diff --git a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/Platform.kt b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/Platform.kt index 4ae1873095f..1818b04830c 100644 --- a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/Platform.kt +++ b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/Platform.kt @@ -1,8 +1,14 @@ package arrow.core.test +import arrow.core.test.concurrency.deprecateArrowTestModules + +@Deprecated(deprecateArrowTestModules) public expect fun isJvm(): Boolean +@Deprecated(deprecateArrowTestModules) public expect fun isJs(): Boolean +@Deprecated(deprecateArrowTestModules) public expect fun isNative(): Boolean +@Deprecated(deprecateArrowTestModules) public fun stackSafeIteration(): Int = if (isJvm()) 500_000 else 1000 diff --git a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/UnitSpec.kt b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/UnitSpec.kt index 3896f9f4580..bb44b0620dc 100644 --- a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/UnitSpec.kt +++ b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/UnitSpec.kt @@ -1,6 +1,7 @@ package arrow.core.test import arrow.core.* +import arrow.core.test.concurrency.deprecateArrowTestModules import arrow.core.test.generators.unit import arrow.core.test.laws.Law import io.kotest.core.names.TestName @@ -22,17 +23,21 @@ import kotlin.math.max /** * Base class for unit tests */ +@Deprecated(deprecateArrowTestModules) public abstract class UnitSpec( public val iterations: Int = 250, public val maxDepth: Int = 15, spec: UnitSpec.() -> Unit = {} ) : StringSpec() { + @Deprecated(deprecateArrowTestModules) public constructor(spec: UnitSpec.() -> Unit) : this(250, 15, spec) + @Deprecated(deprecateArrowTestModules) public fun Arb.Companion.list(gen: Gen, range: IntRange = 0..maxDepth): Arb> = Arb.KList(gen, range) + @Deprecated(deprecateArrowTestModules) public fun Arb.Companion.nonEmptyList(arb: Arb, depth: Int = maxDepth): Arb> { return Arb.list(arb, 1..max(1, depth)) .map { Option.fromNullable(it.toNonEmptyListOrNull()) } @@ -40,13 +45,16 @@ public abstract class UnitSpec( .map { it.value } } + @Deprecated(deprecateArrowTestModules) public fun Arb.Companion.sequence(arbA: Arb, range: IntRange = 0..maxDepth): Arb> = Arb.list(arbA, range).map { it.asSequence() } @JvmOverloads + @Deprecated(deprecateArrowTestModules) public inline fun Arb.Companion.array(gen: Arb, range: IntRange = 0..maxDepth): Arb> = Arb.list(gen, range).map { it.toTypedArray() } + @Deprecated(deprecateArrowTestModules) public fun Arb.Companion.map( keyArb: Arb, valueArb: Arb, @@ -59,6 +67,7 @@ public abstract class UnitSpec( spec() } + @Deprecated(deprecateArrowTestModules) public fun testLaws(vararg laws: List): Unit = laws .flatMap { list: List -> list.asIterable() } .distinctBy { law: Law -> law.name } @@ -68,6 +77,7 @@ public abstract class UnitSpec( } } + @Deprecated(deprecateArrowTestModules) public fun testLaws(prefix: String, vararg laws: List): Unit = laws .flatMap { list: List -> list.asIterable() } .distinctBy { law: Law -> law.name } @@ -77,9 +87,11 @@ public abstract class UnitSpec( } } + @Deprecated(deprecateArrowTestModules) public suspend fun checkAll(property: suspend PropertyContext.() -> Unit): PropertyContext = checkAll(iterations, Arb.unit()) { property() } + @Deprecated(deprecateArrowTestModules) public suspend fun checkAll( genA: Arb, property: suspend PropertyContext.(A) -> Unit @@ -90,6 +102,7 @@ public abstract class UnitSpec( property ) + @Deprecated(deprecateArrowTestModules) public suspend fun checkAll( genA: Arb, genB: Arb, @@ -102,6 +115,7 @@ public abstract class UnitSpec( property ) + @Deprecated(deprecateArrowTestModules) public suspend fun checkAll( genA: Arb, genB: Arb, @@ -116,6 +130,7 @@ public abstract class UnitSpec( property ) + @Deprecated(deprecateArrowTestModules) public suspend fun checkAll( genA: Arb, genB: Arb, @@ -132,6 +147,7 @@ public abstract class UnitSpec( property ) + @Deprecated(deprecateArrowTestModules) public suspend fun checkAll( genA: Arb, genB: Arb, @@ -150,6 +166,7 @@ public abstract class UnitSpec( property ) + @Deprecated(deprecateArrowTestModules) public suspend fun checkAll( genA: Arb, genB: Arb, @@ -170,6 +187,7 @@ public abstract class UnitSpec( property ) + @Deprecated(deprecateArrowTestModules) public suspend fun checkAll( gena: Arb, genb: Arb, @@ -185,6 +203,7 @@ public abstract class UnitSpec( } } + @Deprecated(deprecateArrowTestModules) public suspend fun checkAll( gena: Arb, genb: Arb, @@ -201,6 +220,7 @@ public abstract class UnitSpec( } } + @Deprecated(deprecateArrowTestModules) public suspend fun checkAll( gena: Arb, genb: Arb, @@ -218,6 +238,7 @@ public abstract class UnitSpec( } } + @Deprecated(deprecateArrowTestModules) public suspend fun checkAll( gena: Arb, genb: Arb, @@ -243,6 +264,7 @@ public abstract class UnitSpec( } } + @Deprecated(deprecateArrowTestModules) public suspend fun forFew( iterations: Int, property: suspend PropertyContext.(Unit) -> Unit diff --git a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/concurrency/SideEffect.kt b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/concurrency/SideEffect.kt index 2f528121350..d643af6395e 100644 --- a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/concurrency/SideEffect.kt +++ b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/concurrency/SideEffect.kt @@ -1,7 +1,12 @@ package arrow.core.test.concurrency +@Deprecated(deprecateArrowTestModules) public data class SideEffect(var counter: Int = 0) { + @Deprecated(deprecateArrowTestModules) public fun increment() { counter++ } } + +public const val deprecateArrowTestModules: String = + "arrow test modules are being deprecated in favour of kotest-arrow-extension libraries" diff --git a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/generators/Generators.kt b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/generators/Generators.kt index 31bbd71946b..49c19601228 100644 --- a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/generators/Generators.kt +++ b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/generators/Generators.kt @@ -16,6 +16,7 @@ import arrow.core.Tuple9 import arrow.core.Validated import arrow.core.left import arrow.core.right +import arrow.core.test.concurrency.deprecateArrowTestModules import arrow.core.toOption import io.kotest.property.Arb import io.kotest.property.arbitrary.bind @@ -37,51 +38,65 @@ import io.kotest.property.arbitrary.string import kotlin.Result.Companion.failure import kotlin.Result.Companion.success import kotlin.math.abs - +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.functionAToB(arb: Arb): Arb<(A) -> B> = arb.map { b: B -> { _: A -> b } } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.functionAAToA(arb: Arb): Arb<(A, A) -> A> = arb.map { a: A -> { _: A, _: A -> a } } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.functionBAToB(arb: Arb): Arb<(B, A) -> B> = arb.map { b: B -> { _: B, _: A -> b } } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.functionABToB(arb: Arb): Arb<(A, B) -> B> = arb.map { b: B -> { _: A, _: B -> b } } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.functionToA(arb: Arb): Arb<() -> A> = arb.map { a: A -> { a } } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.throwable(): Arb = Arb.of(listOf(RuntimeException(), NoSuchElementException(), IllegalArgumentException())) +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.result(arbA: Arb): Arb> = Arb.choice(arbA.map(::success), throwable().map(::failure)) +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.doubleSmall(): Arb = Arb.numericDoubles(from = 0.0, to = 100.0) +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.floatSmall(): Arb = Arb.numericFloats(from = 0F, to = 100F) +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.intSmall(factor: Int = 10000): Arb = Arb.int((Int.MIN_VALUE / factor)..(Int.MAX_VALUE / factor)) +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.byteSmall(): Arb = Arb.byte(min = (Byte.MIN_VALUE / 10).toByte(), max = (Byte.MAX_VALUE / 10).toByte()) +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.shortSmall(): Arb { val range = (Short.MIN_VALUE / 1000)..(Short.MAX_VALUE / 1000) return Arb.short().filter { it in range } } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.longSmall(): Arb = Arb.long((Long.MIN_VALUE / 100000L)..(Long.MAX_VALUE / 100000L)) +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.tuple4(arbA: Arb, arbB: Arb, arbC: Arb, arbD: Arb): Arb> = Arb.bind(arbA, arbB, arbC, arbD, ::Tuple4) +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.tuple5( arbA: Arb, arbB: Arb, @@ -91,6 +106,7 @@ public fun Arb.Companion.tuple5( ): Arb> = Arb.bind(arbA, arbB, arbC, arbD, arbE, ::Tuple5) +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.tuple6( arbA: Arb, arbB: Arb, @@ -101,6 +117,7 @@ public fun Arb.Companion.tuple6( ): Arb> = Arb.bind(arbA, arbB, arbC, arbD, arbE, arbF, ::Tuple6) +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.tuple7( arbA: Arb, arbB: Arb, @@ -112,6 +129,7 @@ public fun Arb.Companion.tuple7( ): Arb> = Arb.bind(arbA, arbB, arbC, arbD, arbE, arbF, arbG, ::Tuple7) +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.tuple8( arbA: Arb, arbB: Arb, @@ -129,6 +147,7 @@ public fun Arb.Companion.tuple8( Tuple8(a, b, c, d, e, f, g, h) } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.tuple9( arbA: Arb, arbB: Arb, @@ -147,6 +166,7 @@ public fun Arb.Companion.tuple9( Tuple9(a, b, c, d, e, f, g, h, i) } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.tuple10( arbA: Arb, arbB: Arb, @@ -166,8 +186,10 @@ public fun Arb.Companion.tuple10( Tuple10(a, b, c, d, e, f, g, h, i, j) } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.nonZeroInt(): Arb = Arb.int().filter { it != 0 } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.intPredicate(): Arb<(Int) -> Boolean> = Arb.nonZeroInt().flatMap { num -> val absNum = abs(num) @@ -181,37 +203,48 @@ public fun Arb.Companion.intPredicate(): Arb<(Int) -> Boolean> = ) } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.endo(arb: Arb): Arb> = arb.map { a: A -> Endo { a } } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.option(arb: Arb): Arb> = arb.orNull().map { it.toOption() } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.either(arbE: Arb, arbA: Arb): Arb> { val arbLeft = arbE.map { Either.Left(it) } val arbRight = arbA.map { Either.Right(it) } return Arb.choice(arbLeft, arbRight) } +@Deprecated(deprecateArrowTestModules) public fun Arb.or(arbA: Arb): Arb> = Arb.either(this, arbA) +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.validated(arbE: Arb, arbA: Arb): Arb> = Arb.either(arbE, arbA).map { Validated.fromEither(it) } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.unit(): Arb = Arb.constant(Unit) +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.ior(arbA: Arb, arbB: Arb): Arb> = arbA.alignWith(arbB) { it } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.arbConst(arb: Arb): Arb> = arb.map { Const(it) } +@Deprecated(deprecateArrowTestModules) public fun Arb.eval(): Arb> = map { Eval.now(it) } +@Deprecated(deprecateArrowTestModules) private fun Arb.alignWith(arbB: Arb, transform: (Ior) -> R): Arb = Arb.bind(this, arbB) { a, b -> transform(Ior.Both(a, b)) } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.suspendFunThatReturnsEitherAnyOrAnyOrThrows(): Arb Either> = choice( suspendFunThatReturnsAnyRight(), @@ -219,15 +252,19 @@ public fun Arb.Companion.suspendFunThatReturnsEitherAnyOrAnyOrThrows(): Arb Either> = any().map { suspend { it.right() } } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.suspendFunThatReturnsAnyLeft(): Arb Either> = any().map { suspend { it.left() } } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.suspendFunThatThrows(): Arb Either> = throwable().map { suspend { throw it } } as Arb Either> +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.any(): Arb = choice( Arb.string() as Arb, diff --git a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/generators/utils.kt b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/generators/utils.kt index b6d8f37299e..838fc1004be 100644 --- a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/generators/utils.kt +++ b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/generators/utils.kt @@ -1,5 +1,6 @@ package arrow.core.test.generators +import arrow.core.test.concurrency.deprecateArrowTestModules import kotlin.coroutines.Continuation import kotlin.coroutines.intrinsics.COROUTINE_SUSPENDED import kotlin.coroutines.intrinsics.intercepted @@ -7,6 +8,7 @@ import kotlin.coroutines.intrinsics.suspendCoroutineUninterceptedOrReturn import kotlin.coroutines.startCoroutine import kotlinx.coroutines.Dispatchers +@Deprecated(deprecateArrowTestModules) public suspend fun Throwable.suspend(): Nothing = suspendCoroutineUninterceptedOrReturn { cont -> suspend { throw this }.startCoroutine( @@ -18,6 +20,7 @@ public suspend fun Throwable.suspend(): Nothing = COROUTINE_SUSPENDED } +@Deprecated(deprecateArrowTestModules) public suspend fun A.suspend(): A = suspendCoroutineUninterceptedOrReturn { cont -> suspend { this }.startCoroutine( diff --git a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/FxLaws.kt b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/FxLaws.kt index 203da948cf3..02f311cdee1 100644 --- a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/FxLaws.kt +++ b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/FxLaws.kt @@ -2,6 +2,7 @@ package arrow.core.test.laws import arrow.continuations.Effect import arrow.core.Either +import arrow.core.test.concurrency.deprecateArrowTestModules import arrow.core.test.generators.throwable import io.kotest.assertions.fail import io.kotest.matchers.shouldBe @@ -17,8 +18,10 @@ import kotlin.coroutines.startCoroutine private typealias EagerFxBlock = (suspend Eff.() -> A) -> F private typealias SuspendFxBlock = suspend (suspend Eff.() -> A) -> F +@Deprecated(deprecateArrowTestModules) public object FxLaws { + @Deprecated(deprecateArrowTestModules) public fun , F, A> suspended( pureArb: Arb, G: Arb, @@ -44,6 +47,7 @@ public object FxLaws { } ) + @Deprecated(deprecateArrowTestModules) public fun , F, A> eager( pureArb: Arb, G: Arb, @@ -157,6 +161,7 @@ public object FxLaws { } // TODO expose for tests +@Deprecated(deprecateArrowTestModules) internal suspend fun Throwable.suspend(): Nothing = suspendCoroutineUninterceptedOrReturn { cont -> suspend { throw this }.startCoroutine( @@ -168,6 +173,7 @@ internal suspend fun Throwable.suspend(): Nothing = COROUTINE_SUSPENDED } +@Deprecated(deprecateArrowTestModules) internal suspend fun A.suspend(): A = suspendCoroutineUninterceptedOrReturn { cont -> suspend { this }.startCoroutine( diff --git a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/Law.kt b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/Law.kt index 289c365f035..ab07d42bd01 100644 --- a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/Law.kt +++ b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/Law.kt @@ -1,9 +1,12 @@ package arrow.core.test.laws +import arrow.core.test.concurrency.deprecateArrowTestModules import io.kotest.assertions.fail import io.kotest.core.test.TestContext +@Deprecated(deprecateArrowTestModules) public data class Law(val name: String, val test: suspend TestContext.() -> Unit) +@Deprecated(deprecateArrowTestModules) public fun A.equalUnderTheLaw(b: A, f: (A, A) -> Boolean = { a, b -> a == b }): Boolean = if (f(this, b)) true else fail("Found $this but expected: $b") diff --git a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/MonoidLaws.kt b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/MonoidLaws.kt index 9187f956e65..8d8822e2e37 100644 --- a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/MonoidLaws.kt +++ b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/MonoidLaws.kt @@ -1,5 +1,6 @@ package arrow.core.test.laws +import arrow.core.test.concurrency.deprecateArrowTestModules import arrow.typeclasses.Monoid import io.kotest.property.Arb import io.kotest.property.checkAll @@ -7,8 +8,10 @@ import io.kotest.matchers.shouldBe import io.kotest.property.PropertyContext import io.kotest.property.arbitrary.list +@Deprecated(deprecateArrowTestModules) public object MonoidLaws { + @Deprecated(deprecateArrowTestModules) public fun laws(M: Monoid, GEN: Arb, eq: (F, F) -> Boolean = { a, b -> a == b }): List = SemigroupLaws.laws(M, GEN, eq) + listOf( @@ -18,21 +21,25 @@ public object MonoidLaws { Law("Monoid Laws: combineAll of empty list is empty") { M.combineAllOfEmptyIsEmpty(eq) } ) + @Deprecated(deprecateArrowTestModules) public suspend fun Monoid.monoidLeftIdentity(GEN: Arb, eq: (F, F) -> Boolean): PropertyContext = checkAll(GEN) { a -> (empty().combine(a)).equalUnderTheLaw(a, eq) } + @Deprecated(deprecateArrowTestModules) public suspend fun Monoid.monoidRightIdentity(GEN: Arb, eq: (F, F) -> Boolean): PropertyContext = checkAll(GEN) { a -> a.combine(empty()).equalUnderTheLaw(a, eq) } + @Deprecated(deprecateArrowTestModules) public suspend fun Monoid.combineAllIsDerived(GEN: Arb, eq: (F, F) -> Boolean): PropertyContext = checkAll(5, Arb.list(GEN)) { list -> list.combineAll().equalUnderTheLaw(if (list.isEmpty()) empty() else list.reduce { acc, f -> acc.combine(f) }, eq) } + @Deprecated(deprecateArrowTestModules) public fun Monoid.combineAllOfEmptyIsEmpty(eq: (F, F) -> Boolean): Unit = emptyList().combineAll().equalUnderTheLaw(empty(), eq) shouldBe true } diff --git a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/SemigroupLaws.kt b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/SemigroupLaws.kt index 5b65ac272a0..d031c3f62a3 100644 --- a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/SemigroupLaws.kt +++ b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/SemigroupLaws.kt @@ -1,15 +1,19 @@ package arrow.core.test.laws +import arrow.core.test.concurrency.deprecateArrowTestModules import arrow.typeclasses.Semigroup import io.kotest.property.Arb import io.kotest.property.PropertyContext import io.kotest.property.checkAll +@Deprecated(deprecateArrowTestModules) public object SemigroupLaws { + @Deprecated(deprecateArrowTestModules) public fun laws(SG: Semigroup, G: Arb, eq: (F, F) -> Boolean = { a, b -> a == b }): List = listOf(Law("Semigroup: associativity") { SG.semigroupAssociative(G, eq) }) + @Deprecated(deprecateArrowTestModules) public suspend fun Semigroup.semigroupAssociative(G: Arb, eq: (F, F) -> Boolean): PropertyContext = checkAll(G, G, G) { A, B, C -> A.combine(B).combine(C).equalUnderTheLaw(A.combine(B.combine(C)), eq) diff --git a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/SemiringLaws.kt b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/SemiringLaws.kt index fb548478fe5..0f30f49e64b 100644 --- a/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/SemiringLaws.kt +++ b/arrow-libs/core/arrow-core-test/src/commonMain/kotlin/arrow/core/test/laws/SemiringLaws.kt @@ -1,13 +1,16 @@ package arrow.core.test.laws +import arrow.core.test.concurrency.deprecateArrowTestModules import arrow.typeclasses.Semiring import io.kotest.property.Arb import io.kotest.property.checkAll import io.kotest.matchers.shouldBe import io.kotest.property.PropertyContext +@Deprecated(deprecateArrowTestModules) public object SemiringLaws { + @Deprecated(deprecateArrowTestModules) public fun laws(SG: Semiring, GEN: Arb, eq: (F, F) -> Boolean = { a, b -> a == b }): List = listOf( Law("Semiring: Additive commutativity") { SG.semiringAdditiveCommutativity(GEN, eq) }, diff --git a/arrow-libs/core/arrow-core-test/src/jsMain/kotlin/arrow.core/test/Platform-js.kt b/arrow-libs/core/arrow-core-test/src/jsMain/kotlin/arrow.core/test/Platform-js.kt index 5d040f43a07..64c647e2734 100644 --- a/arrow-libs/core/arrow-core-test/src/jsMain/kotlin/arrow.core/test/Platform-js.kt +++ b/arrow-libs/core/arrow-core-test/src/jsMain/kotlin/arrow.core/test/Platform-js.kt @@ -1,5 +1,10 @@ package arrow.core.test +import arrow.core.test.concurrency.deprecateArrowTestModules + +@Deprecated(deprecateArrowTestModules) public actual fun isJvm(): Boolean = false +@Deprecated(deprecateArrowTestModules) public actual fun isJs(): Boolean = true +@Deprecated(deprecateArrowTestModules) public actual fun isNative(): Boolean = false diff --git a/arrow-libs/core/arrow-core-test/src/jvmMain/kotlin/arrow/core/test/Platform-jvm.kt b/arrow-libs/core/arrow-core-test/src/jvmMain/kotlin/arrow/core/test/Platform-jvm.kt index 817ceaa9042..c5c0ba90ee6 100644 --- a/arrow-libs/core/arrow-core-test/src/jvmMain/kotlin/arrow/core/test/Platform-jvm.kt +++ b/arrow-libs/core/arrow-core-test/src/jvmMain/kotlin/arrow/core/test/Platform-jvm.kt @@ -1,5 +1,10 @@ package arrow.core.test +import arrow.core.test.concurrency.deprecateArrowTestModules + +@Deprecated(deprecateArrowTestModules) public actual fun isJvm(): Boolean = true +@Deprecated(deprecateArrowTestModules) public actual fun isJs(): Boolean = false +@Deprecated(deprecateArrowTestModules) public actual fun isNative(): Boolean = false diff --git a/arrow-libs/core/arrow-core-test/src/jvmMain/kotlin/arrow/core/test/generators/GeneratorsJvm.kt b/arrow-libs/core/arrow-core-test/src/jvmMain/kotlin/arrow/core/test/generators/GeneratorsJvm.kt index e43e06aa708..47242d610c9 100644 --- a/arrow-libs/core/arrow-core-test/src/jvmMain/kotlin/arrow/core/test/generators/GeneratorsJvm.kt +++ b/arrow-libs/core/arrow-core-test/src/jvmMain/kotlin/arrow/core/test/generators/GeneratorsJvm.kt @@ -1,12 +1,15 @@ package arrow.core.test.generators import arrow.core.Either +import arrow.core.test.concurrency.deprecateArrowTestModules import io.kotest.property.Arb import io.kotest.property.arbitrary.map import io.kotest.property.arbitrary.of +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.suspendFunThatThrowsFatalThrowable(): Arb Either> = fatalThrowable().map { suspend { throw it } } as Arb Either> +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.fatalThrowable(): Arb = Arb.of(listOf(ThreadDeath(), StackOverflowError(), OutOfMemoryError(), InterruptedException())) diff --git a/arrow-libs/core/arrow-core-test/src/nativeMain/kotlin/arrow/core/test/Platform-native.kt b/arrow-libs/core/arrow-core-test/src/nativeMain/kotlin/arrow/core/test/Platform-native.kt index 2aa938e99e4..60e4ea88939 100644 --- a/arrow-libs/core/arrow-core-test/src/nativeMain/kotlin/arrow/core/test/Platform-native.kt +++ b/arrow-libs/core/arrow-core-test/src/nativeMain/kotlin/arrow/core/test/Platform-native.kt @@ -1,5 +1,10 @@ package arrow.core.test +import arrow.core.test.concurrency.deprecateArrowTestModules + +@Deprecated(deprecateArrowTestModules) public actual fun isJvm(): Boolean = false +@Deprecated(deprecateArrowTestModules) public actual fun isJs(): Boolean = false +@Deprecated(deprecateArrowTestModules) public actual fun isNative(): Boolean = true diff --git a/arrow-libs/fx/arrow-fx-coroutines-test/src/commonMain/kotlin/arrow/fx/coroutines/ArrowFxSpec.kt b/arrow-libs/fx/arrow-fx-coroutines-test/src/commonMain/kotlin/arrow/fx/coroutines/ArrowFxSpec.kt index 4218ac98879..9c8f8a888d3 100644 --- a/arrow-libs/fx/arrow-fx-coroutines-test/src/commonMain/kotlin/arrow/fx/coroutines/ArrowFxSpec.kt +++ b/arrow-libs/fx/arrow-fx-coroutines-test/src/commonMain/kotlin/arrow/fx/coroutines/ArrowFxSpec.kt @@ -1,8 +1,10 @@ package arrow.fx.coroutines import arrow.core.test.UnitSpec +import arrow.core.test.concurrency.deprecateArrowTestModules /** Simple overwritten Kotest StringSpec (UnitSpec) to reduce stress on tests. */ +@Deprecated(deprecateArrowTestModules) public abstract class ArrowFxSpec( iterations: Int = 250, spec: ArrowFxSpec.() -> Unit = {} diff --git a/arrow-libs/fx/arrow-fx-coroutines-test/src/commonMain/kotlin/arrow/fx/coroutines/predef-test.kt b/arrow-libs/fx/arrow-fx-coroutines-test/src/commonMain/kotlin/arrow/fx/coroutines/predef-test.kt index 5405da2ffea..3e38d073d2b 100644 --- a/arrow-libs/fx/arrow-fx-coroutines-test/src/commonMain/kotlin/arrow/fx/coroutines/predef-test.kt +++ b/arrow-libs/fx/arrow-fx-coroutines-test/src/commonMain/kotlin/arrow/fx/coroutines/predef-test.kt @@ -8,6 +8,7 @@ import arrow.core.invalid import arrow.core.invalidNel import arrow.core.left import arrow.core.right +import arrow.core.test.concurrency.deprecateArrowTestModules import arrow.core.valid import arrow.core.validNel import io.kotest.assertions.fail @@ -42,12 +43,15 @@ import kotlinx.coroutines.flow.buffer import kotlinx.coroutines.flow.channelFlow import kotlinx.coroutines.flow.emptyFlow +@Deprecated(deprecateArrowTestModules) public data class SideEffect(var counter: Int = 0) { + @Deprecated(deprecateArrowTestModules) public fun increment() { counter++ } } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.flow(arbA: Arb): Arb> = Arb.choose( 10 to Arb.list(arbA).map { it.asFlow() }, @@ -55,61 +59,75 @@ public fun Arb.Companion.flow(arbA: Arb): Arb> = 1 to Arb.constant(emptyFlow()), ) +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.throwable(): Arb = Arb.string().map(::RuntimeException) +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.either(left: Arb, right: Arb): Arb> { val failure: Arb> = left.map { l -> l.left() } val success: Arb> = right.map { r -> r.right() } return Arb.choice(failure, success) } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.validated(left: Arb, right: Arb): Arb> { val failure: Arb> = left.map { l -> l.invalid() } val success: Arb> = right.map { r -> r.valid() } return Arb.choice(failure, success) } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.validatedNel(left: Arb, right: Arb): Arb> { val failure: Arb> = left.map { l -> l.invalidNel() } val success: Arb> = right.map { r -> r.validNel() } return Arb.choice(failure, success) } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.intRange(min: Int = Int.MIN_VALUE, max: Int = Int.MAX_VALUE): Arb = Arb.bind(Arb.int(min, max), Arb.int(min, max)) { a, b -> if (a < b) a..b else b..a } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.longRange(min: Long = Long.MIN_VALUE, max: Long = Long.MAX_VALUE): Arb = Arb.bind(Arb.long(min, max), Arb.long(min, max)) { a, b -> if (a < b) a..b else b..a } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.charRange(): Arb = Arb.bind(Arb.char(), Arb.char()) { a, b -> if (a < b) a..b else b..a } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.function(arb: Arb): Arb<() -> O> = arb.map { { it } } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.unit(): Arb = Arb.constant(Unit) +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.functionAToB(arb: Arb): Arb<(A) -> B> = arb.map { b: B -> { _: A -> b } } +@Deprecated(deprecateArrowTestModules) public fun Arb.Companion.nullable(arb: Arb): Arb = Arb.Companion.choice(arb, arb.map { null }) /** Useful for testing success & error scenarios with an `Either` generator **/ +@Deprecated(deprecateArrowTestModules) public fun Either.rethrow(): A = fold({ throw it }, ::identity) +@Deprecated(deprecateArrowTestModules) public fun Result.toEither(): Either = fold({ a -> Either.Right(a) }, { e -> Either.Left(e) }) +@Deprecated(deprecateArrowTestModules) public suspend fun Throwable.suspend(): Nothing = suspendCoroutineUninterceptedOrReturn { cont -> suspend { throw this }.startCoroutine( @@ -121,6 +139,7 @@ public suspend fun Throwable.suspend(): Nothing = COROUTINE_SUSPENDED } +@Deprecated(deprecateArrowTestModules) public suspend fun A.suspend(): A = suspendCoroutineUninterceptedOrReturn { cont -> suspend { this }.startCoroutine( @@ -132,6 +151,7 @@ public suspend fun A.suspend(): A = COROUTINE_SUSPENDED } +@Deprecated(deprecateArrowTestModules) public fun A.suspended(): suspend () -> A = suspend { suspend() } @@ -150,6 +170,7 @@ public fun A.suspended(): suspend () -> A = * * @see Assertions.assertThrows */ +@Deprecated(deprecateArrowTestModules) public inline fun assertThrowable(executable: () -> A): Throwable { val a = try { executable.invoke() @@ -160,6 +181,7 @@ public inline fun assertThrowable(executable: () -> A): Throwable { return if (a is Throwable) a else fail("Expected an exception but found: $a") } +@Deprecated(deprecateArrowTestModules) public suspend fun CoroutineContext.shift(): Unit = suspendCoroutineUninterceptedOrReturn { cont -> suspend { this }.startCoroutine( @@ -171,6 +193,7 @@ public suspend fun CoroutineContext.shift(): Unit = COROUTINE_SUSPENDED } +@Deprecated(deprecateArrowTestModules) public fun leftException(e: Throwable): Matcher> = object : Matcher> { override fun test(value: Either): MatcherResult = @@ -200,6 +223,7 @@ public fun leftException(e: Throwable): Matcher> = } } +@Deprecated(deprecateArrowTestModules) public fun either(e: Either): Matcher> = object : Matcher> { override fun test(value: Either): MatcherResult = @@ -225,12 +249,14 @@ public fun either(e: Either): Matcher> = } } +@Deprecated(deprecateArrowTestModules) public suspend fun awaitExitCase(send: Channel, exit: CompletableDeferred): A = guaranteeCase({ send.receive() awaitCancellation() }) { ex -> exit.complete(ex) } +@Deprecated(deprecateArrowTestModules) public suspend fun awaitExitCase(start: CompletableDeferred, exit: CompletableDeferred): A = guaranteeCase({ start.complete(Unit) From df687bb71bf0dbf209cf9c24639de9b0ef61a45a Mon Sep 17 00:00:00 2001 From: i-walker <46971368+i-walker@users.noreply.github.com> Date: Thu, 30 Jun 2022 15:45:47 +0200 Subject: [PATCH 2/4] deprecate arrow-optics-test --- .../kotlin/arrow/fx/coroutines/predef-test-jvm.kt | 6 ++++++ .../kotlin/arrow/optics/test/laws/IsoLaws.kt | 9 ++++++++- .../kotlin/arrow/optics/test/laws/LensLaws.kt | 10 ++++++++++ .../kotlin/arrow/optics/test/laws/OptionalLaws.kt | 10 ++++++++++ .../kotlin/arrow/optics/test/laws/PrismLaws.kt | 8 ++++++++ .../kotlin/arrow/optics/test/laws/SetterLaws.kt | 7 +++++++ .../kotlin/arrow/optics/test/laws/TraversalLaws.kt | 6 ++++++ 7 files changed, 55 insertions(+), 1 deletion(-) diff --git a/arrow-libs/fx/arrow-fx-coroutines-test/src/jvmMain/kotlin/arrow/fx/coroutines/predef-test-jvm.kt b/arrow-libs/fx/arrow-fx-coroutines-test/src/jvmMain/kotlin/arrow/fx/coroutines/predef-test-jvm.kt index 44c119c1508..bb8480abd1c 100644 --- a/arrow-libs/fx/arrow-fx-coroutines-test/src/jvmMain/kotlin/arrow/fx/coroutines/predef-test-jvm.kt +++ b/arrow-libs/fx/arrow-fx-coroutines-test/src/jvmMain/kotlin/arrow/fx/coroutines/predef-test-jvm.kt @@ -1,15 +1,21 @@ package arrow.fx.coroutines import arrow.core.continuations.AtomicRef +import arrow.core.test.concurrency.deprecateArrowTestModules import java.util.concurrent.ThreadFactory import kotlin.coroutines.CoroutineContext +@Deprecated(deprecateArrowTestModules) public val singleThreadName: String = "single" + +@Deprecated(deprecateArrowTestModules) public val single: Resource = Resource.singleThreadContext(singleThreadName) +@Deprecated(deprecateArrowTestModules) public val threadName: suspend () -> String = { Thread.currentThread().name } +@Deprecated(deprecateArrowTestModules) public class NamedThreadFactory(private val mkName: (Int) -> String) : ThreadFactory { private val count = AtomicRef(0) override fun newThread(r: Runnable): Thread = diff --git a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/IsoLaws.kt b/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/IsoLaws.kt index abbcce8e524..148ea91208a 100644 --- a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/IsoLaws.kt +++ b/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/IsoLaws.kt @@ -2,6 +2,7 @@ package arrow.optics.test.laws import arrow.core.compose import arrow.core.identity +import arrow.core.test.concurrency.deprecateArrowTestModules import arrow.optics.Iso import arrow.core.test.laws.Law import arrow.core.test.laws.equalUnderTheLaw @@ -9,8 +10,9 @@ import io.kotest.property.Arb import io.kotest.property.PropertyContext import io.kotest.property.checkAll -public object IsoLaws { +@Deprecated(deprecateArrowTestModules)public object IsoLaws { + @Deprecated(deprecateArrowTestModules) public fun laws( iso: Iso, aGen: Arb, @@ -27,26 +29,31 @@ public object IsoLaws { Law("Iso Law: consitent set with modify") { iso.consistentSetModify(aGen, bGen, eqa) } ) + @Deprecated(deprecateArrowTestModules) public suspend fun Iso.roundTripOneWay(aGen: Arb, eq: (A, A) -> Boolean): PropertyContext = checkAll(100, aGen) { a -> reverseGet(get(a)).equalUnderTheLaw(a, eq) } + @Deprecated(deprecateArrowTestModules) public suspend fun Iso.roundTripOtherWay(bGen: Arb, eq: (B, B) -> Boolean): PropertyContext = checkAll(100, bGen) { b -> get(reverseGet(b)).equalUnderTheLaw(b, eq) } + @Deprecated(deprecateArrowTestModules) public suspend fun Iso.modifyIdentity(aGen: Arb, eq: (A, A) -> Boolean): PropertyContext = checkAll(100, aGen) { a -> modify(a, ::identity).equalUnderTheLaw(a, eq) } + @Deprecated(deprecateArrowTestModules) public suspend fun Iso.composeModify(aGen: Arb, funcGen: Arb<(B) -> B>, eq: (A, A) -> Boolean): PropertyContext = checkAll(100, aGen, funcGen, funcGen) { a, f, g -> modify(modify(a, f), g).equalUnderTheLaw(modify(a, g compose f), eq) } + @Deprecated(deprecateArrowTestModules) public suspend fun Iso.consistentSetModify(aGen: Arb, bGen: Arb, eq: (A, A) -> Boolean): PropertyContext = checkAll(100, aGen, bGen) { a, b -> set(b).equalUnderTheLaw(modify(a) { b }, eq) diff --git a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/LensLaws.kt b/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/LensLaws.kt index 47565479a7f..a6cd370a787 100644 --- a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/LensLaws.kt +++ b/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/LensLaws.kt @@ -2,6 +2,7 @@ package arrow.optics.test.laws import arrow.core.compose import arrow.core.identity +import arrow.core.test.concurrency.deprecateArrowTestModules import arrow.optics.Lens import arrow.core.test.laws.Law import arrow.core.test.laws.equalUnderTheLaw @@ -10,8 +11,10 @@ import io.kotest.property.PropertyContext import io.kotest.property.arbitrary.constant import io.kotest.property.checkAll +@Deprecated(deprecateArrowTestModules) public object LensLaws { + @Deprecated(deprecateArrowTestModules) public fun laws( lensGen: Arb>, aGen: Arb, @@ -32,6 +35,7 @@ public object LensLaws { /** * Warning: Use only when a `Gen.constant()` applies */ + @Deprecated(deprecateArrowTestModules) public fun laws( lens: Lens, aGen: Arb, @@ -41,6 +45,7 @@ public object LensLaws { eqb: (B, B) -> Boolean = { a, b -> a == b } ): List = laws(Arb.constant(lens), aGen, bGen, funcGen, eqa, eqb) + @Deprecated(deprecateArrowTestModules) public suspend fun lensGetSet(lensGen: Arb>, aGen: Arb, eq: (A, A) -> Boolean): PropertyContext = checkAll(100, lensGen, aGen) { lens, a -> lens.run { @@ -48,6 +53,7 @@ public object LensLaws { } } + @Deprecated(deprecateArrowTestModules) public suspend fun lensSetGet(lensGen: Arb>, aGen: Arb, bGen: Arb, eq: (B, B) -> Boolean): PropertyContext = checkAll(100, lensGen, aGen, bGen) { lens, a, b -> lens.run { @@ -55,6 +61,7 @@ public object LensLaws { } } + @Deprecated(deprecateArrowTestModules) public suspend fun lensSetIdempotent(lensGen: Arb>, aGen: Arb, bGen: Arb, eq: (A, A) -> Boolean): PropertyContext = checkAll(100, lensGen, aGen, bGen) { lens, a, b -> lens.run { @@ -62,6 +69,7 @@ public object LensLaws { } } + @Deprecated(deprecateArrowTestModules) public suspend fun lensModifyIdentity(lensGen: Arb>, aGen: Arb, eq: (A, A) -> Boolean): PropertyContext = checkAll(100, lensGen, aGen) { lens, a -> lens.run { @@ -69,6 +77,7 @@ public object LensLaws { } } + @Deprecated(deprecateArrowTestModules) public suspend fun lensComposeModify(lensGen: Arb>, aGen: Arb, funcGen: Arb<(B) -> B>, eq: (A, A) -> Boolean): PropertyContext = checkAll(100, lensGen, aGen, funcGen, funcGen) { lens, a, f, g -> lens.run { @@ -76,6 +85,7 @@ public object LensLaws { } } + @Deprecated(deprecateArrowTestModules) public suspend fun lensConsistentSetModify(lensGen: Arb>, aGen: Arb, bGen: Arb, eq: (A, A) -> Boolean): PropertyContext = checkAll(100, lensGen, aGen, bGen) { lens, a, b -> lens.run { diff --git a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/OptionalLaws.kt b/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/OptionalLaws.kt index 659e334aee0..f9c455f5716 100644 --- a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/OptionalLaws.kt +++ b/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/OptionalLaws.kt @@ -2,6 +2,7 @@ package arrow.optics.test.laws import arrow.core.compose import arrow.core.identity +import arrow.core.test.concurrency.deprecateArrowTestModules import arrow.optics.Optional import arrow.core.test.laws.Law import arrow.core.test.laws.equalUnderTheLaw @@ -10,8 +11,10 @@ import io.kotest.property.PropertyContext import io.kotest.property.arbitrary.constant import io.kotest.property.checkAll +@Deprecated(deprecateArrowTestModules) public object OptionalLaws { + @Deprecated(deprecateArrowTestModules) public fun laws( optionalGen: Arb>, aGen: Arb, @@ -31,6 +34,7 @@ public object OptionalLaws { /** * Warning: Use only when a `Gen.constant()` applies */ + @Deprecated(deprecateArrowTestModules) public fun laws( optional: Optional, aGen: Arb, @@ -40,6 +44,7 @@ public object OptionalLaws { eqb: (B?, B?) -> Boolean = { a, b -> a == b } ): List = laws(Arb.constant(optional), aGen, bGen, funcGen, eqa, eqb) + @Deprecated(deprecateArrowTestModules) public suspend fun getOptionSet( optionalGen: Arb>, aGen: Arb, @@ -52,6 +57,7 @@ public object OptionalLaws { } } + @Deprecated(deprecateArrowTestModules) public suspend fun setGetOption( optionalGen: Arb>, aGen: Arb, @@ -65,6 +71,7 @@ public object OptionalLaws { } } + @Deprecated(deprecateArrowTestModules) public suspend fun setIdempotent( optionalGen: Arb>, aGen: Arb, @@ -78,6 +85,7 @@ public object OptionalLaws { } } + @Deprecated(deprecateArrowTestModules) public suspend fun modifyIdentity( optionalGen: Arb>, aGen: Arb, @@ -90,6 +98,7 @@ public object OptionalLaws { } } + @Deprecated(deprecateArrowTestModules) public suspend fun composeModify( optionalGen: Arb>, aGen: Arb, @@ -103,6 +112,7 @@ public object OptionalLaws { } } + @Deprecated(deprecateArrowTestModules) public suspend fun consistentSetModify( optionalGen: Arb>, aGen: Arb, diff --git a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/PrismLaws.kt b/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/PrismLaws.kt index 9f3d486e292..d814d87b600 100644 --- a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/PrismLaws.kt +++ b/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/PrismLaws.kt @@ -2,6 +2,7 @@ package arrow.optics.test.laws import arrow.core.compose import arrow.core.identity +import arrow.core.test.concurrency.deprecateArrowTestModules import arrow.optics.Prism import arrow.core.test.laws.Law import arrow.core.test.laws.equalUnderTheLaw @@ -9,8 +10,10 @@ import io.kotest.property.Arb import io.kotest.property.PropertyContext import io.kotest.property.checkAll +@Deprecated(deprecateArrowTestModules) public object PrismLaws { + @Deprecated(deprecateArrowTestModules) public fun laws( prism: Prism, aGen: Arb, @@ -26,28 +29,33 @@ public object PrismLaws { Law("Prism law: consistent set modify") { prism.consistentSetModify(aGen, bGen, eqa) } ) + @Deprecated(deprecateArrowTestModules) public suspend fun Prism.partialRoundTripOneWay(aGen: Arb, eq: (A, A) -> Boolean): PropertyContext = checkAll(100, aGen) { a -> getOrModify(a).fold(::identity, ::reverseGet) .equalUnderTheLaw(a, eq) } + @Deprecated(deprecateArrowTestModules) public suspend fun Prism.roundTripOtherWay(bGen: Arb, eq: (B?, B?) -> Boolean): PropertyContext = checkAll(100, bGen) { b -> getOrNull(reverseGet(b)) .equalUnderTheLaw(b, eq) } + @Deprecated(deprecateArrowTestModules) public suspend fun Prism.modifyIdentity(aGen: Arb, eq: (A, A) -> Boolean): PropertyContext = checkAll(100, aGen) { a -> modify(a, ::identity).equalUnderTheLaw(a, eq) } + @Deprecated(deprecateArrowTestModules) public suspend fun Prism.composeModify(aGen: Arb, funcGen: Arb<(B) -> B>, eq: (A, A) -> Boolean): PropertyContext = checkAll(100, aGen, funcGen, funcGen) { a, f, g -> modify(modify(a, f), g).equalUnderTheLaw(modify(a, g compose f), eq) } + @Deprecated(deprecateArrowTestModules) public suspend fun Prism.consistentSetModify(aGen: Arb, bGen: Arb, eq: (A, A) -> Boolean): PropertyContext = checkAll(100, aGen, bGen) { a, b -> set(a, b).equalUnderTheLaw(modify(a) { b }, eq) diff --git a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/SetterLaws.kt b/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/SetterLaws.kt index 9f6ae55733c..5cb7bb0edb4 100644 --- a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/SetterLaws.kt +++ b/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/SetterLaws.kt @@ -2,6 +2,7 @@ package arrow.optics.test.laws import arrow.core.compose import arrow.core.identity +import arrow.core.test.concurrency.deprecateArrowTestModules import arrow.optics.Setter import arrow.core.test.laws.Law import arrow.core.test.laws.equalUnderTheLaw @@ -9,8 +10,10 @@ import io.kotest.property.Arb import io.kotest.property.PropertyContext import io.kotest.property.checkAll +@Deprecated(deprecateArrowTestModules) public object SetterLaws { + @Deprecated(deprecateArrowTestModules) public fun laws( setter: Setter, aGen: Arb, @@ -24,21 +27,25 @@ public object SetterLaws { Law("Setter law: consistent set modify") { setter.consistentSetModify(aGen, bGen, eq) } ) + @Deprecated(deprecateArrowTestModules) public suspend fun Setter.setIdempotent(aGen: Arb, bGen: Arb, eq: (A, A) -> Boolean): PropertyContext = checkAll(100, aGen, bGen) { a, b -> set(set(a, b), b).equalUnderTheLaw(set(a, b), eq) } + @Deprecated(deprecateArrowTestModules) public suspend fun Setter.modifyIdentity(aGen: Arb, eq: (A, A) -> Boolean): PropertyContext = checkAll(100, aGen) { a -> modify(a, ::identity).equalUnderTheLaw(a, eq) } + @Deprecated(deprecateArrowTestModules) public suspend fun Setter.composeModify(aGen: Arb, eq: (A, A) -> Boolean, funcGen: Arb<(B) -> B>): PropertyContext = checkAll(100, aGen, funcGen, funcGen) { a, f, g -> modify(modify(a, f), g).equalUnderTheLaw(modify(a, g compose f), eq) } + @Deprecated(deprecateArrowTestModules) public suspend fun Setter.consistentSetModify(aGen: Arb, bGen: Arb, eq: (A, A) -> Boolean): PropertyContext = checkAll(100, aGen, bGen) { a, b -> modify(a) { b }.equalUnderTheLaw(set(a, b), eq) diff --git a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/TraversalLaws.kt b/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/TraversalLaws.kt index 5399faecdf1..bc204f85dc3 100644 --- a/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/TraversalLaws.kt +++ b/arrow-libs/optics/arrow-optics-test/src/commonMain/kotlin/arrow/optics/test/laws/TraversalLaws.kt @@ -2,6 +2,7 @@ package arrow.optics.test.laws import arrow.core.compose import arrow.core.identity +import arrow.core.test.concurrency.deprecateArrowTestModules import arrow.optics.Traversal import arrow.core.test.laws.Law import arrow.core.test.laws.equalUnderTheLaw @@ -10,8 +11,10 @@ import io.kotest.property.PropertyContext import io.kotest.property.checkAll import kotlin.math.max +@Deprecated(deprecateArrowTestModules) public object TraversalLaws { + @Deprecated(deprecateArrowTestModules) public fun laws( traversal: Traversal, aGen: Arb, @@ -24,17 +27,20 @@ public object TraversalLaws { Law("Traversal law: compose modify") { traversal.composeModify(aGen, funcGen, eq) } ) + @Deprecated(deprecateArrowTestModules) public suspend fun Traversal.setIdempotent(aGen: Arb, bGen: Arb, eq: (A, A) -> Boolean): PropertyContext = checkAll(max(aGen.minIterations(), bGen.minIterations()), aGen, bGen) { a, b -> set(set(a, b), b) .equalUnderTheLaw(set(a, b), eq) } + @Deprecated(deprecateArrowTestModules) public suspend fun Traversal.modifyIdentity(aGen: Arb, eq: (A, A) -> Boolean): PropertyContext = checkAll(aGen.minIterations(), aGen) { a -> modify(a, ::identity).equalUnderTheLaw(a, eq) } + @Deprecated(deprecateArrowTestModules) public suspend fun Traversal.composeModify( aGen: Arb, funcGen: Arb<(B) -> B>, From eac45908f56a98ba2875473ab9044c505159426f Mon Sep 17 00:00:00 2001 From: i-walker Date: Thu, 30 Jun 2022 13:50:27 +0000 Subject: [PATCH 3/4] Update API files --- arrow-libs/core/arrow-core-test/api/arrow-core-test.api | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arrow-libs/core/arrow-core-test/api/arrow-core-test.api b/arrow-libs/core/arrow-core-test/api/arrow-core-test.api index 762d7b50400..1d009c7d92f 100644 --- a/arrow-libs/core/arrow-core-test/api/arrow-core-test.api +++ b/arrow-libs/core/arrow-core-test/api/arrow-core-test.api @@ -55,6 +55,10 @@ public final class arrow/core/test/concurrency/SideEffect { public fun toString ()Ljava/lang/String; } +public final class arrow/core/test/concurrency/SideEffectKt { + public static final field deprecateArrowTestModules Ljava/lang/String; +} + public final class arrow/core/test/generators/GeneratorsJvmKt { public static final fun fatalThrowable (Lio/kotest/property/Arb$Companion;)Lio/kotest/property/Arb; public static final fun suspendFunThatThrowsFatalThrowable (Lio/kotest/property/Arb$Companion;)Lio/kotest/property/Arb; From cea60dd4bd597affa196705abf4566b658e0275e Mon Sep 17 00:00:00 2001 From: i-walker <46971368+i-walker@users.noreply.github.com> Date: Thu, 30 Jun 2022 16:13:43 +0200 Subject: [PATCH 4/4] run CI