Skip to content

Commit 586a098

Browse files
committed
Update kotlintest to version 3.3.1
Law updated because the function has to be suspended NumberMonoid updated because nesting is not supported and I had to create some generators Moore updated because the default toString implementation breaks kotlin-reflect
1 parent 6645255 commit 586a098

File tree

5 files changed

+48
-40
lines changed

5 files changed

+48
-40
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ buildscript {
2222
javaVersion = JavaVersion.VERSION_1_7
2323
jUnitVersion = '4.12'
2424
jUnitVintageVersion = '5.2.0'
25-
kotlinTestVersion = '3.1.5'
25+
kotlinTestVersion = '3.3.1'
2626
kotlinVersion = '1.3.11'
2727
daggerVersion = '2.17'
2828
kotlinxCoroutinesVersion = '1.1.0'

modules/core/arrow-core-data/src/test/kotlin/arrow/extensions/NumberMonoidTest.kt

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ package arrow.extensions
22

33
import arrow.core.extensions.monoid
44
import arrow.test.UnitSpec
5+
import arrow.test.generators.byte
6+
import arrow.test.generators.short
7+
import io.kotlintest.properties.Gen
58
import io.kotlintest.runner.junit4.KotlinTestRunner
69
import io.kotlintest.properties.forAll
710
import org.junit.runner.RunWith
@@ -10,60 +13,57 @@ import org.junit.runner.RunWith
1013
class NumberMonoidTest : UnitSpec() {
1114
init {
1215

13-
"should semigroup with the instance passed" {
14-
"int" {
15-
forAll { value: Int ->
16-
val seen = Int.monoid().run { value.combine(value) }
17-
val expected = value + value
16+
"should semigroup with the instance passed - int" {
17+
forAll { value: Int ->
18+
val seen = Int.monoid().run { value.combine(value) }
19+
val expected = value + value
1820

19-
expected == seen
20-
}
21+
expected == seen
2122
}
23+
}
2224

23-
"float" {
24-
forAll { value: Float ->
25-
val seen = Float.monoid().run { value.combine(value) }
26-
val expected = value + value
25+
"should semigroup with the instance passed - float" {
26+
forAll(Gen.numericFloats()) { value: Float ->
27+
val seen = Float.monoid().run { value.combine(value) }
28+
val expected = value + value
2729

28-
expected == seen
29-
}
30+
expected == seen
3031
}
32+
}
3133

32-
"double" {
33-
forAll { value: Double ->
34-
val seen = Double.monoid().run { value.combine(value) }
35-
val expected = value + value
34+
"should semigroup with the instance passed - double" {
35+
forAll(Gen.numericDoubles()) { value: Double ->
36+
val seen = Double.monoid().run { value.combine(value) }
37+
val expected = value + value
3638

37-
expected == seen
38-
}
39+
expected == seen
3940
}
41+
}
4042

41-
"long" {
42-
43-
forAll { value: Long ->
44-
val seen = Long.monoid().run { value.combine(value) }
45-
val expected = value + value
43+
"should semigroup with the instance passed - long" {
44+
forAll { value: Long ->
45+
val seen = Long.monoid().run { value.combine(value) }
46+
val expected = value + value
4647

47-
expected == seen
48-
}
48+
expected == seen
4949
}
50+
}
5051

51-
"short" {
52-
forAll { value: Short ->
53-
val seen = Short.monoid().run { value.combine(value) }
54-
val expected = (value + value).toShort()
52+
"should semigroup with the instance passed - short" {
53+
forAll(Gen.short()) { value: Short ->
54+
val seen = Short.monoid().run { value.combine(value) }
55+
val expected = (value + value).toShort()
5556

56-
expected == seen
57-
}
57+
expected == seen
5858
}
59+
}
5960

60-
"byte" {
61-
forAll { value: Byte ->
62-
val seen = Byte.monoid().run { value.combine(value) }
63-
val expected = (value + value).toByte()
61+
"should semigroup with the instance passed - byte" {
62+
forAll(Gen.byte()) { value: Byte ->
63+
val seen = Byte.monoid().run { value.combine(value) }
64+
val expected = (value + value).toByte()
6465

65-
expected == seen
66-
}
66+
expected == seen
6767
}
6868
}
6969
}

modules/core/arrow-extras-data/src/main/kotlin/arrow/data/Moore.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@ data class Moore<E, V>(val view: V, val handle: (E) -> Moore<E, V>) : MooreOf<E,
1313

1414
fun extract(): V = view
1515

16+
override fun toString() = "Moore $view"
17+
1618
companion object
1719
}

modules/core/arrow-test/src/main/kotlin/arrow/test/generators/Generators.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ import arrow.typeclasses.ApplicativeError
1414
import io.kotlintest.properties.Gen
1515
import java.util.concurrent.TimeUnit
1616

17+
fun Gen.Companion.short(): Gen<Short> =
18+
Gen.int().filter { it >= Short.MIN_VALUE && it <= Short.MAX_VALUE }.map { it.toShort() }
19+
20+
fun Gen.Companion.byte(): Gen<Byte> =
21+
Gen.int().filter { it >= Byte.MIN_VALUE && it <= Byte.MAX_VALUE }.map { it.toByte() }
22+
1723
fun <F, A> Gen<A>.applicative(AP: Applicative<F>): Gen<Kind<F, A>> =
1824
map { AP.just(it) }
1925

modules/core/arrow-test/src/main/kotlin/arrow/test/laws/Law.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fun throwableEq() = Eq { a: Throwable, b ->
1313
a::class == b::class && a.message == b.message
1414
}
1515

16-
data class Law(val name: String, val test: TestContext.() -> Unit)
16+
data class Law (val name: String, val test: suspend TestContext.() -> Unit)
1717

1818
fun <A> A.equalUnderTheLaw(b: A, eq: Eq<A>): Boolean =
1919
eq.run { eqv(b) }

0 commit comments

Comments
 (0)