Skip to content

Commit

Permalink
test: add tests for Applicative
Browse files Browse the repository at this point in the history
  • Loading branch information
csgn committed Sep 14, 2024
1 parent 51dccf1 commit a5e9aef
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion tests/src/test/scala/kuram/tests/ApplicativeSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,38 @@

package kuram.tests

class ApplicativeSuite extends munit.FunSuite {}
import kuram.laws.ApplicativeLaws
import kuram.data.Id
import kuram.instances.id.given
import kuram.syntax.eq.*

class ApplicativeSuite extends munit.FunSuite {
private val laws = ApplicativeLaws[Id]

test("identity") {
val isEq = laws.identity(Id(1))
assert(isEq.a === isEq.b)
}

test("leftIdentity") {
val isEq = laws.leftIdentity(Id(1))
assert(isEq.a === isEq.b)
}

test("rightIdentity") {
val isEq = laws.rightIdentity(Id(1))
assert(isEq.a === isEq.b)
}

test("homomorphism") {
val f: String => Int = _.length
val isEq = laws.homomorphism("test")(f)
assert(isEq.a === isEq.b)
}

test("interchange") {
val f: String => Int = _.length
val isEq = laws.interchange("test")(Id(f))
assert(isEq.a === isEq.b)
}
}

0 comments on commit a5e9aef

Please sign in to comment.