diff --git a/arrow-libs/ank/gradle.properties b/arrow-libs/ank/gradle.properties
index 6c21d28a87b..4decaec9c15 100644
--- a/arrow-libs/ank/gradle.properties
+++ b/arrow-libs/ank/gradle.properties
@@ -8,7 +8,7 @@ systemProp.org.gradle.internal.publish.checksums.insecure=true
kotlin.incremental=true
# Kotlin Test configuration
#Parallelism needs to be set to 1 since the concurrent tests in arrow-effects become flaky otherwise
-kotlintest.parallelism=1
+kotest.framework.parallelism=1
# Reason: https://youtrack.jetbrains.com/issue/KT-46847
# kotlin.stdlib.default.dependency=false
diff --git a/arrow-libs/core/arrow-continuations/build.gradle b/arrow-libs/core/arrow-continuations/build.gradle
index 8758bc34bac..7a60a1abb5c 100644
--- a/arrow-libs/core/arrow-continuations/build.gradle
+++ b/arrow-libs/core/arrow-continuations/build.gradle
@@ -25,7 +25,6 @@ kotlin {
jvmTest {
dependencies {
runtimeOnly "org.junit.vintage:junit-vintage-engine:$JUNIT_VINTAGE_VERSION"
- compileOnly "io.kotlintest:kotlintest-runner-junit5:$KOTLIN_TEST_VERSION", excludeArrow
implementation project(":arrow-core-test")
}
}
diff --git a/arrow-libs/core/arrow-continuations/src/jvmTest/kotlin/generic/SuspendingComputationTest.kt b/arrow-libs/core/arrow-continuations/src/jvmTest/kotlin/generic/SuspendingComputationTest.kt
index 247c5468a9a..ef4c09cdd70 100644
--- a/arrow-libs/core/arrow-continuations/src/jvmTest/kotlin/generic/SuspendingComputationTest.kt
+++ b/arrow-libs/core/arrow-continuations/src/jvmTest/kotlin/generic/SuspendingComputationTest.kt
@@ -3,10 +3,10 @@ package generic
import arrow.core.computations.either
import arrow.core.Either.Right
import arrow.core.Either.Left
-import io.kotlintest.fail
-import io.kotlintest.shouldBe
-import io.kotlintest.shouldThrow
-import io.kotlintest.specs.StringSpec
+import io.kotest.assertions.fail
+import io.kotest.matchers.shouldBe
+import io.kotest.assertions.throwables.shouldThrow
+import io.kotest.core.spec.style.StringSpec
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Deferred
diff --git a/arrow-libs/core/arrow-continuations/src/jvmTest/kotlin/generic/TestSuite.kt b/arrow-libs/core/arrow-continuations/src/jvmTest/kotlin/generic/TestSuite.kt
index 86b5f3a4adc..2de62bd57f3 100644
--- a/arrow-libs/core/arrow-continuations/src/jvmTest/kotlin/generic/TestSuite.kt
+++ b/arrow-libs/core/arrow-continuations/src/jvmTest/kotlin/generic/TestSuite.kt
@@ -6,7 +6,7 @@ import arrow.continuations.generic.RestrictedScope
import arrow.core.Either
import arrow.core.Either.Left
import arrow.core.test.UnitSpec
-import io.kotlintest.shouldBe
+import io.kotest.matchers.shouldBe
abstract class ContTestSuite : UnitSpec() {
abstract suspend fun runScope(func: (suspend RestrictedScope.() -> A)): A
diff --git a/arrow-libs/core/arrow-core-retrofit/src/test/kotlin/arrow/retrofit/adapter/either/ArrowEitherCallAdapterTest.kt b/arrow-libs/core/arrow-core-retrofit/src/test/kotlin/arrow/retrofit/adapter/either/ArrowEitherCallAdapterTest.kt
index 762bf3a309f..3089af5b731 100644
--- a/arrow-libs/core/arrow-core-retrofit/src/test/kotlin/arrow/retrofit/adapter/either/ArrowEitherCallAdapterTest.kt
+++ b/arrow-libs/core/arrow-core-retrofit/src/test/kotlin/arrow/retrofit/adapter/either/ArrowEitherCallAdapterTest.kt
@@ -6,9 +6,7 @@ import arrow.core.test.UnitSpec
import arrow.retrofit.adapter.mock.ErrorMock
import arrow.retrofit.adapter.mock.ResponseMock
import arrow.retrofit.adapter.retrofit.SuspedApiClientTest
-import io.kotlintest.Spec
-import io.kotlintest.shouldBe
-import kotlinx.coroutines.runBlocking
+import io.kotest.matchers.shouldBe
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
import okhttp3.mockwebserver.SocketPolicy
@@ -28,22 +26,15 @@ class ArrowEitherCallAdapterTest : UnitSpec() {
.create(SuspedApiClientTest::class.java)
}
- override fun beforeSpec(spec: Spec) {
- super.beforeSpec(spec)
- server.start()
- }
-
- override fun afterSpec(spec: Spec) {
- server.shutdown()
- super.afterSpec(spec)
- }
-
init {
+ beforeSpec { server.start() }
+ afterSpec { server.shutdown() }
+
"should return ResponseMock for 200 with valid JSON" {
server.enqueue(MockResponse().setBody("""{"response":"Arrow rocks"}"""))
- val body = runBlocking { service.getEither() }
+ val body = service.getEither()
body shouldBe ResponseMock("Arrow rocks").right()
}
@@ -51,7 +42,7 @@ class ArrowEitherCallAdapterTest : UnitSpec() {
"should return ErrorMock for 400 with valid JSON" {
server.enqueue(MockResponse().setBody("""{"errorCode":666}""").setResponseCode(400))
- val body = runBlocking { service.getEither() }
+ val body = service.getEither()
body shouldBe ErrorMock(666).left()
}
@@ -59,7 +50,7 @@ class ArrowEitherCallAdapterTest : UnitSpec() {
"should throw for 200 with invalid JSON" {
server.enqueue(MockResponse().setBody("""not a valid JSON"""))
- val body = kotlin.runCatching { service.getEither() }
+ val body = runCatching { service.getEither() }
body.isFailure shouldBe true
}
@@ -67,7 +58,7 @@ class ArrowEitherCallAdapterTest : UnitSpec() {
"should throw for 400 and invalid JSON" {
server.enqueue(MockResponse().setBody("""not a valid JSON""").setResponseCode(400))
- val body = kotlin.runCatching { service.getEither() }
+ val body = runCatching { service.getEither() }
body.isFailure shouldBe true
}
diff --git a/arrow-libs/core/arrow-core-retrofit/src/test/kotlin/arrow/retrofit/adapter/either/ArrowResponseEAdapterTest.kt b/arrow-libs/core/arrow-core-retrofit/src/test/kotlin/arrow/retrofit/adapter/either/ArrowResponseEAdapterTest.kt
index c55d077f742..9681c76704f 100644
--- a/arrow-libs/core/arrow-core-retrofit/src/test/kotlin/arrow/retrofit/adapter/either/ArrowResponseEAdapterTest.kt
+++ b/arrow-libs/core/arrow-core-retrofit/src/test/kotlin/arrow/retrofit/adapter/either/ArrowResponseEAdapterTest.kt
@@ -6,9 +6,7 @@ import arrow.core.test.UnitSpec
import arrow.retrofit.adapter.mock.ErrorMock
import arrow.retrofit.adapter.mock.ResponseMock
import arrow.retrofit.adapter.retrofit.SuspedApiClientTest
-import io.kotlintest.Spec
-import io.kotlintest.shouldBe
-import kotlinx.coroutines.runBlocking
+import io.kotest.matchers.shouldBe
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
import okhttp3.mockwebserver.SocketPolicy
@@ -28,22 +26,15 @@ class ArrowResponseEAdapterTest : UnitSpec() {
.create(SuspedApiClientTest::class.java)
}
- override fun beforeSpec(spec: Spec) {
- super.beforeSpec(spec)
- server.start()
- }
-
- override fun afterSpec(spec: Spec) {
- server.shutdown()
- super.afterSpec(spec)
- }
-
init {
+ beforeSpec { server.start() }
+ afterSpec { server.shutdown() }
+
"should return ResponseMock for 200 with valid JSON" {
server.enqueue(MockResponse().setBody("""{"response":"Arrow rocks"}"""))
- val responseE = runBlocking { service.getResponseE() }
+ val responseE = service.getResponseE()
with(responseE) {
code shouldBe 200
@@ -54,7 +45,7 @@ class ArrowResponseEAdapterTest : UnitSpec() {
"should return ErrorMock for 400 with valid JSON" {
server.enqueue(MockResponse().setBody("""{"errorCode":42}""").setResponseCode(400))
- val responseE = runBlocking { service.getResponseE() }
+ val responseE = service.getResponseE()
with(responseE) {
code shouldBe 400
@@ -65,7 +56,7 @@ class ArrowResponseEAdapterTest : UnitSpec() {
"should throw for 200 with invalid JSON" {
server.enqueue(MockResponse().setBody("""not a valid JSON"""))
- val responseE = kotlin.runCatching { service.getResponseE() }
+ val responseE = runCatching { service.getResponseE() }
responseE.isFailure shouldBe true
}
@@ -73,7 +64,7 @@ class ArrowResponseEAdapterTest : UnitSpec() {
"should throw for 400 and invalid JSON" {
server.enqueue(MockResponse().setBody("""not a valid JSON""").setResponseCode(400))
- val responseE = kotlin.runCatching { service.getResponseE() }
+ val responseE = runCatching { service.getResponseE() }
responseE.isFailure shouldBe true
}
diff --git a/arrow-libs/core/arrow-core-test/build.gradle b/arrow-libs/core/arrow-core-test/build.gradle
index 71a6ccae3fc..bf8b6ffc514 100644
--- a/arrow-libs/core/arrow-core-test/build.gradle
+++ b/arrow-libs/core/arrow-core-test/build.gradle
@@ -12,6 +12,7 @@ dependencies {
api project(":arrow-core")
api project(":arrow-continuations")
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$KOTLINX_COROUTINES_VERSION"
- api "io.kotlintest:kotlintest-runner-junit5:$KOTLIN_TEST_VERSION", excludeArrow
- testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$JUNIT_VINTAGE_VERSION"
+ api "io.kotest:kotest-runner-junit5-jvm:$KOTEST_VERSION" // for kotest framework
+ api "io.kotest:kotest-assertions-core-jvm:$KOTEST_VERSION" // for kotest core jvm assertions
+ api "io.kotest:kotest-property-jvm:$KOTEST_VERSION" // for kotest property test
}
diff --git a/arrow-libs/core/arrow-core-test/src/main/kotlin/arrow/core/test/UnitSpec.kt b/arrow-libs/core/arrow-core-test/src/main/kotlin/arrow/core/test/UnitSpec.kt
index dacb960e731..1969789862d 100644
--- a/arrow-libs/core/arrow-core-test/src/main/kotlin/arrow/core/test/UnitSpec.kt
+++ b/arrow-libs/core/arrow-core-test/src/main/kotlin/arrow/core/test/UnitSpec.kt
@@ -3,95 +3,102 @@ package arrow.core.test
import arrow.core.Tuple4
import arrow.core.Tuple5
import arrow.core.test.laws.Law
-import io.kotlintest.TestCase
-import io.kotlintest.TestType
-import io.kotlintest.properties.Gen
-import io.kotlintest.properties.PropertyContext
-import io.kotlintest.properties.assertAll
-import io.kotlintest.shouldBe
-import io.kotlintest.specs.AbstractStringSpec
+import io.kotest.core.spec.style.StringSpec
+import io.kotest.core.test.createTestName
+import io.kotest.property.Arb
+import io.kotest.property.PropertyContext
+import io.kotest.property.arbitrary.bind
+import io.kotest.property.checkAll
/**
* Base class for unit tests
*/
-abstract class UnitSpec : AbstractStringSpec() {
+abstract class UnitSpec : StringSpec() {
- private val lawTestCases = mutableListOf()
-
- fun testLaws(vararg laws: List): List = laws
+ fun testLaws(vararg laws: List): Unit = laws
.flatMap { list: List -> list.asIterable() }
.distinctBy { law: Law -> law.name }
- .map { law: Law ->
- val lawTestCase = createTestCase(law.name, law.test, defaultTestCaseConfig, TestType.Test)
- lawTestCases.add(lawTestCase)
- lawTestCase
+ .forEach { law: Law ->
+ registration().addTest(createTestName(law.name), xdisabled = false, law.test)
}
- override fun testCases(): List = super.testCases() + lawTestCases
+ fun testLaws(prefix: String, vararg laws: List): Unit = laws
+ .flatMap { list: List -> list.asIterable() }
+ .distinctBy { law: Law -> law.name }
+ .forEach { law: Law ->
+ registration().addTest(createTestName(prefix, law.name, true), xdisabled = false, law.test)
+ }
- fun forAll(
- gena: Gen,
- genb: Gen,
- genc: Gen,
- gend: Gen,
- gene: Gen,
- genf: Gen,
- geng: Gen,
- fn: PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F, g: G) -> Boolean
+ suspend fun checkAll(
+ gena: Arb,
+ genb: Arb,
+ genc: Arb,
+ gend: Arb,
+ gene: Arb,
+ genf: Arb,
+ geng: Arb,
+ fn: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F, g: G) -> Unit
) {
- assertAll(gena, genb, genc, gend, gene, Gen.bind(genf, geng, ::Pair)) { a, b, c, d, e, (f, g) ->
- fn(a, b, c, d, e, f, g) shouldBe true
+ checkAll(gena, genb, genc, gend, gene, Arb.bind(genf, geng, ::Pair)) { a, b, c, d, e, (f, g) ->
+ fn(a, b, c, d, e, f, g)
}
}
- fun forAll(
- gena: Gen,
- genb: Gen,
- genc: Gen,
- gend: Gen,
- gene: Gen,
- genf: Gen,
- geng: Gen,
- genh: Gen,
- fn: PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H) -> Boolean
+ suspend fun checkAll(
+ gena: Arb,
+ genb: Arb,
+ genc: Arb,
+ gend: Arb,
+ gene: Arb,
+ genf: Arb,
+ geng: Arb,
+ genh: Arb,
+ fn: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H) -> Unit
) {
- assertAll(gena, genb, genc, gend, gene, Gen.bind(genf, geng, genh, ::Triple)) { a, b, c, d, e, (f, g, h) ->
- fn(a, b, c, d, e, f, g, h) shouldBe true
+ checkAll(gena, genb, genc, gend, gene, Arb.bind(genf, geng, genh, ::Triple)) { a, b, c, d, e, (f, g, h) ->
+ fn(a, b, c, d, e, f, g, h)
}
}
- fun forAll(
- gena: Gen,
- genb: Gen,
- genc: Gen,
- gend: Gen,
- gene: Gen,
- genf: Gen,
- geng: Gen,
- genh: Gen,
- geni: Gen,
- fn: PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I) -> Boolean
+ suspend fun checkAll(
+ gena: Arb,
+ genb: Arb,
+ genc: Arb,
+ gend: Arb,
+ gene: Arb,
+ genf: Arb,
+ geng: Arb,
+ genh: Arb,
+ geni: Arb,
+ fn: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I) -> Unit
) {
- assertAll(gena, genb, genc, gend, gene, Gen.bind(genf, geng, genh, geni, ::Tuple4)) { a, b, c, d, e, (f, g, h, i) ->
- fn(a, b, c, d, e, f, g, h, i) shouldBe true
+ checkAll(gena, genb, genc, gend, gene, Arb.bind(genf, geng, genh, geni, ::Tuple4)) { a, b, c, d, e, (f, g, h, i) ->
+ fn(a, b, c, d, e, f, g, h, i)
}
}
- fun forAll(
- gena: Gen,
- genb: Gen,
- genc: Gen,
- gend: Gen,
- gene: Gen,
- genf: Gen,
- geng: Gen,
- genh: Gen,
- geni: Gen,
- genj: Gen,
- fn: PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J) -> Boolean
+ suspend fun checkAll(
+ gena: Arb,
+ genb: Arb,
+ genc: Arb,
+ gend: Arb,
+ gene: Arb,
+ genf: Arb,
+ geng: Arb,
+ genh: Arb,
+ geni: Arb,
+ genj: Arb,
+ fn: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J) -> Unit
) {
- assertAll(gena, genb, genc, gend, gene, Gen.bind(genf, geng, genh, geni, genj, ::Tuple5)) { a, b, c, d, e, (f, g, h, i, j) ->
- fn(a, b, c, d, e, f, g, h, i, j) shouldBe true
+ checkAll(
+ gena,
+ genb,
+ genc,
+ gend,
+ gene,
+ Arb.bind(genf, geng, genh, geni, genj, ::Tuple5)
+ ) { a, b, c, d, e, (f, g, h, i, j) ->
+ fn(a, b, c, d, e, f, g, h, i, j)
}
}
}
diff --git a/arrow-libs/core/arrow-core-test/src/main/kotlin/arrow/core/test/generators/Generators.kt b/arrow-libs/core/arrow-core-test/src/main/kotlin/arrow/core/test/generators/Generators.kt
index 4e4fc355dd4..42d5268136c 100644
--- a/arrow-libs/core/arrow-core-test/src/main/kotlin/arrow/core/test/generators/Generators.kt
+++ b/arrow-libs/core/arrow-core-test/src/main/kotlin/arrow/core/test/generators/Generators.kt
@@ -16,83 +16,171 @@ import arrow.core.Tuple7
import arrow.core.Tuple8
import arrow.core.Tuple9
import arrow.core.Validated
-import arrow.core.align
import arrow.core.left
import arrow.core.right
import arrow.core.toOption
-import io.kotlintest.properties.Gen
-import io.kotlintest.properties.shrinking.DoubleShrinker
-import io.kotlintest.properties.shrinking.FloatShrinker
-import io.kotlintest.properties.shrinking.Shrinker
-
-fun Gen.Companion.short(): Gen =
- Gen.choose(Short.MIN_VALUE.toInt(), Short.MAX_VALUE.toInt()).map { it.toShort() }
-
-fun Gen.Companion.byte(): Gen =
- Gen.choose(Byte.MIN_VALUE.toInt(), Byte.MAX_VALUE.toInt()).map { it.toByte() }
-
-fun Gen.Companion.functionAToB(gen: Gen): Gen<(A) -> B> = gen.map { b: B -> { _: A -> b } }
-
-fun Gen.Companion.functionAAToA(gen: Gen): Gen<(A, A) -> A> = gen.map { a: A -> { _: A, _: A -> a } }
-
-fun Gen.Companion.functionBAToB(gen: Gen): Gen<(B, A) -> B> = gen.map { b: B -> { _: B, _: A -> b } }
-
-fun Gen.Companion.functionABToB(gen: Gen): Gen<(A, B) -> B> = gen.map { b: B -> { _: A, _: B -> b } }
-
-fun Gen.Companion.functionToA(gen: Gen): Gen<() -> A> = gen.map { a: A -> { a } }
-
-fun Gen.Companion.throwable(): Gen = Gen.from(listOf(RuntimeException(), NoSuchElementException(), IllegalArgumentException()))
-
-fun Gen.Companion.fatalThrowable(): Gen = Gen.from(listOf(ThreadDeath(), StackOverflowError(), OutOfMemoryError(), InterruptedException()))
-
-fun Gen.Companion.doubleSmall(): Gen = object : Gen {
- override fun constants(): Iterable = emptyList()
- override fun random(): Sequence = (0 until 10_000).asSequence().map { it / 100.0 }
- override fun shrinker(): Shrinker = DoubleShrinker
+import io.kotest.property.Arb
+import io.kotest.property.arbitrary.bind
+import io.kotest.property.arbitrary.bool
+import io.kotest.property.arbitrary.byte
+import io.kotest.property.arbitrary.choice
+import io.kotest.property.arbitrary.constant
+import io.kotest.property.arbitrary.double
+import io.kotest.property.arbitrary.file
+import io.kotest.property.arbitrary.filter
+import io.kotest.property.arbitrary.flatMap
+import io.kotest.property.arbitrary.float
+import io.kotest.property.arbitrary.int
+import io.kotest.property.arbitrary.list
+import io.kotest.property.arbitrary.localDate
+import io.kotest.property.arbitrary.localDateTime
+import io.kotest.property.arbitrary.localTime
+import io.kotest.property.arbitrary.long
+import io.kotest.property.arbitrary.map
+import io.kotest.property.arbitrary.numericDoubles
+import io.kotest.property.arbitrary.numericFloats
+import io.kotest.property.arbitrary.of
+import io.kotest.property.arbitrary.orNull
+import io.kotest.property.arbitrary.period
+import io.kotest.property.arbitrary.short
+import io.kotest.property.arbitrary.string
+import io.kotest.property.arbitrary.uuid
+import kotlin.math.abs
+
+fun Arb.Companion.functionAToB(arb: Arb): Arb<(A) -> B> =
+ arb.map { b: B -> { _: A -> b } }
+
+fun Arb.Companion.functionAAToA(arb: Arb): Arb<(A, A) -> A> =
+ arb.map { a: A -> { _: A, _: A -> a } }
+
+fun Arb.Companion.functionBAToB(arb: Arb): Arb<(B, A) -> B> =
+ arb.map { b: B -> { _: B, _: A -> b } }
+
+fun Arb.Companion.functionABToB(arb: Arb): Arb<(A, B) -> B> =
+ arb.map { b: B -> { _: A, _: B -> b } }
+
+fun Arb.Companion.functionToA(arb: Arb): Arb<() -> A> =
+ arb.map { a: A -> { a } }
+
+fun Arb.Companion.throwable(): Arb =
+ Arb.of(listOf(RuntimeException(), NoSuchElementException(), IllegalArgumentException()))
+
+fun Arb.Companion.fatalThrowable(): Arb =
+ Arb.of(listOf(ThreadDeath(), StackOverflowError(), OutOfMemoryError(), InterruptedException()))
+
+fun Arb.Companion.doubleSmall(): Arb =
+ Arb.numericDoubles(from = 0.0, to = 100.0)
+
+fun Arb.Companion.floatSmall(): Arb =
+ Arb.numericFloats(from = 0F, to = 100F)
+
+fun Arb.Companion.intSmall(factor: Int = 10000): Arb =
+ Arb.int((Int.MIN_VALUE / factor)..(Int.MAX_VALUE / factor))
+
+fun Arb.Companion.byteSmall(): Arb =
+ Arb.byte(min = (Byte.MIN_VALUE / 10).toByte(), max = (Byte.MAX_VALUE / 10).toByte())
+
+fun Arb.Companion.shortSmall(): Arb {
+ val range = (Short.MIN_VALUE / 1000)..(Short.MAX_VALUE / 1000)
+ return Arb.short().filter { it in range }
}
-fun Gen.Companion.floatSmall(): Gen = object : Gen {
- val literals = listOf(0F)
- override fun constants(): Iterable = literals
- override fun random(): Sequence = (0 until 10_000).asSequence().map { it / 100.0f }
- override fun shrinker() = FloatShrinker
-}
-
-fun Gen.Companion.intSmall(): Gen = Gen.oneOf(Gen.choose(Int.MIN_VALUE / 10000, -1), Gen.choose(0, Int.MAX_VALUE / 10000))
-
-fun Gen.Companion.byteSmall(): Gen = Gen.oneOf(Gen.choose(Byte.MIN_VALUE / 10, -1), Gen.choose(0, Byte.MAX_VALUE / 10)).map { it.toByte() }
-
-fun Gen.Companion.shortSmall(): Gen = Gen.oneOf(Gen.choose(Short.MIN_VALUE / 1000, -1), Gen.choose(0, Short.MAX_VALUE / 1000)).map { it.toShort() }
-
-fun Gen.Companion.longSmall(): Gen = Gen.oneOf(Gen.choose(Long.MIN_VALUE / 100000L, -1L), Gen.choose(0L, Long.MAX_VALUE / 100000L))
-
-fun Gen.Companion.tuple4(genA: Gen, genB: Gen, genC: Gen, genD: Gen): Gen> =
- Gen.bind(genA, genB, genC, genD) { a: A, b: B, c: C, d: D -> Tuple4(a, b, c, d) }
-
-fun Gen.Companion.tuple5(genA: Gen, genB: Gen, genC: Gen, genD: Gen, genE: Gen): Gen> =
- Gen.bind(genA, genB, genC, genD, genE) { a: A, b: B, c: C, d: D, e: E -> Tuple5(a, b, c, d, e) }
-
-fun Gen.Companion.tuple6(genA: Gen, genB: Gen, genC: Gen, genD: Gen, genE: Gen, genF: Gen): Gen> =
- Gen.bind(genA, genB, genC, genD, genE, genF) { a: A, b: B, c: C, d: D, e: E, f: F -> Tuple6(a, b, c, d, e, f) }
-
-fun Gen.Companion.tuple7(genA: Gen, genB: Gen, genC: Gen, genD: Gen, genE: Gen, genF: Gen, genG: Gen): Gen> =
- Gen.bind(genA, genB, genC, genD, genE, genF, genG) { a: A, b: B, c: C, d: D, e: E, f: F, g: G -> Tuple7(a, b, c, d, e, f, g) }
-
-fun Gen.Companion.tuple8(genA: Gen, genB: Gen, genC: Gen, genD: Gen, genE: Gen, genF: Gen, genG: Gen, genH: Gen): Gen> =
- Gen.bind(Gen.tuple7(genA, genB, genC, genD, genE, genF, genG), genH) { tuple: Tuple7, h: H -> Tuple8(tuple.first, tuple.second, tuple.third, tuple.fourth, tuple.fifth, tuple.sixth, tuple.seventh, h) }
+fun Arb.Companion.longSmall(): Arb =
+ Arb.long((Long.MIN_VALUE / 100000L)..(Long.MAX_VALUE / 100000L))
+
+fun Arb.Companion.tuple4(arbA: Arb, arbB: Arb, arbC: Arb, arbD: Arb): Arb> =
+ Arb.bind(arbA, arbB, arbC, arbD, ::Tuple4)
+
+fun Arb.Companion.tuple5(
+ arbA: Arb,
+ arbB: Arb,
+ arbC: Arb,
+ arbD: Arb,
+ arbE: Arb
+): Arb> =
+ Arb.bind(arbA, arbB, arbC, arbD, arbE, ::Tuple5)
+
+fun Arb.Companion.tuple6(
+ arbA: Arb,
+ arbB: Arb,
+ arbC: Arb,
+ arbD: Arb,
+ arbE: Arb,
+ arbF: Arb
+): Arb> =
+ Arb.bind(arbA, arbB, arbC, arbD, arbE, arbF, ::Tuple6)
+
+fun Arb.Companion.tuple7(
+ arbA: Arb,
+ arbB: Arb,
+ arbC: Arb,
+ arbD: Arb,
+ arbE: Arb,
+ arbF: Arb,
+ arbG: Arb
+): Arb> =
+ Arb.bind(arbA, arbB, arbC, arbD, arbE, arbF, arbG, ::Tuple7)
+
+fun Arb.Companion.tuple8(
+ arbA: Arb,
+ arbB: Arb,
+ arbC: Arb,
+ arbD: Arb,
+ arbE: Arb,
+ arbF: Arb,
+ arbG: Arb,
+ arbH: Arb
+): Arb> =
+ Arb.bind(
+ Arb.tuple7(arbA, arbB, arbC, arbD, arbE, arbF, arbG),
+ arbH
+ ) { (a, b, c, d, e, f, g), h ->
+ Tuple8(a, b, c, d, e, f, g, h)
+ }
-fun Gen.Companion.tuple9(genA: Gen, genB: Gen, genC: Gen, genD: Gen, genE: Gen, genF: Gen, genG: Gen, genH: Gen, genI: Gen): Gen> =
- Gen.bind(Gen.tuple8(genA, genB, genC, genD, genE, genF, genG, genH), genI) { tuple: Tuple8, i: I -> Tuple9(tuple.first, tuple.second, tuple.third, tuple.fourth, tuple.fifth, tuple.sixth, tuple.seventh, tuple.eighth, i) }
+fun Arb.Companion.tuple9(
+ arbA: Arb,
+ arbB: Arb,
+ arbC: Arb,
+ arbD: Arb,
+ arbE: Arb,
+ arbF: Arb,
+ arbG: Arb,
+ arbH: Arb,
+ arbI: Arb
+): Arb> =
+ Arb.bind(
+ Arb.tuple8(arbA, arbB, arbC, arbD, arbE, arbF, arbG, arbH),
+ arbI
+ ) { (a, b, c, d, e, f, g, h), i ->
+ Tuple9(a, b, c, d, e, f, g, h, i)
+ }
-fun Gen.Companion.tuple10(genA: Gen, genB: Gen, genC: Gen, genD: Gen, genE: Gen, genF: Gen, genG: Gen, genH: Gen, genI: Gen, genJ: Gen): Gen> =
- Gen.bind(Gen.tuple9(genA, genB, genC, genD, genE, genF, genG, genH, genI), genJ) { tuple: Tuple9, j: J -> Tuple10(tuple.first, tuple.second, tuple.third, tuple.fourth, tuple.fifth, tuple.sixth, tuple.seventh, tuple.eighth, tuple.ninth, j) }
+fun Arb.Companion.tuple10(
+ arbA: Arb,
+ arbB: Arb,
+ arbC: Arb,
+ arbD: Arb,
+ arbE: Arb,
+ arbF: Arb,
+ arbG: Arb,
+ arbH: Arb,
+ arbI: Arb,
+ arbJ: Arb
+): Arb> =
+ Arb.bind(
+ Arb.tuple9(arbA, arbB, arbC, arbD, arbE, arbF, arbG, arbH, arbI),
+ arbJ
+ ) { (a, b, c, d, e, f, g, h, i), j ->
+ Tuple10(a, b, c, d, e, f, g, h, i, j)
+ }
-fun Gen.Companion.nonZeroInt(): Gen = Gen.int().filter { it != 0 }
+fun Arb.Companion.nonZeroInt(): Arb = Arb.int().filter { it != 0 }
-fun Gen.Companion.intPredicate(): Gen<(Int) -> Boolean> =
- Gen.nonZeroInt().flatMap { num ->
- val absNum = Math.abs(num)
- Gen.from(
+fun Arb.Companion.intPredicate(): Arb<(Int) -> Boolean> =
+ Arb.nonZeroInt().flatMap { num ->
+ val absNum = abs(num)
+ Arb.of(
listOf<(Int) -> Boolean>(
{ it > num },
{ it <= num },
@@ -102,90 +190,77 @@ fun Gen.Companion.intPredicate(): Gen<(Int) -> Boolean> =
)
}
-fun Gen.Companion.endo(gen: Gen): Gen> = gen.map { a: A -> Endo { a } }
+fun Arb.Companion.endo(arb: Arb): Arb> = arb.map { a: A -> Endo { a } }
-fun Gen.Companion.option(gen: Gen): Gen