Skip to content

Commit

Permalink
Add tests of kleisli left and right identity laws
Browse files Browse the repository at this point in the history
  • Loading branch information
ceedubs committed Dec 14, 2015
1 parent bdf5648 commit 03ffaa8
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/src/test/scala/cats/tests/OptionTests.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cats
package tests

import cats.laws.{ApplicativeLaws, CoflatMapLaws, FlatMapLaws}
import cats.laws.{ApplicativeLaws, CoflatMapLaws, FlatMapLaws, MonadLaws}
import cats.laws.discipline.{TraverseTests, CoflatMapTests, MonadCombineTests, SerializableTests, MonoidalTests}
import cats.laws.discipline.eq._

Expand Down Expand Up @@ -60,4 +60,20 @@ class OptionTests extends CatsSuite {
isEq.lhs should === (isEq.rhs)
}
}

val monadLaws = MonadLaws[Option]

test("Kleisli left identity") {
forAll { (a: Int, f: Int => Option[Long]) =>
val isEq = monadLaws.kleisliLeftIdentity(a, f)
isEq.lhs should === (isEq.rhs)
}
}

test("Kleisli right identity") {
forAll { (a: Int, f: Int => Option[Long]) =>
val isEq = monadLaws.kleisliRightIdentity(a, f)
isEq.lhs should === (isEq.rhs)
}
}
}

0 comments on commit 03ffaa8

Please sign in to comment.