Skip to content

Commit

Permalink
Remove cyclic dependencies by moving all tests to Arrow Core Test
Browse files Browse the repository at this point in the history
  • Loading branch information
nomisRev committed Jun 2, 2021
1 parent 1db8fe9 commit e674740
Show file tree
Hide file tree
Showing 49 changed files with 138 additions and 169 deletions.
15 changes: 0 additions & 15 deletions arrow-libs/core/arrow-continuations/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,15 @@ kotlin {
compileOnly "org.jetbrains.kotlin:kotlin-stdlib:$KOTLIN_VERSION"
}
}
commonTest {
dependencies {
implementation project(":arrow-core-test")
}
}
jvmMain {
dependencies {
compileOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION"
}
}
jvmTest {
dependencies {
runtimeOnly "io.kotest:kotest-runner-junit5:$KOTEST_VERSION"
}
}
jsMain {
dependencies {
compileOnly "org.jetbrains.kotlin:kotlin-stdlib-js:$KOTLIN_VERSION"
}
}
jsTest {
dependencies {
implementation "io.kotest:kotest-framework-engine:$KOTEST_VERSION"
}
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions arrow-libs/core/arrow-core-retrofit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,4 @@ dependencies {
compileOnly "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION"
compileOnly project(":arrow-core")
compileOnly "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"
testCompileOnly "org.jetbrains.kotlin:kotlin-reflect:$KOTLIN_VERSION"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine:$JUNIT_VINTAGE_VERSION"
testImplementation project(":arrow-core-test")
testImplementation "com.squareup.retrofit2:converter-gson:$RETROFIT_VERSION"
testImplementation "com.squareup.okhttp3:mockwebserver:$MOCKWEBSERVER_VERSION"
}
23 changes: 23 additions & 0 deletions arrow-libs/core/arrow-core-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,33 @@ kotlin {
api "io.kotest:kotest-assertions-core:$KOTEST_VERSION"
}
}
commonTest {
dependencies {
implementation project(":arrow-core-test")
}
}
jvmMain {
dependencies {
compileOnly "org.jetbrains.kotlin:kotlin-stdlib:$KOTLIN_VERSION"
}
}
jvmTest {
dependencies {
runtimeOnly "io.kotest:kotest-runner-junit5:$KOTEST_VERSION"
compileOnly "org.jetbrains.kotlin:kotlin-reflect:$KOTLIN_VERSION"
implementation "com.squareup.retrofit2:converter-gson:$RETROFIT_VERSION"
implementation "com.squareup.okhttp3:mockwebserver:$MOCKWEBSERVER_VERSION"
}
}
jsMain {
dependencies {
compileOnly "org.jetbrains.kotlin:kotlin-stdlib-js:$KOTLIN_VERSION"
}
}
jsTest {
dependencies {
implementation "io.kotest:kotest-framework-engine:$KOTEST_VERSION"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package generic
package arrow.continuations

import arrow.core.computations.either
import arrow.core.Either.Right
import arrow.core.Either.Left
import arrow.core.Some
import arrow.core.computations.option
import io.kotest.assertions.fail
import io.kotest.matchers.shouldBe
import io.kotest.assertions.throwables.shouldThrow
Expand Down Expand Up @@ -71,7 +73,7 @@ class SuspendingComputationTest : StringSpec({

"Can short-circuit immediately from nested blocks" {
either<String, Int> {
val x = maybeEff {
val x = option {
Left("test").bind()
5L
}
Expand All @@ -83,7 +85,7 @@ class SuspendingComputationTest : StringSpec({

"Can short-circuit suspended from nested blocks" {
either<String, Int> {
val x = maybeEff {
val x = option {
Left("test").suspend().bind()
5L
}
Expand All @@ -95,8 +97,8 @@ class SuspendingComputationTest : StringSpec({

"Can short-circuit immediately after suspending from nested blocks" {
either<String, Int> {
val x = maybeEff {
Just(1L).suspend().bind()
val x = option {
Some(1L).suspend().bind()
Left("test").suspend().bind()
5L
}
Expand All @@ -108,8 +110,8 @@ class SuspendingComputationTest : StringSpec({

"Can short-circuit suspended after suspending from nested blocks" {
either<String, Int> {
val x = maybeEff {
Just(1L).suspend().bind()
val x = option {
Some(1L).suspend().bind()
Left("test").suspend().bind()
5L
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
//package arrow.continuations
//
//import arrow.continuations.generic.RestrictedScope
//import arrow.core.Either
//import arrow.core.Either.Left
//import arrow.core.identity
//import arrow.core.test.UnitSpec
//import io.kotest.matchers.shouldBe
//
//abstract class ContTestSuite : UnitSpec() {
// abstract suspend fun <A> runScope(func: (suspend RestrictedScope<A>.() -> A)): A
//
// abstract fun capabilities(): Set<ScopeCapabilities>
//
// init {
// "yield a list (also verifies stacksafety)" {
// runScope<List<Int>> {
// suspend fun <A> RestrictedScope<List<A>>.yield(a: A): Unit = shift { k -> listOf(a) + k(Unit) }
// for (i in 0..10_000) yield(i)
// emptyList()
// } shouldBe (0..10_000).toList()
// }
// "short circuit" {
// runScope<Either<String, Int>> {
// val no: Int = shift { Left("No thank you") }
// throw IllegalStateException("This should not be executed")
// } shouldBe Left("No thank you")
// }
//
// // some examples from http://homes.sice.indiana.edu/ccshan/recur/recur.pdf
// if (capabilities().contains(ScopeCapabilities.MultiShot)) {
// "multshot nondet" {
// runScope<List<Pair<Int, Int>>> {
// val i: Int = shift { k -> k(10) + k(20) }
// val j: Int = shift { k -> k(15) + k(25) }
// listOf(i to j)
// } shouldBe listOf(10 to 15, 10 to 25, 20 to 15, 20 to 25)
// }
// "multishot more than twice" {
// runScope<List<Triple<Int, Int, Int>>> {
// val i: Int = shift { k -> k(10) + k(20) }
// val j: Int = shift { k -> k(15) + k(25) }
// val k: Int = shift { k -> k(17) + k(27) }
// listOf(Triple(i, j, k))
// } shouldBe listOf(10, 20).flatMap { i -> listOf(15, 25).flatMap { j -> listOf(17, 27).map { k -> Triple(i, j, k) } } }
// }
// "multishot more than twice and with more multishot invocations" {
// runScope<List<Triple<Int, Int, Int>>> {
// val i: Int = shift { k -> k(10) + k(20) + k(30) + k(40) + k(50) }
// val j: Int = shift { k -> k(15) + k(25) + k(35) + k(45) + k(55) }
// val k: Int = shift { k -> k(17) + k(27) + k(37) + k(47) + k(57) }
// listOf(Triple(i, j, k))
// } shouldBe
// listOf(10, 20, 30, 40, 50)
// .flatMap { i ->
// listOf(15, 25, 35, 45, 55)
// .flatMap { j ->
// listOf(17, 27, 37, 47, 57)
// .map { k -> Triple(i, j, k) }
// }
// }
// }
// "multishot is stacksafe regardless of stack size" {
// runScope<Int> {
// // bring 10k elements on the stack
// var sum = 0
// for (i0 in 1..10_000) sum += shift<Int> { it(i0) }
//
// // run the continuation from here 10k times and sum the results
// // This is about as bad as a scenario as it gets :)
// val j: Int = shift {
// var sum2 = 0
// for (i0 in 1..10_000) sum2 += it(i0)
// sum2
// }
//
// sum + j
// }
// }
// }
// }
//}
//
//sealed class ScopeCapabilities {
// object MultiShot : ScopeCapabilities()
//}
//
//class SingleShotContTestSuite : ContTestSuite() {
// override suspend fun <A> runScope(func: (suspend RestrictedScope<A>.() -> A)): A =
// Reset.restricted { func(this) }
//
// override fun capabilities(): Set<ScopeCapabilities> = emptySet()
//}
//
//class MultiShotContTestSuite : ContTestSuite() {
// override suspend fun <A> runScope(func: (suspend RestrictedScope<A>.() -> A)): A =
// MultiShotDelimContScope.reset { func(this) }
//
// override fun capabilities(): Set<ScopeCapabilities> = setOf(ScopeCapabilities.MultiShot)
//}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import arrow.core.test.laws.MonoidLaws
import arrow.core.test.laws.SemiringLaws
import arrow.typeclasses.Monoid
import arrow.typeclasses.Semiring
import io.kotest.assertions.fail
import io.kotest.matchers.shouldBe
import io.kotest.property.Arb
import io.kotest.property.arbitrary.byte
Expand Down Expand Up @@ -40,6 +41,10 @@ class NumberInstancesTest : UnitSpec() {

/** Semigroup specific instance check */

"This test in numbers should fail" {
fail("This fail was expected, the js tests are running!")
}

"should semigroup with the instance passed - int" {
checkAll { value: Int ->
val seen = Monoid.int().run { value.combine(value) }
Expand Down
Loading

0 comments on commit e674740

Please sign in to comment.