Skip to content

Commit

Permalink
Break up large group of .combine() tests
Browse files Browse the repository at this point in the history
  • Loading branch information
doub1ejack committed Oct 8, 2017
1 parent aa160c8 commit 242b703
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/main/scala/catslib/Semigroup.scala
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -45,25 +45,27 @@ object SemigroupSection
* guess how it works in the following examples: * guess how it works in the following examples:
* *
*/ */
def semigroupCombine( def semigroupCombine(res0: Int, res1: List[Int], res2: Option[Int], res3: Option[Int]) = {
res0: Int,
res1: List[Int],
res2: Option[Int],
res3: Option[Int],
res4: Int) = {
import cats.implicits._ import cats.implicits._


Semigroup[Int].combine(1, 2) should be(res0) Semigroup[Int].combine(1, 2) should be(res0)
Semigroup[List[Int]].combine(List(1, 2, 3), List(4, 5, 6)) should be(res1) Semigroup[List[Int]].combine(List(1, 2, 3), List(4, 5, 6)) should be(res1)
Semigroup[Option[Int]].combine(Option(1), Option(2)) should be(res2) Semigroup[Option[Int]].combine(Option(1), Option(2)) should be(res2)
Semigroup[Option[Int]].combine(Option(1), None) should be(res3) Semigroup[Option[Int]].combine(Option(1), None) should be(res3)
}

/** And now try a slightly more complex combination:
*/
def semigroupCombineComplex(res0: Int) = {
import cats.implicits._

Semigroup[Int Int] Semigroup[Int Int]
.combine({ (x: Int) .combine({ (x: Int)
x + 1 x + 1
}, { (x: Int) }, { (x: Int)
x * 10 x * 10
}) })
.apply(6) should be(res4) .apply(6) should be(res0)
} }


/** Many of these types have methods defined directly on them, /** Many of these types have methods defined directly on them,
Expand Down

0 comments on commit 242b703

Please sign in to comment.