Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update kotlintest #912

Merged
merged 92 commits into from Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from 78 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
30dea37
wip upgrade kotlin test version
AdrianRaFo Jun 12, 2018
a88c29b
fixed generator wip laws
AdrianRaFo Jun 21, 2018
3165b5d
Merge remote-tracking branch 'origin/master' into arf-854-update-kotl…
AdrianRaFo Jun 21, 2018
24b6a44
updated laws add runner
AdrianRaFo Jun 23, 2018
8575347
update the tests
AdrianRaFo Jun 24, 2018
344dfbb
Merge remote-tracking branch 'origin/master' into arf-854-update-kotl…
AdrianRaFo Jun 26, 2018
8efcc05
Merge branch 'master' into arf-854-update-kotlintest
pakoito Jun 27, 2018
2f5d45f
Merge remote-tracking branch 'origin/master' into arf-854-update-kotl…
AdrianRaFo Jul 2, 2018
8f6048f
address changes requested and update from master
AdrianRaFo Jul 2, 2018
29d516e
Merge branch 'master' into arf-854-update-kotlintest
raulraja Jul 3, 2018
dea62bf
Merge remote-tracking branch 'origin/master' into arf-854-update-kotl…
AdrianRaFo Jul 4, 2018
27a6965
update from master
AdrianRaFo Jul 4, 2018
02ef3e5
Merge remote-tracking branch 'origin/arf-854-update-kotlintest' into …
AdrianRaFo Jul 4, 2018
a7e2f16
Merge branch 'master' into arf-854-update-kotlintest
AdrianRaFo Jul 5, 2018
8e51626
Merge branch 'master' into arf-854-update-kotlintest
AdrianRaFo Jul 11, 2018
7bac603
Merge branch 'master' into arf-854-update-kotlintest
AdrianRaFo Jul 16, 2018
81a4035
Merge remote-tracking branch 'origin/master' into arf-854-update-kotl…
AdrianRaFo Jul 24, 2018
0155484
fix update from master
AdrianRaFo Jul 24, 2018
cab9c01
Merge remote-tracking branch 'origin/master' into arf-854-update-kotl…
AdrianRaFo Jul 25, 2018
eb00a7a
Merge branch 'master' into arf-854-update-kotlintest
pakoito Jul 28, 2018
40746ea
update gradle and junit build
AdrianRaFo Jul 29, 2018
9c19a2a
Merge remote-tracking branch 'origin/master' into arf-854-update-kotl…
AdrianRaFo Jul 29, 2018
63c31ef
Merge remote-tracking branch 'origin/master' into arf-854-update-kotl…
AdrianRaFo Aug 5, 2018
ee58d0f
fix master merge
AdrianRaFo Aug 5, 2018
0661ef8
minor improvement
AdrianRaFo Aug 5, 2018
a0ad0d5
Merge remote-tracking branch 'origin/master' into arf-854-update-kotl…
AdrianRaFo Aug 13, 2018
dd4efc2
fix merge from master
AdrianRaFo Aug 13, 2018
467f09d
Merge branch 'master' into arf-854-update-kotlintest
AdrianRaFo Aug 14, 2018
d5b514c
Merge branch 'master' into arf-854-update-kotlintest
AdrianRaFo Aug 16, 2018
661ed2e
Merge branch 'master' into arf-854-update-kotlintest
AdrianRaFo Aug 20, 2018
6c708d0
Merge branch 'master' into arf-854-update-kotlintest
AdrianRaFo Aug 21, 2018
ad73cce
Merge branch 'master' into arf-854-update-kotlintest
AdrianRaFo Aug 22, 2018
4325f5c
Merge branch 'master' into arf-854-update-kotlintest
AdrianRaFo Aug 29, 2018
c3deb21
Merge branch 'master' into arf-854-update-kotlintest
AdrianRaFo Aug 30, 2018
c4641e2
Merge remote-tracking branch 'origin/master' into arf-854-update-kotl…
AdrianRaFo Sep 19, 2018
31c0637
fix test after update
AdrianRaFo Sep 19, 2018
a55b30a
Merge remote-tracking branch 'origin/arf-854-update-kotlintest' into …
AdrianRaFo Sep 19, 2018
4edce58
Merge remote-tracking branch 'origin/master' into arf-854-update-kotl…
AdrianRaFo Oct 4, 2018
ce9c032
update new tests
AdrianRaFo Oct 5, 2018
7edfbf3
more test fixed
AdrianRaFo Oct 5, 2018
bead26b
Merge remote-tracking branch 'origin/master' into arf-854-update-kotl…
AdrianRaFo Oct 5, 2018
f26e583
Merge branch 'master' into arf-854-update-kotlintest
AdrianRaFo Oct 9, 2018
34b4f2e
Merge branch 'master' into arf-854-update-kotlintest
AdrianRaFo Oct 17, 2018
91bbdf6
Merge remote-tracking branch 'origin/master' into arf-854-update-kotl…
AdrianRaFo Jan 2, 2019
00f6572
fix master merge and some gens
AdrianRaFo Jan 2, 2019
14d9078
Merge remote-tracking branch 'origin/arf-854-update-kotlintest' into …
AdrianRaFo Jan 2, 2019
83b12cc
fix tests
AdrianRaFo Jan 2, 2019
4425bb8
minor test fix
AdrianRaFo Jan 2, 2019
36815fe
fix duplicated test name
AdrianRaFo Jan 2, 2019
8213db6
Merge remote-tracking branch 'origin/master' into arf-854-update-kotl…
AdrianRaFo Jan 4, 2019
0b60643
format gradles
AdrianRaFo Jan 4, 2019
8766514
delete duplicated test
AdrianRaFo Jan 4, 2019
075cd89
fix master merge
AdrianRaFo Jan 4, 2019
527b2a2
minor name change
AdrianRaFo Jan 4, 2019
df0b56e
fix test doing sure that number are distinct
AdrianRaFo Jan 4, 2019
fd0e37f
format gradles
AdrianRaFo Jan 5, 2019
89427cd
fix duplicated test names and duplicated value method
AdrianRaFo Jan 5, 2019
8a30f7f
Merge remote-tracking branch 'origin/master' into arf-854-update-kotl…
AdrianRaFo Jan 5, 2019
5a1fcf9
Merge remote-tracking branch 'origin/master' into arf-854-update-kotl…
AdrianRaFo Jan 8, 2019
a5e0f9d
fix arrow example test
AdrianRaFo Jan 8, 2019
b5aceea
fix var names
AdrianRaFo Jan 8, 2019
6ce0298
monoid laws now use generators
AdrianRaFo Jan 8, 2019
3d5e55c
fix try combine
AdrianRaFo Jan 8, 2019
0ada846
fix sorted map combine (doing it equal as map)
AdrianRaFo Jan 8, 2019
a977d7f
fix stuck tests
AdrianRaFo Jan 9, 2019
5abe025
add runner to missing builds
AdrianRaFo Jan 9, 2019
03a50d0
fix retrofit integration tests
AdrianRaFo Jan 9, 2019
e0a5a9d
fix duplicated name issues
AdrianRaFo Jan 9, 2019
f32457a
Merge branch 'master' into arf-854-update-kotlintest
AdrianRaFo Jan 9, 2019
54ae65b
minor fix
AdrianRaFo Jan 9, 2019
e04a989
Merge remote-tracking branch 'origin/arf-854-update-kotlintest' into …
AdrianRaFo Jan 9, 2019
dc0658a
fix random failure
AdrianRaFo Jan 9, 2019
d136deb
fix io test
AdrianRaFo Jan 9, 2019
c1f2a89
fix more builds
AdrianRaFo Jan 9, 2019
410f687
fix optics tests
AdrianRaFo Jan 9, 2019
7eb6aff
fix aql test id comparison
AdrianRaFo Jan 9, 2019
afd5e11
fix duplicated test names
AdrianRaFo Jan 10, 2019
260e545
temporal aql test fix
AdrianRaFo Jan 10, 2019
86c6a93
delete redundant test
AdrianRaFo Jan 13, 2019
03cfeff
fix format and comment
AdrianRaFo Jan 13, 2019
6b4e864
reset Random per execution
AdrianRaFo Jan 13, 2019
0a025e5
properly format
AdrianRaFo Jan 13, 2019
f828ba4
Optional laws now uses gens
AdrianRaFo Jan 13, 2019
2509305
Merge remote-tracking branch 'origin/master' into arf-854-update-kotl…
AdrianRaFo Jan 13, 2019
92c642e
minor fix
AdrianRaFo Jan 13, 2019
4eec869
lens laws uses generators now
AdrianRaFo Jan 13, 2019
7cddc8b
Merge remote-tracking branch 'origin/master' into arf-854-update-kotl…
nomisRev Jan 13, 2019
bf5d4c9
Fix conflicts merge master
nomisRev Jan 14, 2019
2dcf1d2
Merge branch 'arf-854-update-kotlintest' of github.com:arrow-kt/arrow…
nomisRev Jan 14, 2019
70b1698
Merge branch 'master' into arf-854-update-kotlintest
nomisRev Jan 14, 2019
c7fd7aa
reduce changes with constant generator laws
AdrianRaFo Jan 14, 2019
0486829
minor fix
AdrianRaFo Jan 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 9 additions & 6 deletions build.gradle
Expand Up @@ -20,7 +20,9 @@ buildscript {
gradleVersion = '4.10'
gradleVersionsPluginVersion = '0.20.0'
javaVersion = JavaVersion.VERSION_1_7
kotlinTestVersion = '2.0.7'
jUnitVersion = '4.12'
jUnitVintageVersion = '5.2.0'
kotlinTestVersion = '3.1.5'
kotlinVersion = '1.3.11'
daggerVersion = '2.17'
kotlinxCoroutinesVersion = '1.1.0'
Expand Down Expand Up @@ -155,6 +157,7 @@ subprojects { project ->
compileKotlin.kotlinOptions.freeCompilerArgs += ["-Xskip-runtime-version-check"]

test {
useJUnitPlatform()
testLogging {
exceptionFormat 'full'
events "passed", "skipped", "failed", "standardOut", "standardError"
Expand Down Expand Up @@ -233,15 +236,15 @@ dependencyUpdates {
.findAll { dependency -> dependenciesToCheck.any { it == "${dependency.group}:${dependency.name}" } }

final isRejected = dependencies
.any { dependency -> disallowedQualifiers.any(isDisallowed(dependency)) }
.any { dependency -> disallowedQualifiers.any(isDisallowed(dependency)) }

if (isRejected) {
final title = "\nError: Kotlin and Coroutines must depends on release version!"
final message = dependencies
.inject(title) { acc, dependency ->
"$acc\n${dependency.group}:${dependency.name}:${dependency.version}"
}
.inject(title) { acc, dependency ->
"$acc\n${dependency.group}:${dependency.name}:${dependency.version}"
}

throw new GradleException(message)
}
}
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Expand Up @@ -5,6 +5,8 @@ VERSION_NAME=0.9.0-SNAPSHOT
org.gradle.jvmargs=-Xmx4g
# Kotlin configuration
kotlin.incremental=true
# Kotlin Test configuration
kotlintest.parallelism=2
# Pomfile definitions
POM_DESCRIPTION=Functional companion to Kotlin's Standard Library
POM_URL=https://github.com/arrow-kt/arrow/
Expand Down
18 changes: 8 additions & 10 deletions modules/ank/arrow-ank/src/main/kotlin/arrow/ank/interpreter.kt
Expand Up @@ -9,9 +9,7 @@ import java.nio.file.Files
import java.nio.file.Path
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ConcurrentMap
import javax.script.ScriptContext
import javax.script.ScriptEngine
import javax.script.ScriptEngineManager
import javax.script.*

val extensionMappings = mapOf(
"java" to "java",
Expand Down Expand Up @@ -195,19 +193,19 @@ fun <F> monadDeferInterpreter(MF: MonadDefer<F>): AnkOps<F> = object : AnkOps<F>
}

override fun replaceAnkToLang(content: Sequence<String>, compiledSnippets: Sequence<Snippet>): Sequence<String> =
sequenceOf(compiledSnippets.foldLeft(content.joinToString("\n")) { content, snippet ->
sequenceOf(compiledSnippets.foldLeft(content.joinToString("\n")) { snippetContent, snippet ->
snippet.result.fold(
{ content.replace(snippet.fence, "{: data-executable='true'}\n\n```${snippet.lang}\n${snippet.code}\n```") },
{ snippetContent.replace(snippet.fence, "{: data-executable='true'}\n\n```${snippet.lang}\n${snippet.code}\n```") },
{
when {
// these are extensions declared in type classes that should be removed since the extension generator
// processor is the one in charge of projecting those examples in the generated markdown files
snippet.isPlaygroundExtension -> content.replace(snippet.fence, it)
snippet.isPlaygroundExtension -> snippetContent.replace(snippet.fence, it)
// a regular playground
snippet.isPlayground -> content.replace(snippet.fence, "{: data-executable='true'}\n\n```${snippet.lang}\n${snippet.code}\n$it\n```")
snippet.isReplace -> content.replace(snippet.fence, it)
snippet.isOutFile -> content.replace(snippet.fence, "")
else -> content.replace(snippet.fence, "```${snippet.lang}\n" + snippet.code + "\n" + it + "\n```")
snippet.isPlayground -> snippetContent.replace(snippet.fence, "{: data-executable='true'}\n\n```${snippet.lang}\n${snippet.code}\n$it\n```")
snippet.isReplace -> snippetContent.replace(snippet.fence, it)
snippet.isOutFile -> snippetContent.replace(snippet.fence, "")
else -> snippetContent.replace(snippet.fence, "```${snippet.lang}\n" + snippet.code + "\n" + it + "\n```")
}
}
)
Expand Down
4 changes: 3 additions & 1 deletion modules/aql/arrow-query-language/build.gradle
Expand Up @@ -6,7 +6,9 @@ dependencies {
kaptTest project(':arrow-meta')
compileOnly project(':arrow-meta')
testCompileOnly project(':arrow-meta')
testCompile "io.kotlintest:kotlintest:$kotlinTestVersion"
testRuntime("org.junit.vintage:junit-vintage-engine:$jUnitVintageVersion")
testCompile "io.kotlintest:kotlintest-runner-junit4:$kotlinTestVersion"

testCompile project(':arrow-test')
}

Expand Down
@@ -1,34 +1,33 @@
package arrow.aql.tests

import arrow.aql.Ord
import arrow.aql.extensions.id.select.value
import arrow.aql.extensions.list.count.count
import arrow.aql.extensions.list.count.value
import arrow.aql.extensions.list.from.join
import arrow.aql.extensions.list.groupBy.groupBy
import arrow.aql.extensions.list.select.query
import arrow.aql.extensions.list.orderBy.orderBy
import arrow.aql.extensions.list.orderBy.orderMap
import arrow.aql.extensions.list.select.query
import arrow.aql.extensions.list.select.value
import arrow.aql.extensions.list.orderBy.value
import arrow.aql.extensions.list.sum.sum
import arrow.aql.extensions.list.sum.value
import arrow.aql.extensions.list.union.union
import arrow.aql.extensions.list.where.where
import arrow.aql.extensions.list.where.whereSelection
import arrow.aql.extensions.list.count.count
import arrow.aql.extensions.listk.select.select
import arrow.aql.extensions.listk.select.selectAll
import arrow.aql.extensions.listk.select.value
import arrow.aql.extensions.option.select.query
import arrow.aql.extensions.option.select.select
import arrow.aql.extensions.option.select.value
import arrow.core.Id
import arrow.core.Option
import arrow.core.Some
import arrow.core.extensions.order
import arrow.test.UnitSpec
import io.kotlintest.KTestJUnitRunner
import io.kotlintest.matchers.shouldBe
import io.kotlintest.shouldBe
import io.kotlintest.runner.junit4.KotlinTestRunner
import org.junit.runner.RunWith

@RunWith(KTestJUnitRunner::class)
@RunWith(KotlinTestRunner::class)
class AQLTests : UnitSpec() {

init {
Expand All @@ -47,7 +46,7 @@ class AQLTests : UnitSpec() {

"AQL is able to `select count`" {
listOf(1, 2, 3).query { select { this } }.count()
.value() shouldBe 3L
.value() shouldBe listOf(3L)
}

"AQL is able to `select`, transform and filter data with `where`" {
Expand Down Expand Up @@ -76,7 +75,7 @@ class AQLTests : UnitSpec() {
val jack = Student("Jack", 32)
listOf(john, jane, jack).query {
selectAll() groupBy { age }
}.value() shouldBe Id(mapOf(30 to listOf(john), 32 to listOf(jane, jack)))
}.value() shouldBe mapOf(30 to listOf(john), 32 to listOf(jane, jack))
}

data class Student(val name: String, val age: Int)
Expand All @@ -86,7 +85,7 @@ class AQLTests : UnitSpec() {
val jack = Student("Jack", 32)
val chris = Student("Chris", 40)

"AQL is able to `groupBy`" {
"AQL is able to filter using `where` and then `groupBy`" {
listOf(john, jane, jack).query {
selectAll() where { age > 30 } groupBy { age }
}.value() shouldBe mapOf(32 to listOf(jane, jack))
Expand Down
3 changes: 2 additions & 1 deletion modules/core/arrow-core-data/build.gradle
Expand Up @@ -5,7 +5,8 @@ dependencies {
kaptTest project(':arrow-meta')
compileOnly project(':arrow-meta')
testCompileOnly project(':arrow-meta')
testCompile "io.kotlintest:kotlintest:$kotlinTestVersion"
testRuntime("org.junit.vintage:junit-vintage-engine:$jUnitVintageVersion")
testCompile "io.kotlintest:kotlintest-runner-junit4:$kotlinTestVersion"
testCompile project(':arrow-test')
testCompile project(':arrow-syntax')
testCompile project(':arrow-core-extensions')
Expand Down
8 changes: 3 additions & 5 deletions modules/core/arrow-core-data/src/main/kotlin/arrow/core/Id.kt
Expand Up @@ -2,14 +2,14 @@ package arrow.core

import arrow.higherkind

fun <A> IdOf<A>.value(): A = this.fix().value()
fun <A> IdOf<A>.value(): A = this.fix().extract()

@higherkind
data class Id<out A>(private val value: A) : IdOf<A> {

inline fun <B> map(f: (A) -> B): Id<B> = Id(f(value()))
inline fun <B> map(f: (A) -> B): Id<B> = Id(f(extract()))

inline fun <B> flatMap(f: (A) -> IdOf<B>): Id<B> = f(value()).fix()
inline fun <B> flatMap(f: (A) -> IdOf<B>): Id<B> = f(extract()).fix()

fun <B> foldLeft(initial: B, operation: (B, A) -> B): B = operation(initial, value)

Expand All @@ -19,8 +19,6 @@ data class Id<out A>(private val value: A) : IdOf<A> {

fun extract(): A = value

fun value(): A = value
AdrianRaFo marked this conversation as resolved.
Show resolved Hide resolved

fun <B> ap(ff: IdOf<(A) -> B>): Id<B> = ff.fix().flatMap { f -> map(f) }.fix()

companion object {
Expand Down
Expand Up @@ -14,14 +14,17 @@ import arrow.core.extensions.either.semigroupK.semigroupK
import arrow.core.extensions.either.show.show
import arrow.core.extensions.either.traverse.traverse
import arrow.test.UnitSpec
import arrow.test.generators.genEither
import arrow.test.generators.genIntSmall
import arrow.test.laws.*
import arrow.typeclasses.Eq
import arrow.typeclasses.Hash
import io.kotlintest.KTestJUnitRunner
import io.kotlintest.properties.Gen
import io.kotlintest.properties.forAll
import io.kotlintest.runner.junit4.KotlinTestRunner
import org.junit.runner.RunWith

@RunWith(KTestJUnitRunner::class)
@RunWith(KotlinTestRunner::class)
class EitherTest : UnitSpec() {
val EQ: Eq<Kind<EitherPartialOf<ForId>, Int>> = Eq { a, b ->
a.fix() == b.fix()
Expand All @@ -36,7 +39,7 @@ class EitherTest : UnitSpec() {
testLaws(
BifunctorLaws.laws(Either.bifunctor(), { Right(it) }, EQ2),
SemigroupLaws.laws(Either.semigroup(String.semigroup(), String.semigroup()), Either.right("1"), Either.right("2"), Either.right("3"), Either.eq(String.eq(), String.eq())),
MonoidLaws.laws(Either.monoid(MOL = String.monoid(), MOR = Int.monoid()), Either.right(1), Either.eq(String.eq(), Int.eq())),
MonoidLaws.laws(Either.monoid(MOL = String.monoid(), MOR = Int.monoid()), genEither(Gen.string(), Gen.int()), Either.eq(String.eq(), Int.eq())),
ShowLaws.laws(Either.show(), Either.eq(String.eq(), Int.eq())) { Right(it) },
MonadErrorLaws.laws(Either.monadError(), Eq.any(), Eq.any()),
TraverseLaws.laws(Either.traverse(), Either.applicative(), { Right(it) }, Eq.any()),
Expand Down Expand Up @@ -64,7 +67,7 @@ class EitherTest : UnitSpec() {

"combine a right and a left should return left" {
forAll { a: String, b: String ->
Either.left(a) == Either.left(a).combine(String.monoid(), String.monoid(), Either.right(b))
Either.left(a) == Either.left(a).combine(String.monoid(), String.monoid(), Either.right(b)) &&
Either.left(a) == Either.right(b).combine(String.monoid(), String.monoid(), Either.left(a))
}
}
Expand Down Expand Up @@ -93,7 +96,7 @@ class EitherTest : UnitSpec() {
}

"filterOrElse should filter values" {
forAll { a: Int, b: Int ->
forAll(genIntSmall(), genIntSmall()) { a: Int, b: Int ->
val left: Either<Int, Int> = Left(a)

Right(a).filterOrElse({ it > a - 1 }, { b }) == Right(a)
Expand All @@ -104,7 +107,7 @@ class EitherTest : UnitSpec() {
}

"filterOrOther should filter values" {
forAll { a: Int, b: Int ->
forAll(genIntSmall(), genIntSmall()) { a: Int, b: Int ->
val left: Either<Int, Int> = Left(a)

Right(a).filterOrOther({ it > a - 1 }, { b + a }) == Right(a)
Expand Down Expand Up @@ -144,15 +147,15 @@ class EitherTest : UnitSpec() {
}

"contains should check value" {
forAll { a: Int, b: Int ->
forAll(genIntSmall(), genIntSmall()) { a: Int, b: Int ->
Right(a).contains(a)
&& !Right(a).contains(b)
&& !Left(a).contains(a)
}
}

"mapLeft should alter left instance only" {
forAll { a: Int, b: Int ->
forAll(genIntSmall(), genIntSmall()) { a: Int, b: Int ->
val right: Either<Int, Int> = Right(a)
val left: Either<Int, Int> = Left(b)
right.mapLeft { it + 1 } == right && left.mapLeft { it + 1 } == Left(b + 1)
Expand Down
Expand Up @@ -9,14 +9,14 @@ import arrow.test.concurrency.SideEffect
import arrow.test.laws.ComonadLaws
import arrow.test.laws.MonadLaws
import arrow.typeclasses.Eq
import io.kotlintest.KTestJUnitRunner
import io.kotlintest.matchers.fail
import io.kotlintest.matchers.shouldBe
import io.kotlintest.fail
import io.kotlintest.properties.Gen
import io.kotlintest.properties.forAll
import io.kotlintest.runner.junit4.KotlinTestRunner
import io.kotlintest.shouldBe
import org.junit.runner.RunWith

@RunWith(KTestJUnitRunner::class)
@RunWith(KotlinTestRunner::class)
class EvalTest : UnitSpec() {
val EQ: Eq<Kind<ForEval, Int>> = Eq { a, b ->
a.value() == b.value()
Expand Down Expand Up @@ -155,7 +155,7 @@ class EvalTest : UnitSpec() {
class Defer : O()

companion object {
val gen = Gen.oneOf(
val gen = Gen.oneOf<O>(
Gen.create { O.Map { it + 1 } },
Gen.create { O.FlatMap { Eval.Now(it) } },
Gen.create { O.Memoize() },
Expand Down Expand Up @@ -189,7 +189,7 @@ class EvalTest : UnitSpec() {

val gen = Gen.create {
val leaf = { Eval.Now(0) }
val eval = build(leaf, (0 until maxDepth).map { O.gen.generate() })
val eval = build(leaf, O.gen.random().take(maxDepth).toList())
DeepEval(eval)
}
}
Expand Down
Expand Up @@ -13,11 +13,12 @@ import arrow.test.laws.MonadLaws
import arrow.test.laws.MonoidLaws
import arrow.test.laws.SemigroupLaws
import arrow.typeclasses.Eq
import io.kotlintest.KTestJUnitRunner
import io.kotlintest.properties.Gen
import io.kotlintest.runner.junit4.KotlinTestRunner
import io.kotlintest.properties.forAll
import org.junit.runner.RunWith

@RunWith(KTestJUnitRunner::class)
@RunWith(KotlinTestRunner::class)
class Function0Test : UnitSpec() {
val EQ: Eq<Kind<ForFunction0, Int>> = Eq { a, b ->
a() == b()
Expand All @@ -26,7 +27,7 @@ class Function0Test : UnitSpec() {
init {
testLaws(
SemigroupLaws.laws(Function0.semigroup(Int.semigroup()), { 1 }.k(), { 2 }.k(), { 3 }.k(), EQ),
MonoidLaws.laws(Function0.monoid(Int.monoid()), { 1 }.k(), EQ),
MonoidLaws.laws(Function0.monoid(Int.monoid()), Gen.constant({ 1 }.k()), EQ),
MonadLaws.laws(Function0.monad(), EQ),
ComonadLaws.laws(Function0.comonad(), { { it }.k() }, EQ)
)
Expand Down
Expand Up @@ -15,11 +15,12 @@ import arrow.typeclasses.Conested
import arrow.typeclasses.Eq
import arrow.typeclasses.conest
import arrow.typeclasses.counnest
import io.kotlintest.KTestJUnitRunner
import io.kotlintest.properties.Gen
import io.kotlintest.properties.forAll
import io.kotlintest.runner.junit4.KotlinTestRunner
import org.junit.runner.RunWith

@RunWith(KTestJUnitRunner::class)
@RunWith(KotlinTestRunner::class)
class Function1Test : UnitSpec() {
val ConestedEQ: Eq<Kind<Conested<ForFunction1, Int>, Int>> = Eq { a, b ->
a.counnest().invoke(1) == b.counnest().invoke(1)
Expand All @@ -32,7 +33,7 @@ class Function1Test : UnitSpec() {
init {
testLaws(
SemigroupLaws.laws(Function1.semigroup<Int, Int>(Int.semigroup()), { a: Int -> a + 1 }.k(), { a: Int -> a + 2 }.k(), { a: Int -> a + 3 }.k(), EQ),
MonoidLaws.laws(Function1.monoid<Int, Int>(Int.monoid()), { a: Int -> a + 1 }.k(), EQ),
MonoidLaws.laws(Function1.monoid<Int, Int>(Int.monoid()), Gen.constant({ a: Int -> a + 1 }.k()), EQ),
ContravariantLaws.laws(Function1.contravariant(), { Function1.just<Int, Int>(it).conest() }, ConestedEQ),
ProfunctorLaws.laws(Function1.profunctor(), { Function1.just(it) }, EQ),
MonadLaws.laws(Function1.monad(), EQ),
Expand Down
Expand Up @@ -16,16 +16,17 @@ import arrow.core.extensions.semigroup
import arrow.test.UnitSpec
import arrow.test.laws.*
import arrow.typeclasses.Eq
import io.kotlintest.KTestJUnitRunner
import io.kotlintest.properties.Gen
import io.kotlintest.properties.forAll
import io.kotlintest.runner.junit4.KotlinTestRunner
import org.junit.runner.RunWith

@RunWith(KTestJUnitRunner::class)
@RunWith(KotlinTestRunner::class)
class IdTest : UnitSpec() {
init {
testLaws(
SemigroupLaws.laws(Id.semigroup(Int.semigroup()), Id(1), Id(2), Id(3), Id.eq(Int.eq())),
MonoidLaws.laws(Id.monoid(Int.monoid()), Id(1), Id.eq(Int.eq())),
MonoidLaws.laws(Id.monoid(Int.monoid()), Gen.constant(Id(1)), Id.eq(Int.eq())),
ShowLaws.laws(Id.show(), Eq.any()) { Id(it) },
MonadLaws.laws(Id.monad(), Eq.any()),
TraverseLaws.laws(Id.traverse(), Id.applicative(), ::Id, Eq.any()),
Expand Down