Skip to content

Commit

Permalink
test: add tests for Functor
Browse files Browse the repository at this point in the history
  • Loading branch information
csgn committed Sep 14, 2024
1 parent d0ea9d3 commit c8cada4
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/src/test/scala/kuram/tests/FunctorSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,24 @@

package kuram.tests

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

class FunctorSuite extends munit.FunSuite {
private val laws = FunctorLaws[Id]

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

test("composition") {
val f: String => Int = _.length
val g: Int => Int = _ * 2

val isEq = laws.composition(Id("test"), f, g)
assert(isEq.a === isEq.b)
}
}

0 comments on commit c8cada4

Please sign in to comment.