Skip to content

Commit 48cc4b0

Browse files
Merge pull request #61 from doub1ejack/uncombine
Break apart a set of five tests
2 parents aa160c8 + d5fd1b9 commit 48cc4b0

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/main/scala/catslib/Semigroup.scala

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,27 @@ object SemigroupSection
4545
* guess how it works in the following examples:
4646
*
4747
*/
48-
def semigroupCombine(
49-
res0: Int,
50-
res1: List[Int],
51-
res2: Option[Int],
52-
res3: Option[Int],
53-
res4: Int) = {
48+
def semigroupCombine(res0: Int, res1: List[Int], res2: Option[Int], res3: Option[Int]) = {
5449
import cats.implicits._
5550

5651
Semigroup[Int].combine(1, 2) should be(res0)
5752
Semigroup[List[Int]].combine(List(1, 2, 3), List(4, 5, 6)) should be(res1)
5853
Semigroup[Option[Int]].combine(Option(1), Option(2)) should be(res2)
5954
Semigroup[Option[Int]].combine(Option(1), None) should be(res3)
55+
}
56+
57+
/** And now try a slightly more complex combination:
58+
*/
59+
def semigroupCombineComplex(res0: Int) = {
60+
import cats.implicits._
61+
6062
Semigroup[Int Int]
6163
.combine({ (x: Int)
6264
x + 1
6365
}, { (x: Int)
6466
x * 10
6567
})
66-
.apply(6) should be(res4)
68+
.apply(6) should be(res0)
6769
}
6870

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

src/test/scala/catslib/SemigroupSpec.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,16 @@ class SemigroupSpec extends RefSpec with Checkers {
1616
check(
1717
Test.testSuccess(
1818
SemigroupSection.semigroupCombine _,
19-
3 :: List(1, 2, 3, 4, 5, 6) :: Option(3) :: Option(1) :: 67 :: HNil
19+
3 :: List(1, 2, 3, 4, 5, 6) :: Option(3) :: Option(1) :: HNil
20+
)
21+
)
22+
}
23+
24+
def `has an advanced combine operation` = {
25+
check(
26+
Test.testSuccess(
27+
SemigroupSection.semigroupCombineComplex _,
28+
67 :: HNil
2029
)
2130
)
2231
}

0 commit comments

Comments
 (0)