Skip to content

Commit

Permalink
One more flatMap test
Browse files Browse the repository at this point in the history
  • Loading branch information
lenguyenthanh committed Jul 9, 2023
1 parent b72bd66 commit 133c52c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/main/scala/ByColor.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package chess

import cats.{ Applicative, Eq, Functor, Monoid }
import cats.{ Applicative, Eq, Eval, Functor, Monoid, Traverse }
import cats.syntax.all.*
import scala.annotation.targetName
import alleycats.Zero
import cats.Traverse
import cats.Eval

case class ByColor[A](white: A, black: A):

Expand Down
4 changes: 4 additions & 0 deletions src/test/scala/ByColorTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ class ByColorTest extends ScalaCheckSuite:
forAll: (bc: ByColor[Option[Int]]) =>
bc.flatten == bc.flatMap(identity)

test("flatMap == all.flatMap"):
forAll: (bc: ByColor[Int], f: Int => Option[String]) =>
bc.flatMap(f) == bc.all.flatMap(f(_))

test("fold"):
forAll: (bc: ByColor[Int], init: String, f: (String, Int) => String) =>
bc.fold(init)(f) == bc.all.foldLeft(init)(f)
Expand Down

0 comments on commit 133c52c

Please sign in to comment.