diff --git a/core/src/main/scala/cats/data/OptionT.scala b/core/src/main/scala/cats/data/OptionT.scala index 7d57d68160..e76e025755 100644 --- a/core/src/main/scala/cats/data/OptionT.scala +++ b/core/src/main/scala/cats/data/OptionT.scala @@ -87,7 +87,7 @@ final case class OptionT[F[_], A](value: F[Option[A]]) { transform(_.flatMap(f)) /** - * Perform an effect if the value inside the is a `None`, leaving the result untouched. Equivalent to [[orElseF]] + * Perform an effect if the value inside the is a `None`, leaving the value untouched. Equivalent to [[orElseF]] * with an effect returning `None` as argument. */ def flatTapNone[B](f: => F[B])(implicit F: Monad[F]): OptionT[F, A] = diff --git a/tests/src/test/scala/cats/tests/OptionTSuite.scala b/tests/src/test/scala/cats/tests/OptionTSuite.scala index c9ea0ae5a0..f6189a15c3 100644 --- a/tests/src/test/scala/cats/tests/OptionTSuite.scala +++ b/tests/src/test/scala/cats/tests/OptionTSuite.scala @@ -199,6 +199,25 @@ class OptionTSuite extends CatsSuite { } } + test("foldF and cataF consistent") { + forAll { (o: OptionT[List, Int], s: String, f: Int => List[String]) => + o.foldF(List(s))(f) should ===(o.cataF(List(s), f)) + } + } + + test("fold and foldF consistent") { + forAll { (o: OptionT[List, Int], s: String, f: Int => String) => + val f2 = f.andThen(i => List(i)) + o.fold(s)(f) should ===(o.foldF(List(s))(f2)) + } + } + + test("flatTapNone doesn't change value inside") { + forAll { (o: OptionT[Eval, Int], f: Eval[String]) => + o.flatTapNone(f) should ===(o) + } + } + test("OptionT[Id, A].fold consistent with Option.fold") { forAll { (o: Option[Int], s: String, f: Int => String) => o.fold(s)(f) should ===(OptionT[Id, Int](o).fold(s)(f))