diff --git a/input/src/main/scala-2/fix/DiscardCatsEffectIOTest.scala b/input/src/main/scala-2/fix/DiscardCatsEffectIOTest.scala new file mode 100644 index 0000000..683a967 --- /dev/null +++ b/input/src/main/scala-2/fix/DiscardCatsEffectIOTest.scala @@ -0,0 +1,49 @@ +/* +rule = DiscardCatsEffectIO + */ +package fix + +import cats.effect.IO +import scala.concurrent.ExecutionContext +import org.mockito.Mockito +import org.mockito.Mockito.verify + +trait DiscardCatsEffectIOTest { + def f0[R]: IO[Int] + + def f1[R](n: Int): IO[Int] + + def mock: DiscardCatsEffectIOTest + + def f2[R](implicit ec: ExecutionContext): IO[Int] = { + f0[R] // assert: DiscardCatsEffectIO + + f1[R](2) // assert: DiscardCatsEffectIO + + f1[R](3).map(_ + 4) // assert: DiscardCatsEffectIO + + val x1 = f1[R](5) + def x2: IO[Int] = f1[R](5) + + Mockito.verify(mock).f1(3) + Mockito.verify(mock).f1[R](3) + Mockito.verify(mock, Mockito.times(2)).f1(9) + Mockito.verify(mock, Mockito.times(2)).f1[R](9) + Mockito.verify(mock, Mockito.never()).f1(-1) + Mockito.verify(mock, Mockito.never()).f1[R](-1) + + verify(mock).f0[R] + verify(mock).f1(4) + verify(mock).f1[R](4) + verify(mock, Mockito.times(2)).f1(5) + verify(mock, Mockito.times(2)).f1[R](5) + verify(mock, Mockito.never()).f1(8) + verify(mock, Mockito.never()).f1[R](8) + + x1.flatMap(y => x1.map(_ + y)) // assert: DiscardCatsEffectIO + + x1 // assert: DiscardCatsEffectIO + + x1 + } +}