Skip to content

Commit 9d92797

Browse files
committed
Add redeem and redeemWith syntax tests
1 parent 1385170 commit 9d92797

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

tests/src/test/scala/cats/tests/SyntaxSuite.scala

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ object SyntaxSuite
379379
val done = a.tailRecM[F, B](a => returnValue)
380380
}
381381

382-
def testApplicativeError[F[_, _], E, A](implicit F: ApplicativeError[F[E, *], E]): Unit = {
382+
def testApplicativeError[F[_, _], E, A, B](implicit F: ApplicativeError[F[E, *], E]): Unit = {
383383
type G[X] = F[E, X]
384384

385385
val e = mock[E]
@@ -402,12 +402,49 @@ object SyntaxSuite
402402

403403
val pfegea = mock[PartialFunction[E, G[A]]]
404404
val gea4 = ga.recoverWith(pfegea)
405+
406+
val eb = mock[E => B]
407+
val ab = mock[A => B]
408+
val gb: G[B] = gea.redeem(eb, ab)
405409
}
406410

407411
def testApplicativeErrorSubtype[F[_], A](implicit F: ApplicativeError[F, CharSequence]): Unit = {
408412
val fea = "meow".raiseError[F, A]
409413
}
410414

415+
def testMonadError[F[_, _], E, A, B](implicit F: MonadError[F[E, *], E]): Unit = {
416+
type G[X] = F[E, X]
417+
418+
val e = mock[E]
419+
val ga = e.raiseError[G, A]
420+
421+
val gea = mock[G[A]]
422+
423+
val ea = mock[E => A]
424+
val gea1 = ga.handleError(ea)
425+
426+
val egea = mock[E => G[A]]
427+
val gea2 = ga.handleErrorWith(egea)
428+
429+
val gxea = ga.attempt
430+
431+
val gxtea = ga.attemptT
432+
433+
val pfea = mock[PartialFunction[E, A]]
434+
val gea3 = ga.recover(pfea)
435+
436+
val pfegea = mock[PartialFunction[E, G[A]]]
437+
val gea4 = ga.recoverWith(pfegea)
438+
439+
val eb = mock[E => B]
440+
val ab = mock[A => B]
441+
val gb: G[B] = gea.redeem(eb, ab)
442+
443+
val efb = mock[E => G[B]]
444+
val afb = mock[A => G[B]]
445+
val gb2: G[B] = gea.redeemWith(efb, afb)
446+
}
447+
411448
def testNested[F[_], G[_], A]: Unit = {
412449
val fga: F[G[A]] = mock[F[G[A]]]
413450

0 commit comments

Comments
 (0)