diff --git a/jeorg-kotlin-arrow-crums/jeorg-kotlin-arrow-crums-1/pom.xml b/jeorg-kotlin-arrow-crums/jeorg-kotlin-arrow-crums-1/pom.xml index e7b426440..9a74f7f26 100644 --- a/jeorg-kotlin-arrow-crums/jeorg-kotlin-arrow-crums-1/pom.xml +++ b/jeorg-kotlin-arrow-crums/jeorg-kotlin-arrow-crums-1/pom.xml @@ -12,6 +12,10 @@ org.jesperancinha.console consolerizer + + io.arrow-kt + arrow-analysis-types-jvm + io.arrow-kt arrow-core-jvm @@ -24,7 +28,10 @@ org.jetbrains.kotlin kotlin-stdlib - + + io.kotest + kotest-assertions-core-jvm + org.junit.jupiter junit-jupiter-api diff --git a/jeorg-kotlin-arrow-crums/jeorg-kotlin-arrow-crums-1/src/main/kotlin/org/jesperancinha/aktd/crums1/crum3/ArrowAnalysis.kt b/jeorg-kotlin-arrow-crums/jeorg-kotlin-arrow-crums-1/src/main/kotlin/org/jesperancinha/aktd/crums1/crum3/ArrowAnalysis.kt new file mode 100644 index 000000000..2b0cac20a --- /dev/null +++ b/jeorg-kotlin-arrow-crums/jeorg-kotlin-arrow-crums-1/src/main/kotlin/org/jesperancinha/aktd/crums1/crum3/ArrowAnalysis.kt @@ -0,0 +1,42 @@ +package org.jesperancinha.aktd.crums1.crum3 + +import arrow.analysis.pre +import io.kotest.matchers.shouldBe +import org.jesperancinha.console.consolerizer.console.ConsolerizerComposer + +class ArrowAnalysis { + companion object { + private val logger = object { + fun info(logText: Any) = ConsolerizerComposer.out().magenta(logText) + fun info2(logText: Any) = ConsolerizerComposer.out().brightGreen(logText) + fun infoTitle(logText: String) = ConsolerizerComposer.outSpace() + .brightBlue(ConsolerizerComposer.title(logText)) + + fun error(logText: Any?) = ConsolerizerComposer.out().brightRed(logText) + } + + @JvmStatic + fun main(args: Array) { + fun increment(x: Int): Int { + pre(x > 0) { "value must be positive" } + return x + 1 + } + logger.infoTitle("Crum 3 - Arrow Analysis from https://arrow-kt.io/docs/analysis/conditions/") + run { + val result = try { + increment(0) + } catch (ex: IllegalArgumentException) { + logger.error(ex) + -1 + } + result shouldBe -1 + logger.info("We made a call with 0 and if an exception occurs we get a result of $result") + } + run { + val result = increment(2) + result shouldBe 3 + logger.info2("We made a call with 2 and because its a valid result we get $result") + } + } + } +} \ No newline at end of file diff --git a/jeorg-kotlin-crums/jeorg-kotlin-crums-4/build.gradle.kts b/jeorg-kotlin-crums/jeorg-kotlin-crums-4/build.gradle.kts index 72422db3d..42401f1a8 100644 --- a/jeorg-kotlin-crums/jeorg-kotlin-crums-4/build.gradle.kts +++ b/jeorg-kotlin-crums/jeorg-kotlin-crums-4/build.gradle.kts @@ -6,6 +6,7 @@ allprojects { plugins { id("com.google.devtools.ksp") version "1.8.0-RC-1.0.8" +// id("io.arrow-kt.analysis.kotlin") version "2.0.2" kotlin("jvm") version "1.7.22" application idea diff --git a/jeorg-kotlin-crums/jeorg-kotlin-crums-4/src/main/kotlin/org/jesperancinha/ktd/crums3/MainCrums4.kt b/jeorg-kotlin-crums/jeorg-kotlin-crums-4/src/main/kotlin/org/jesperancinha/ktd/crums3/MainCrums4.kt index f3d9a2677..e2cee6c75 100644 --- a/jeorg-kotlin-crums/jeorg-kotlin-crums-4/src/main/kotlin/org/jesperancinha/ktd/crums3/MainCrums4.kt +++ b/jeorg-kotlin-crums/jeorg-kotlin-crums-4/src/main/kotlin/org/jesperancinha/ktd/crums3/MainCrums4.kt @@ -2,10 +2,12 @@ package org.jesperancinha.ktd.crums3 import org.jesperancinha.ktd.crums3.crum1.CrumOne import org.jesperancinha.ktd.crums3.crum2.CrumTwo -import org.jesperancinha.ktd.crums3.crums3.CrumThree +import org.jesperancinha.ktd.crums3.crum3.CrumThree +import org.jesperancinha.ktd.crums3.crum4.ArrowAnalysis fun main(args: Array = emptyArray()) { CrumOne.main(args) CrumTwo.main(args) CrumThree.main() + ArrowAnalysis.main() } diff --git a/jeorg-kotlin-crums/jeorg-kotlin-crums-4/src/main/kotlin/org/jesperancinha/ktd/crums3/crums3/CrumThree.kt b/jeorg-kotlin-crums/jeorg-kotlin-crums-4/src/main/kotlin/org/jesperancinha/ktd/crums3/crum3/CrumThree.kt similarity index 98% rename from jeorg-kotlin-crums/jeorg-kotlin-crums-4/src/main/kotlin/org/jesperancinha/ktd/crums3/crums3/CrumThree.kt rename to jeorg-kotlin-crums/jeorg-kotlin-crums-4/src/main/kotlin/org/jesperancinha/ktd/crums3/crum3/CrumThree.kt index 3f40f54ab..3dc106352 100644 --- a/jeorg-kotlin-crums/jeorg-kotlin-crums-4/src/main/kotlin/org/jesperancinha/ktd/crums3/crums3/CrumThree.kt +++ b/jeorg-kotlin-crums/jeorg-kotlin-crums-4/src/main/kotlin/org/jesperancinha/ktd/crums3/crum3/CrumThree.kt @@ -1,4 +1,4 @@ -package org.jesperancinha.ktd.crums3.crums3 +package org.jesperancinha.ktd.crums3.crum3 import arrow.optics.optics import org.jesperancinha.console.consolerizer.console.ConsolerizerComposer diff --git a/jeorg-kotlin-crums/jeorg-kotlin-crums-4/src/main/kotlin/org/jesperancinha/ktd/crums3/crum4/ArrowAnalysis.kt b/jeorg-kotlin-crums/jeorg-kotlin-crums-4/src/main/kotlin/org/jesperancinha/ktd/crums3/crum4/ArrowAnalysis.kt new file mode 100644 index 000000000..25e6c4c9f --- /dev/null +++ b/jeorg-kotlin-crums/jeorg-kotlin-crums-4/src/main/kotlin/org/jesperancinha/ktd/crums3/crum4/ArrowAnalysis.kt @@ -0,0 +1,27 @@ +package org.jesperancinha.ktd.crums3.crum4 + +//import arrow.analysis.pre +import org.jesperancinha.console.consolerizer.console.ConsolerizerComposer + +//fun encodeName(name: String): String { +// pre(name.length == 10 && name.matches(Regex("[a-zA-Z]*"))) { "name may only have exactly 10 characters and may only contain letters" } +// return name.map { it.minus('a') }.joinToString { "" } +//} +class ArrowAnalysis { + companion object{ + + private val logger = object { + fun info(logText: Any?) = ConsolerizerComposer.out().orange(logText) + fun info2(logText: Any?) = ConsolerizerComposer.out().red(logText) + fun comment(logText: Any?) = ConsolerizerComposer.out().green(logText) + fun infoTitle(logText: String) = ConsolerizerComposer.outSpace() + .brightMagenta(ConsolerizerComposer.title(logText)) + } + + @JvmStatic + fun main(args: Array = emptyArray()) { +// logger.infoTitle("Crum 3 - Arrow Analysis") +// logger.info(encodeName("Batatucada")) + } + } +} \ No newline at end of file diff --git a/jeorg-kotlin-masters/jeorg-kotlin-constructor/pom.xml b/jeorg-kotlin-masters/jeorg-kotlin-constructor/pom.xml index 50eef2485..d16fac620 100644 --- a/jeorg-kotlin-masters/jeorg-kotlin-constructor/pom.xml +++ b/jeorg-kotlin-masters/jeorg-kotlin-constructor/pom.xml @@ -49,11 +49,9 @@ junit-jupiter test - io.kotest kotest-assertions-core-jvm - 5.5.4 test diff --git a/pom.xml b/pom.xml index 0fa0f9d70..3f9d27f2f 100644 --- a/pom.xml +++ b/pom.xml @@ -44,6 +44,9 @@ 1.1.4-rc.3 1.1.4-rc.3 1.4 + 2.0.3-alpha.2 + 4.0.7 + 5.5.4 @@ -63,6 +66,11 @@ jakarta.validation-api ${jakarta.validation-api.version} + + io.arrow-kt + arrow-analysis-types-jvm + ${arrow-analysis-types-jvm.version} + org.jesperancinha.console consolerizer @@ -113,6 +121,26 @@ arrow-optics ${arrow.version} + + io.kotest + kotest-assertions + ${kotest.version} + + + io.kotest + kotest-assertions-api-jvm + ${kotest-assertions.version} + + + io.kotest + kotest-assertions-core-jvm + ${kotest-assertions.version} + + + io.kotest + kotest-assertions-shared-jvm + ${kotest-assertions.version} + org.jetbrains.kotlin kotlin-test-junit