Skip to content

Commit

Permalink
arrow-kt adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
PLE12366834 committed Feb 25, 2021
1 parent c0e6363 commit 7e06a46
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 164 deletions.
5 changes: 5 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import com.jfrog.bintray.gradle.BintrayExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformJvmPlugin
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

buildscript {
repositories {
Expand Down Expand Up @@ -112,4 +113,8 @@ subprojects {
csv.isEnabled = false
}
}

tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true

kotlinVersion=1.3.41
kotlinVersion=1.3.50

bintray=1.8.4
coroutines=1.3.0-RC2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@ internal class DigitTest : StringSpec() {
init {
"of(Int)" {
forAll(Gen.choose(0, 10)) { a: Int ->
Digit.of(a).nonEmpty()
Digit.of(a) != null
}

forAll(Gen.negativeIntegers()) { a: Int ->
Digit.of(a).isEmpty()
Digit.of(a) == null
}

forAll(Gen.integersOver9()) { a: Int ->
Digit.of(a).isEmpty()
Digit.of(a) == null
}
}

"of(String)" {
forAll(Gen.choose(0, 10)) { a: Int ->
Digit.of(a.toString()).nonEmpty()
Digit.of(a.toString()) != null
}

forAll(Gen.negativeIntegers()) { a: Int ->
Digit.of(a.toString()).isEmpty()
Digit.of(a.toString()) == null
}

forAll(Gen.integersOver9()) { a: Int ->
Digit.of(a).isEmpty()
Digit.of(a) == null
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ internal class NaturalNumberTest : StringSpec() {
init {
"of" {
forAll(Gen.positiveIntegers()) { a: Int ->
NaturalNumber.of(a).nonEmpty()
NaturalNumber.of(a) != null
}

forAll(Gen.negativeIntegers()) { a: Int ->
NaturalNumber.of(a).isEmpty()
NaturalNumber.of(a) == null
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.virtuslab.basetypes.refined

import arrow.core.None
import arrow.core.toOption
import io.kotlintest.properties.Gen
import io.kotlintest.properties.forAll
import io.kotlintest.specs.StringSpec
Expand All @@ -12,11 +10,11 @@ internal class NonNegativeRealNumberTest : StringSpec() {

"of" {
forAll(Gen.positiveDoubles()) { a: Double ->
NonNegativeRealNumber.of(a).nonEmpty()
NonNegativeRealNumber.of(a) != null
}

forAll(Gen.from(listOf(-1.0, -1.5, -2.0, -2.5, -3.0, -3.5))) { a: Double ->
NonNegativeRealNumber.of(a).isEmpty()
NonNegativeRealNumber.of(a) == null
}
}

Expand All @@ -37,25 +35,25 @@ internal class NonNegativeRealNumberTest : StringSpec() {
"minus" {
forAll(Gen.from(positiveDoubles), Gen.from(positiveDoubles)) { a: Double, b: Double ->
if (a >= b) {
NonNegativeRealNumber(a) - NonNegativeRealNumber(b) == NonNegativeRealNumber(a - b).toOption()
NonNegativeRealNumber(a) - NonNegativeRealNumber(b) == NonNegativeRealNumber(a - b)
} else {
NonNegativeRealNumber(a) - NonNegativeRealNumber(b) == None
NonNegativeRealNumber(a) - NonNegativeRealNumber(b) == null
}
}

forAll(Gen.from(positiveDoubles.reversed()), Gen.from(positiveDoubles)) { a: Double, b: Double ->
if (a >= b) {
NonNegativeRealNumber(a) - b == NonNegativeRealNumber(a - b).toOption()
NonNegativeRealNumber(a) - b == NonNegativeRealNumber(a - b)
} else {
NonNegativeRealNumber(a) - b == None
NonNegativeRealNumber(a) - b == null
}
}

forAll(Gen.from(positiveDoubles.reversed()), Gen.positiveIntegers()) { a: Double, b: Int ->
if (a >= b) {
NonNegativeRealNumber(a) - b == NonNegativeRealNumber(a - b).toOption()
NonNegativeRealNumber(a) - b == NonNegativeRealNumber(a - b)
} else {
NonNegativeRealNumber(a) - b == None
NonNegativeRealNumber(a) - b == null
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.virtuslab.basetypes.refined

import arrow.core.None
import arrow.core.toOption
import io.kotlintest.properties.Gen
import io.kotlintest.properties.forAll
import io.kotlintest.specs.StringSpec
Expand All @@ -10,11 +8,11 @@ internal class WholeNumberTest : StringSpec() {
init {
"of" {
forAll(Gen.positiveIntegers()) { a: Int ->
WholeNumber.of(a).nonEmpty()
WholeNumber.of(a) != null
}

forAll(Gen.negativeIntegers()) { a: Int ->
WholeNumber.of(a).isEmpty()
WholeNumber.of(a) == null
}
}

Expand All @@ -26,20 +24,20 @@ internal class WholeNumberTest : StringSpec() {

"decrement" {
forAll(Gen.positiveIntegers()) { a: Int ->
WholeNumber(a).decrement() == WholeNumber(a - 1).toOption()
WholeNumber(a).dec() == WholeNumber(a - 1)
}

forAll(Gen.from(listOf(0))) { zero ->
WholeNumber(zero).decrement().isEmpty()
WholeNumber(zero).dec() == null
}
}

"minus" {
forAll(Gen.positiveIntegers(), Gen.positiveIntegers()) { a, b ->
if (a >= b) {
WholeNumber(a) - WholeNumber(b) == WholeNumber(a-b).toOption()
WholeNumber(a) - WholeNumber(b) == WholeNumber(a - b)
} else {
WholeNumber(a) - WholeNumber(b) == None
WholeNumber(a) - WholeNumber(b) == null
}
}
}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ import reactor.test.test
fun <V> MonoK<V>.test() = mono.map { it as V }.test()

fun <V> FluxK<V>.test() = flux.map { it as V }.test()

internal object SomeException : RuntimeException()

0 comments on commit 7e06a46

Please sign in to comment.