diff --git a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/IterableTest.kt b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/IterableTest.kt index 7a1fe712366..d8402e1280f 100644 --- a/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/IterableTest.kt +++ b/arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/IterableTest.kt @@ -11,12 +11,7 @@ import io.kotest.matchers.nulls.shouldBeNull import io.kotest.matchers.nulls.shouldNotBeNull import io.kotest.property.Arb import io.kotest.matchers.shouldBe -import io.kotest.property.arbitrary.boolean -import io.kotest.property.arbitrary.int -import io.kotest.property.arbitrary.list -import io.kotest.property.arbitrary.orNull -import io.kotest.property.arbitrary.pair -import io.kotest.property.arbitrary.string +import io.kotest.property.arbitrary.* import io.kotest.property.checkAll import kotlin.math.max import kotlin.math.min @@ -553,6 +548,26 @@ class IterableTest : StringSpec({ } } + "flatten" { + checkAll(Arb.pair(Arb.list(Arb.int()), Arb.list(Arb.int()))) { (a, b) -> + listOf(a, b).flatten() shouldBe a + b + } + } + + "widen(Iterable)" { + checkAll(Arb.list(Arb.string())) { orig: Iterable -> + val result: Iterable = orig.widen() + result shouldContainExactly orig + } + } + + "widen(List)" { + checkAll(Arb.list(Arb.string())) { orig: List -> + val result: List = orig.widen() + result shouldContainExactly orig + } + } + "unzip is the inverse of zip" { checkAll(Arb.list(Arb.int())) { xs -> @@ -628,4 +643,19 @@ class IterableTest : StringSpec({ } } } + + "compareTo returns 0 if other has same elements" { + checkAll(Arb.list(Arb.int())) { ints -> + ints.compareTo(ints) shouldBe 0 + } + } + + "compareTo returns -1 if other have greater element at the same position"{ + listOf(1,2,3).compareTo(listOf(1,4,3)) shouldBe -1 + } + + "compareTo returns 1 if other have smaller element at the same position"{ + listOf(1,2,3).compareTo(listOf(1,1,3)) shouldBe 1 + } + })