From 91d541e8cc62e16ab260f2313eb816076c4910db Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Mon, 21 Aug 2023 23:10:53 +0000 Subject: [PATCH] Migrate kernel and law tests to munit --- build.sbt | 7 ++-- .../{SyntaxSpec.scala => SyntaxSuite.scala} | 6 +-- .../{BaseSpec.scala => BaseSuite.scala} | 2 +- .../{OutcomeSpec.scala => OutcomeSuite.scala} | 6 +-- .../{ClockSpec.scala => ClockSuite.scala} | 5 +-- ...cSpec.scala => EitherTFreeSyncSuite.scala} | 10 ++--- ...cSpec.scala => EitherTPureConcSuite.scala} | 6 +-- ...FreeSyncSpec.scala => FreeSyncSuite.scala} | 10 ++--- ...poralSpec.scala => GenTemporalSuite.scala} | 38 +++++++----------- ...SyncSpec.scala => IorTFreeSyncSuite.scala} | 10 ++--- ...ConcSpec.scala => IorTPureConcSuite.scala} | 6 +-- ...cSpec.scala => KleisliFreeSyncSuite.scala} | 10 ++--- ...cSpec.scala => KleisliPureConcSuite.scala} | 20 +++++----- ...cSpec.scala => OptionTFreeSyncSuite.scala} | 5 +-- ...cSpec.scala => OptionTPureConcSuite.scala} | 19 ++++----- ...PureConcSpec.scala => PureConcSuite.scala} | 40 ++++++++++--------- ... => ReaderWriterStateTFreeSyncSuite.scala} | 17 ++++---- ... => ReaderWriterStateTPureConcSuite.scala} | 13 +++--- ...Spec.scala => ResourcePureConcSuite.scala} | 11 +++-- ...ncSpec.scala => StateTFreeSyncSuite.scala} | 10 ++--- ...ncSpec.scala => StateTPureConcSuite.scala} | 14 ++++--- ...cSpec.scala => WriterTFreeSyncSuite.scala} | 10 ++--- ...cSpec.scala => WriterTPureConcSuite.scala} | 6 +-- .../{TimeTSpec.scala => TimeTSuite.scala} | 6 +-- 24 files changed, 130 insertions(+), 157 deletions(-) rename kernel/shared/src/test/scala/cats/effect/kernel/{SyntaxSpec.scala => SyntaxSuite.scala} (97%) rename laws/shared/src/test/scala/cats/effect/{BaseSpec.scala => BaseSuite.scala} (99%) rename laws/shared/src/test/scala/cats/effect/kernel/{OutcomeSpec.scala => OutcomeSuite.scala} (91%) rename laws/shared/src/test/scala/cats/effect/laws/{ClockSpec.scala => ClockSuite.scala} (83%) rename laws/shared/src/test/scala/cats/effect/laws/{EitherTFreeSyncSpec.scala => EitherTFreeSyncSuite.scala} (89%) rename laws/shared/src/test/scala/cats/effect/laws/{EitherTPureConcSpec.scala => EitherTPureConcSuite.scala} (89%) rename laws/shared/src/test/scala/cats/effect/laws/{FreeSyncSpec.scala => FreeSyncSuite.scala} (89%) rename laws/shared/src/test/scala/cats/effect/laws/{GenTemporalSpec.scala => GenTemporalSuite.scala} (72%) rename laws/shared/src/test/scala/cats/effect/laws/{IorTFreeSyncSpec.scala => IorTFreeSyncSuite.scala} (88%) rename laws/shared/src/test/scala/cats/effect/laws/{IorTPureConcSpec.scala => IorTPureConcSuite.scala} (89%) rename laws/shared/src/test/scala/cats/effect/laws/{KleisliFreeSyncSpec.scala => KleisliFreeSyncSuite.scala} (88%) rename laws/shared/src/test/scala/cats/effect/laws/{KleisliPureConcSpec.scala => KleisliPureConcSuite.scala} (93%) rename laws/shared/src/test/scala/cats/effect/laws/{OptionTFreeSyncSpec.scala => OptionTFreeSyncSuite.scala} (87%) rename laws/shared/src/test/scala/cats/effect/laws/{OptionTPureConcSpec.scala => OptionTPureConcSuite.scala} (79%) rename laws/shared/src/test/scala/cats/effect/laws/{PureConcSpec.scala => PureConcSuite.scala} (63%) rename laws/shared/src/test/scala/cats/effect/laws/{ReaderWriterStateTFreeSyncSpec.scala => ReaderWriterStateTFreeSyncSuite.scala} (81%) rename laws/shared/src/test/scala/cats/effect/laws/{ReaderWriterStateTPureConcSpec.scala => ReaderWriterStateTPureConcSuite.scala} (85%) rename laws/shared/src/test/scala/cats/effect/laws/{ResourcePureConcSpec.scala => ResourcePureConcSuite.scala} (89%) rename laws/shared/src/test/scala/cats/effect/laws/{StateTFreeSyncSpec.scala => StateTFreeSyncSuite.scala} (88%) rename laws/shared/src/test/scala/cats/effect/laws/{StateTPureConcSpec.scala => StateTPureConcSuite.scala} (78%) rename laws/shared/src/test/scala/cats/effect/laws/{WriterTFreeSyncSpec.scala => WriterTFreeSyncSuite.scala} (88%) rename laws/shared/src/test/scala/cats/effect/laws/{WriterTPureConcSpec.scala => WriterTPureConcSuite.scala} (89%) rename laws/shared/src/test/scala/cats/effect/testkit/{TimeTSpec.scala => TimeTSuite.scala} (92%) diff --git a/build.sbt b/build.sbt index 82a522f7a7..eabd1c5a5e 100644 --- a/build.sbt +++ b/build.sbt @@ -312,6 +312,8 @@ val Specs2Version = "4.20.0" val ScalaCheckVersion = "1.17.0" val DisciplineVersion = "1.4.0" val CoopVersion = "1.2.0" +val MUnitVersion = "1.0.0-M8" +val DisciplineMUnitVersion = "2.0.0-M3" val MacrotaskExecutorVersion = "1.1.1" @@ -393,8 +395,7 @@ lazy val kernel = crossProject(JSPlatform, JVMPlatform, NativePlatform) .settings( name := "cats-effect-kernel", libraryDependencies ++= Seq( - "org.typelevel" %%% "cats-core" % CatsVersion, - "org.specs2" %%% "specs2-core" % Specs2Version % Test + "org.typelevel" %%% "cats-core" % CatsVersion ), mimaBinaryIssueFilters ++= Seq( ProblemFilters.exclude[MissingClassProblem]("cats.effect.kernel.Ref$SyncRef"), @@ -451,7 +452,7 @@ lazy val laws = crossProject(JSPlatform, JVMPlatform, NativePlatform) name := "cats-effect-laws", libraryDependencies ++= Seq( "org.typelevel" %%% "cats-laws" % CatsVersion, - "org.typelevel" %%% "discipline-specs2" % DisciplineVersion % Test) + "org.typelevel" %%% "discipline-munit" % DisciplineMUnitVersion % Test) ) .disablePlugins(JCStressPlugin) diff --git a/kernel/shared/src/test/scala/cats/effect/kernel/SyntaxSpec.scala b/kernel/shared/src/test/scala/cats/effect/kernel/SyntaxSuite.scala similarity index 97% rename from kernel/shared/src/test/scala/cats/effect/kernel/SyntaxSpec.scala rename to kernel/shared/src/test/scala/cats/effect/kernel/SyntaxSuite.scala index 2563ffbefd..d3c8c6a180 100644 --- a/kernel/shared/src/test/scala/cats/effect/kernel/SyntaxSpec.scala +++ b/kernel/shared/src/test/scala/cats/effect/kernel/SyntaxSuite.scala @@ -18,14 +18,10 @@ package cats.effect.kernel import cats.implicits._ -import org.specs2.mutable.Specification - import scala.concurrent.ExecutionContext import scala.concurrent.duration.{Duration, FiniteDuration} -class SyntaxSpec extends Specification { - - "kernel syntax" >> ok +class SyntaxSuite { def concurrentForwarder[F[_]: Concurrent] = Concurrent[F] diff --git a/laws/shared/src/test/scala/cats/effect/BaseSpec.scala b/laws/shared/src/test/scala/cats/effect/BaseSuite.scala similarity index 99% rename from laws/shared/src/test/scala/cats/effect/BaseSpec.scala rename to laws/shared/src/test/scala/cats/effect/BaseSuite.scala index ec3e295e3a..fb8a9c0baa 100644 --- a/laws/shared/src/test/scala/cats/effect/BaseSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/BaseSuite.scala @@ -27,7 +27,7 @@ import org.scalacheck.{Arbitrary, Gen, Prop} import org.scalacheck.util.Pretty // A dumping ground for random helpers for property tests -private[effect] trait BaseSpec { +private[effect] trait BaseSuite { implicit def kleisliEq[F[_], A, B](implicit ev: Eq[A => F[B]]): Eq[Kleisli[F, A, B]] = Eq.by[Kleisli[F, A, B], A => F[B]](_.run) diff --git a/laws/shared/src/test/scala/cats/effect/kernel/OutcomeSpec.scala b/laws/shared/src/test/scala/cats/effect/kernel/OutcomeSuite.scala similarity index 91% rename from laws/shared/src/test/scala/cats/effect/kernel/OutcomeSpec.scala rename to laws/shared/src/test/scala/cats/effect/kernel/OutcomeSuite.scala index 08f27092bf..6dcf0ec468 100644 --- a/laws/shared/src/test/scala/cats/effect/kernel/OutcomeSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/kernel/OutcomeSuite.scala @@ -22,10 +22,10 @@ import cats.effect.kernel.testkit.OutcomeGenerators import cats.laws.discipline.{ApplicativeErrorTests, MonadErrorTests} import org.scalacheck.{Arbitrary, Cogen} -import org.specs2.mutable.Specification -import org.typelevel.discipline.specs2.mutable.Discipline -class OutcomeSpec extends Specification with Discipline { +import munit.DisciplineSuite + +class OutcomeSuite extends DisciplineSuite { import OutcomeGenerators._ { diff --git a/laws/shared/src/test/scala/cats/effect/laws/ClockSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/ClockSuite.scala similarity index 83% rename from laws/shared/src/test/scala/cats/effect/laws/ClockSpec.scala rename to laws/shared/src/test/scala/cats/effect/laws/ClockSuite.scala index 0008bc8e16..8707fca1d1 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/ClockSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/ClockSuite.scala @@ -20,10 +20,9 @@ package laws import cats.data.ContT import cats.effect.kernel.testkit.freeEval._ -import org.specs2.mutable.Specification -import org.typelevel.discipline.specs2.mutable.Discipline +import munit.DisciplineSuite -class ClockSpec extends Specification with Discipline with BaseSpec { +class ClockSuite extends DisciplineSuite with BaseSuite { // we only need to test the ones that *aren't* also Sync checkAll("ContT[FreeEitherSync, Int, *]", ClockTests[ContT[FreeEitherSync, Int, *]].clock) diff --git a/laws/shared/src/test/scala/cats/effect/laws/EitherTFreeSyncSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/EitherTFreeSyncSuite.scala similarity index 89% rename from laws/shared/src/test/scala/cats/effect/laws/EitherTFreeSyncSpec.scala rename to laws/shared/src/test/scala/cats/effect/laws/EitherTFreeSyncSuite.scala index 5968c63467..64c6492349 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/EitherTFreeSyncSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/EitherTFreeSyncSuite.scala @@ -24,13 +24,11 @@ import cats.effect.kernel.testkit.freeEval.{syncForFreeT, FreeEitherSync} import cats.free.FreeT import cats.laws.discipline.arbitrary._ -import org.specs2.mutable._ -import org.typelevel.discipline.specs2.mutable.Discipline +import munit.DisciplineSuite -class EitherTFreeSyncSpec - extends Specification - with Discipline - with BaseSpec +class EitherTFreeSyncSuite + extends DisciplineSuite + with BaseSuite with LowPriorityImplicits { import FreeSyncGenerators._ import SyncTypeGenerators._ diff --git a/laws/shared/src/test/scala/cats/effect/laws/EitherTPureConcSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/EitherTPureConcSuite.scala similarity index 89% rename from laws/shared/src/test/scala/cats/effect/laws/EitherTPureConcSpec.scala rename to laws/shared/src/test/scala/cats/effect/laws/EitherTPureConcSuite.scala index 9e38a3fd87..90b94ed7b9 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/EitherTPureConcSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/EitherTPureConcSuite.scala @@ -24,12 +24,12 @@ import cats.effect.kernel.testkit.pure._ import cats.laws.discipline.arbitrary._ import org.scalacheck.Prop -import org.specs2.mutable._ -import org.typelevel.discipline.specs2.mutable.Discipline import scala.concurrent.duration._ -class EitherTPureConcSpec extends Specification with Discipline with BaseSpec { +import munit.DisciplineSuite + +class EitherTPureConcSuite extends DisciplineSuite with BaseSuite { import PureConcGenerators._ import OutcomeGenerators._ diff --git a/laws/shared/src/test/scala/cats/effect/laws/FreeSyncSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/FreeSyncSuite.scala similarity index 89% rename from laws/shared/src/test/scala/cats/effect/laws/FreeSyncSpec.scala rename to laws/shared/src/test/scala/cats/effect/laws/FreeSyncSuite.scala index db0ab59f59..b81758550b 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/FreeSyncSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/FreeSyncSuite.scala @@ -23,13 +23,11 @@ import cats.effect.kernel.testkit.freeEval.{syncForFreeT, FreeEitherSync} import cats.free.FreeT import cats.laws.discipline.arbitrary._ -import org.specs2.mutable._ -import org.typelevel.discipline.specs2.mutable.Discipline +import munit.DisciplineSuite -class FreeSyncSpec - extends Specification - with Discipline - with BaseSpec +class FreeSyncSuite + extends DisciplineSuite + with BaseSuite with LowPriorityImplicits { import FreeSyncGenerators._ import SyncTypeGenerators._ diff --git a/laws/shared/src/test/scala/cats/effect/laws/GenTemporalSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/GenTemporalSuite.scala similarity index 72% rename from laws/shared/src/test/scala/cats/effect/laws/GenTemporalSpec.scala rename to laws/shared/src/test/scala/cats/effect/laws/GenTemporalSuite.scala index 5403c86f98..d26856f24a 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/GenTemporalSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/GenTemporalSuite.scala @@ -23,12 +23,12 @@ import cats.effect.kernel.testkit.TimeT import cats.effect.kernel.testkit.pure._ import cats.syntax.all._ -import org.specs2.mutable.Specification - import scala.concurrent.duration._ + +import munit.FunSuite // import scala.concurrent.TimeoutException -class GenTemporalSpec extends Specification { outer => +class GenTemporalSuite extends FunSuite { outer => type F[A] = PureConc[Throwable, A] @@ -37,28 +37,20 @@ class GenTemporalSpec extends Specification { outer => val loop: TimeT[F, Unit] = F.sleep(5.millis).foreverM - "temporal" should { - "timeout" should { - "return identity when infinite duration" in { - val fa = F.pure(true) - F.timeout(fa, Duration.Inf) mustEqual fa - } - } + test("timeout should return identity when infinite duration") { + val fa = F.pure(true) + assertEquals(F.timeout(fa, Duration.Inf), fa) + } - "timeoutTo" should { - "return identity when infinite duration" in { - val fa: TimeT[F, Boolean] = F.pure(true) - val fallback: TimeT[F, Boolean] = F.raiseError(new RuntimeException) - F.timeoutTo(fa, Duration.Inf, fallback) mustEqual fa - } - } + test("timeoutTo should return identity when infinite duration") { + val fa: TimeT[F, Boolean] = F.pure(true) + val fallback: TimeT[F, Boolean] = F.raiseError(new RuntimeException) + assertEquals(F.timeoutTo(fa, Duration.Inf, fallback), fa) + } - "timeoutAndForget" should { - "return identity when infinite duration" in { - val fa: TimeT[F, Boolean] = F.pure(true) - F.timeoutAndForget(fa, Duration.Inf) mustEqual fa - } - } + test("timeoutAndForget should return identity when infinite duration") { + val fa: TimeT[F, Boolean] = F.pure(true) + assertEquals(F.timeoutAndForget(fa, Duration.Inf), fa) } // TODO enable these tests once Temporal for TimeT is fixed diff --git a/laws/shared/src/test/scala/cats/effect/laws/IorTFreeSyncSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/IorTFreeSyncSuite.scala similarity index 88% rename from laws/shared/src/test/scala/cats/effect/laws/IorTFreeSyncSpec.scala rename to laws/shared/src/test/scala/cats/effect/laws/IorTFreeSyncSuite.scala index ba237839f4..8fa7516e46 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/IorTFreeSyncSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/IorTFreeSyncSuite.scala @@ -24,13 +24,11 @@ import cats.effect.kernel.testkit.freeEval.{syncForFreeT, FreeEitherSync} import cats.free.FreeT import cats.laws.discipline.arbitrary._ -import org.specs2.mutable._ -import org.typelevel.discipline.specs2.mutable.Discipline +import munit.DisciplineSuite -class IorTFreeSyncSpec - extends Specification - with Discipline - with BaseSpec +class IorTFreeSyncSuite + extends DisciplineSuite + with BaseSuite with LowPriorityImplicits { import FreeSyncGenerators._ import SyncTypeGenerators._ diff --git a/laws/shared/src/test/scala/cats/effect/laws/IorTPureConcSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/IorTPureConcSuite.scala similarity index 89% rename from laws/shared/src/test/scala/cats/effect/laws/IorTPureConcSpec.scala rename to laws/shared/src/test/scala/cats/effect/laws/IorTPureConcSuite.scala index bd549763c2..23763596e0 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/IorTPureConcSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/IorTPureConcSuite.scala @@ -24,12 +24,12 @@ import cats.effect.kernel.testkit.pure._ import cats.laws.discipline.arbitrary._ import org.scalacheck.Prop -import org.specs2.mutable._ -import org.typelevel.discipline.specs2.mutable.Discipline import scala.concurrent.duration._ -class IorTPureConcSpec extends Specification with Discipline with BaseSpec { +import munit.DisciplineSuite + +class IorTPureConcSuite extends DisciplineSuite with BaseSuite { import PureConcGenerators._ import OutcomeGenerators._ diff --git a/laws/shared/src/test/scala/cats/effect/laws/KleisliFreeSyncSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/KleisliFreeSyncSuite.scala similarity index 88% rename from laws/shared/src/test/scala/cats/effect/laws/KleisliFreeSyncSpec.scala rename to laws/shared/src/test/scala/cats/effect/laws/KleisliFreeSyncSuite.scala index df2ac2631a..990f723d68 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/KleisliFreeSyncSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/KleisliFreeSyncSuite.scala @@ -26,13 +26,11 @@ import cats.laws.discipline.MiniInt import cats.laws.discipline.arbitrary._ import cats.laws.discipline.eq._ -import org.specs2.mutable._ -import org.typelevel.discipline.specs2.mutable.Discipline +import munit.DisciplineSuite -class KleisliFreeSyncSpec - extends Specification - with Discipline - with BaseSpec +class KleisliFreeSyncSuite + extends DisciplineSuite + with BaseSuite with LowPriorityImplicits { import FreeSyncGenerators._ import SyncTypeGenerators._ diff --git a/laws/shared/src/test/scala/cats/effect/laws/KleisliPureConcSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/KleisliPureConcSuite.scala similarity index 93% rename from laws/shared/src/test/scala/cats/effect/laws/KleisliPureConcSpec.scala rename to laws/shared/src/test/scala/cats/effect/laws/KleisliPureConcSuite.scala index 843a58c8d2..bd05c5eab5 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/KleisliPureConcSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/KleisliPureConcSuite.scala @@ -26,16 +26,14 @@ import cats.effect.kernel.testkit.pure._ import cats.laws.discipline.{arbitrary, MiniInt} import org.scalacheck.{Arbitrary, Cogen, Prop} -import org.specs2.mutable._ -import org.specs2.scalacheck.Parameters -import org.typelevel.discipline.specs2.mutable.Discipline import scala.concurrent.duration._ -class KleisliPureConcSpec - extends Specification - with Discipline - with BaseSpec +import munit.DisciplineSuite + +class KleisliPureConcSuite + extends DisciplineSuite + with BaseSuite with LowPriorityKleisliInstances { import PureConcGenerators._ import arbitrary.{catsLawsArbitraryForKleisli => _, _} @@ -78,12 +76,16 @@ class KleisliPureConcSpec : Cogen[Outcome[Kleisli[TimeT[PureConc[Int, *], *], MiniInt, *], Int, A]] = OutcomeGenerators.cogenOutcome[Kleisli[TimeT[PureConc[Int, *], *], MiniInt, *], Int, A] + override def scalaCheckTestParameters = + super.scalaCheckTestParameters + // we need to bound this a little tighter because these tests take FOREVER + .withMinSuccessfulTests(25) + checkAll( "Kleisli[PureConc]", GenTemporalTests[Kleisli[TimeT[PureConc[Int, *], *], MiniInt, *], Int] .temporal[Int, Int, Int](10.millis) - // we need to bound this a little tighter because these tests take FOREVER - )(Parameters(minTestsOk = 25)) + ) } //Push the priority of Kleisli instances down so we can explicitly summon more diff --git a/laws/shared/src/test/scala/cats/effect/laws/OptionTFreeSyncSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/OptionTFreeSyncSuite.scala similarity index 87% rename from laws/shared/src/test/scala/cats/effect/laws/OptionTFreeSyncSpec.scala rename to laws/shared/src/test/scala/cats/effect/laws/OptionTFreeSyncSuite.scala index 4f3fd18438..a848b21916 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/OptionTFreeSyncSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/OptionTFreeSyncSuite.scala @@ -24,10 +24,9 @@ import cats.effect.kernel.testkit.freeEval.{syncForFreeT, FreeEitherSync} import cats.free.FreeT import cats.laws.discipline.arbitrary._ -import org.specs2.mutable._ -import org.typelevel.discipline.specs2.mutable.Discipline +import munit.DisciplineSuite -class OptionTFreeSyncSpec extends Specification with Discipline with BaseSpec with FreeSyncEq { +class OptionTFreeSyncSuite extends DisciplineSuite with BaseSuite with FreeSyncEq { import FreeSyncGenerators._ import SyncTypeGenerators._ diff --git a/laws/shared/src/test/scala/cats/effect/laws/OptionTPureConcSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/OptionTPureConcSuite.scala similarity index 79% rename from laws/shared/src/test/scala/cats/effect/laws/OptionTPureConcSpec.scala rename to laws/shared/src/test/scala/cats/effect/laws/OptionTPureConcSuite.scala index 269bdced8d..5c76a996d9 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/OptionTPureConcSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/OptionTPureConcSuite.scala @@ -28,12 +28,12 @@ import cats.laws.discipline.arbitrary._ import cats.syntax.all._ import org.scalacheck.Prop -import org.specs2.mutable._ -import org.typelevel.discipline.specs2.mutable.Discipline import scala.concurrent.duration._ -class OptionTPureConcSpec extends Specification with Discipline with BaseSpec { +import munit.DisciplineSuite + +class OptionTPureConcSuite extends DisciplineSuite with BaseSuite { import PureConcGenerators._ import OutcomeGenerators._ @@ -47,26 +47,21 @@ class OptionTPureConcSpec extends Specification with Discipline with BaseSpec { bO => bO.flatten.fold(false)(_ => true) )) - "optiont bracket" should { - "forward completed zeros on to the handler" in { + test("optiont bracket forward completed zeros on to the handler") { var observed = false val test = OptionT.none[PureConc[Int, *], Unit] guaranteeCase { case Outcome.Succeeded(fa) => observed = true - OptionT(fa.value.map(_ must beNone).as(None)) + OptionT(fa.value.map(assertEquals(_, None)).as(None)) case _ => Applicative[OptionT[PureConc[Int, *], *]].unit } - pure.run(test.value) must beLike { - case Outcome.Succeeded(Some(None)) => ok - case _ => ko - } + assert(pure.run(test.value) === Outcome.Succeeded(Some(Option.empty[Unit]))) - observed must beTrue - } + assert(observed) } checkAll( diff --git a/laws/shared/src/test/scala/cats/effect/laws/PureConcSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/PureConcSuite.scala similarity index 63% rename from laws/shared/src/test/scala/cats/effect/laws/PureConcSpec.scala rename to laws/shared/src/test/scala/cats/effect/laws/PureConcSuite.scala index 6e4de84133..e4495a2e84 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/PureConcSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/PureConcSuite.scala @@ -23,19 +23,19 @@ import cats.effect.kernel.testkit.pure._ import cats.laws.discipline.arbitrary._ import org.scalacheck.Prop -import org.specs2.mutable._ -import org.typelevel.discipline.specs2.mutable.Discipline import scala.concurrent.duration._ -class PureConcSpec extends Specification with Discipline with BaseSpec { +import munit.DisciplineSuite + +class PureConcSuite extends DisciplineSuite with BaseSuite { import PureConcGenerators._ import OutcomeGenerators._ implicit def exec(fb: TimeT[PureConc[Int, *], Boolean]): Prop = Prop(pure.run(TimeT.run(fb)).fold(false, _ => false, _.getOrElse(false))) - "parallel utilities" should { + { import cats.effect.kernel.{GenConcurrent, Outcome} import cats.effect.kernel.implicits._ import cats.syntax.all._ @@ -43,35 +43,37 @@ class PureConcSpec extends Specification with Discipline with BaseSpec { type F[A] = PureConc[Int, A] val F = GenConcurrent[F] - "short-circuit on error" in { - pure.run((F.never[Unit], F.raiseError[Unit](42)).parTupled) mustEqual Outcome.Errored(42) - pure.run((F.raiseError[Unit](42), F.never[Unit]).parTupled) mustEqual Outcome.Errored(42) + test("short-circuit on error") { + assert( + pure.run((F.never[Unit], F.raiseError[Unit](42)).parTupled) === Outcome.Errored(42)) + assertEquals( + pure.run((F.raiseError[Unit](42), F.never[Unit]).parTupled), + Outcome.Errored[Option, Int, (Unit, Unit)](42)) } - "short-circuit on canceled" in { - pure.run((F.never[Unit], F.canceled).parTupled.start.flatMap(_.join)) mustEqual Outcome - .Succeeded(Some(Outcome.canceled[F, Nothing, Unit])) - pure.run((F.canceled, F.never[Unit]).parTupled.start.flatMap(_.join)) mustEqual Outcome - .Succeeded(Some(Outcome.canceled[F, Nothing, Unit])) + test("short-circuit on canceled") { + assert( + pure.run((F.never[Unit], F.canceled).parTupled.start.flatMap(_.join)) === Outcome + .Succeeded(Some(Outcome.canceled[F, Int, (Unit, Unit)]))) + assert( + pure.run((F.canceled, F.never[Unit]).parTupled.start.flatMap(_.join)) === Outcome + .Succeeded(Some(Outcome.canceled[F, Int, (Unit, Unit)]))) } - "not run forever on chained product" in { + test("not run forever on chained product") { import cats.effect.kernel.Par.ParallelF val fa: F[String] = F.pure("a") val fb: F[String] = F.pure("b") val fc: F[Unit] = F.raiseError[Unit](42) - pure.run( - ParallelF.value( - ParallelF(fa).product(ParallelF(fb)).product(ParallelF(fc)))) mustEqual Outcome - .Errored(42) + assert(pure.run(ParallelF.value( + ParallelF(fa).product(ParallelF(fb)).product(ParallelF(fc)))) === Outcome.Errored(42)) } - "ignore unmasking in finalizers" in { + test("ignore unmasking in finalizers") { val fa = F.uncancelable { poll => F.onCancel(poll(F.unit), poll(F.unit)) } pure.run(fa.start.flatMap(_.cancel)) - ok } } diff --git a/laws/shared/src/test/scala/cats/effect/laws/ReaderWriterStateTFreeSyncSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/ReaderWriterStateTFreeSyncSuite.scala similarity index 81% rename from laws/shared/src/test/scala/cats/effect/laws/ReaderWriterStateTFreeSyncSpec.scala rename to laws/shared/src/test/scala/cats/effect/laws/ReaderWriterStateTFreeSyncSuite.scala index 4df3ba5724..721ead60e3 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/ReaderWriterStateTFreeSyncSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/ReaderWriterStateTFreeSyncSuite.scala @@ -25,23 +25,20 @@ import cats.free.FreeT import cats.laws.discipline.MiniInt import cats.laws.discipline.arbitrary._ -import org.specs2.mutable._ -import org.specs2.scalacheck._ -import org.typelevel.discipline.specs2.mutable.Discipline +import munit.DisciplineSuite -class ReaderWriterStateTFreeSyncSpec - extends Specification - with Discipline - with BaseSpec +class ReaderWriterStateTFreeSyncSuite + extends DisciplineSuite + with BaseSuite with LowPriorityImplicits { import FreeSyncGenerators._ import SyncTypeGenerators._ - implicit val params: Parameters = + override def scalaCheckTestParameters = if (cats.platform.Platform.isNative) - Parameters(minTestsOk = 5) + super.scalaCheckTestParameters.withMinSuccessfulTests(5) else - Parameters(minTestsOk = 100) + super.scalaCheckTestParameters implicit val scala_2_12_is_buggy : Eq[FreeT[Eval, Either[Throwable, *], Either[Int, Either[Throwable, Int]]]] = diff --git a/laws/shared/src/test/scala/cats/effect/laws/ReaderWriterStateTPureConcSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/ReaderWriterStateTPureConcSuite.scala similarity index 85% rename from laws/shared/src/test/scala/cats/effect/laws/ReaderWriterStateTPureConcSpec.scala rename to laws/shared/src/test/scala/cats/effect/laws/ReaderWriterStateTPureConcSuite.scala index 4c16bcd7d7..a303cac487 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/ReaderWriterStateTPureConcSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/ReaderWriterStateTPureConcSuite.scala @@ -25,21 +25,22 @@ import cats.laws.discipline.MiniInt import cats.laws.discipline.arbitrary._ import cats.laws.discipline.eq._ -import org.specs2.mutable._ -import org.specs2.scalacheck.Parameters -import org.typelevel.discipline.specs2.mutable.Discipline +import munit.DisciplineSuite -class ReaderWriterStateTPureConcSpec extends Specification with Discipline with BaseSpec { +class ReaderWriterStateTPureConcSuite extends DisciplineSuite with BaseSuite { import PureConcGenerators._ implicit def rwstEq[F[_]: Monad, E, L, S, A]( implicit ev: Eq[(E, S) => F[(L, S, A)]]): Eq[ReaderWriterStateT[F, E, L, S, A]] = Eq.by[ReaderWriterStateT[F, E, L, S, A], (E, S) => F[(L, S, A)]](_.run) + override def scalaCheckTestParameters = + // we need to bound this a little tighter because these tests take FOREVER, especially on scalajs + super.scalaCheckTestParameters.withMinSuccessfulTests(1) + checkAll( "ReaderWriterStateT[PureConc]", MonadCancelTests[ReaderWriterStateT[PureConc[Int, *], MiniInt, Int, MiniInt, *], Int] .monadCancel[Int, Int, Int] - // we need to bound this a little tighter because these tests take FOREVER, especially on scalajs - )(Parameters(minTestsOk = 1)) + ) } diff --git a/laws/shared/src/test/scala/cats/effect/laws/ResourcePureConcSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/ResourcePureConcSuite.scala similarity index 89% rename from laws/shared/src/test/scala/cats/effect/laws/ResourcePureConcSpec.scala rename to laws/shared/src/test/scala/cats/effect/laws/ResourcePureConcSuite.scala index 406d781f51..a0735d65ed 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/ResourcePureConcSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/ResourcePureConcSuite.scala @@ -23,13 +23,12 @@ import cats.laws.discipline.arbitrary._ import cats.syntax.all._ import org.scalacheck.{Cogen, Prop} -import org.specs2.mutable._ -import org.typelevel.discipline.specs2.mutable.Discipline -class ResourcePureConcSpec - extends Specification - with Discipline - with BaseSpec +import munit.DisciplineSuite + +class ResourcePureConcSuite + extends DisciplineSuite + with BaseSuite with TestInstances { import PureConcGenerators._ import OutcomeGenerators._ diff --git a/laws/shared/src/test/scala/cats/effect/laws/StateTFreeSyncSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/StateTFreeSyncSuite.scala similarity index 88% rename from laws/shared/src/test/scala/cats/effect/laws/StateTFreeSyncSpec.scala rename to laws/shared/src/test/scala/cats/effect/laws/StateTFreeSyncSuite.scala index ad44aa909c..209497cfa5 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/StateTFreeSyncSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/StateTFreeSyncSuite.scala @@ -25,13 +25,11 @@ import cats.free.FreeT import cats.laws.discipline.MiniInt import cats.laws.discipline.arbitrary._ -import org.specs2.mutable._ -import org.typelevel.discipline.specs2.mutable.Discipline +import munit.DisciplineSuite -class StateTFreeSyncSpec - extends Specification - with Discipline - with BaseSpec +class StateTFreeSyncSuite + extends DisciplineSuite + with BaseSuite with LowPriorityImplicits { import FreeSyncGenerators._ import SyncTypeGenerators._ diff --git a/laws/shared/src/test/scala/cats/effect/laws/StateTPureConcSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/StateTPureConcSuite.scala similarity index 78% rename from laws/shared/src/test/scala/cats/effect/laws/StateTPureConcSpec.scala rename to laws/shared/src/test/scala/cats/effect/laws/StateTPureConcSuite.scala index c8e6b1d73e..828c20ab4d 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/StateTPureConcSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/StateTPureConcSuite.scala @@ -25,20 +25,22 @@ import cats.laws.discipline.MiniInt import cats.laws.discipline.arbitrary._ import cats.laws.discipline.eq._ -import org.specs2.mutable._ -import org.specs2.scalacheck.Parameters -import org.typelevel.discipline.specs2.mutable.Discipline +import munit.DisciplineSuite -class StateTPureConcSpec extends Specification with Discipline with BaseSpec { +class StateTPureConcSuite extends DisciplineSuite with BaseSuite { import PureConcGenerators._ implicit def stateTEq[F[_]: FlatMap, S, A]( implicit ev: Eq[S => F[(S, A)]]): Eq[StateT[F, S, A]] = Eq.by[StateT[F, S, A], S => F[(S, A)]](_.run) + override def scalaCheckTestParameters = + super.scalaCheckTestParameters.withMinSuccessfulTests(25) + + // override def scalaCheckInitialSeed = "Ky43MND8m5h-10MZTckMFFAW6ea2pXWkFDE2A7ddtML=" + checkAll( "StateT[PureConc]", MonadCancelTests[StateT[PureConc[Int, *], MiniInt, *], Int].monadCancel[Int, Int, Int] - )(Parameters(minTestsOk = - 25 /*, seed = Some(Seed.fromBase64("Ky43MND8m5h-10MZTckMFFAW6ea2pXWkFDE2A7ddtML=").get*/ )) + ) } diff --git a/laws/shared/src/test/scala/cats/effect/laws/WriterTFreeSyncSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/WriterTFreeSyncSuite.scala similarity index 88% rename from laws/shared/src/test/scala/cats/effect/laws/WriterTFreeSyncSpec.scala rename to laws/shared/src/test/scala/cats/effect/laws/WriterTFreeSyncSuite.scala index 59c5fea21f..35f60abee1 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/WriterTFreeSyncSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/WriterTFreeSyncSuite.scala @@ -24,13 +24,11 @@ import cats.effect.kernel.testkit.freeEval.{syncForFreeT, FreeEitherSync} import cats.free.FreeT import cats.laws.discipline.arbitrary._ -import org.specs2.mutable._ -import org.typelevel.discipline.specs2.mutable.Discipline +import munit.DisciplineSuite -class WriterTFreeSyncSpec - extends Specification - with Discipline - with BaseSpec +class WriterTFreeSyncSuite + extends DisciplineSuite + with BaseSuite with LowPriorityImplicits { import FreeSyncGenerators._ import SyncTypeGenerators._ diff --git a/laws/shared/src/test/scala/cats/effect/laws/WriterTPureConcSpec.scala b/laws/shared/src/test/scala/cats/effect/laws/WriterTPureConcSuite.scala similarity index 89% rename from laws/shared/src/test/scala/cats/effect/laws/WriterTPureConcSpec.scala rename to laws/shared/src/test/scala/cats/effect/laws/WriterTPureConcSuite.scala index 3663c442ac..3bb40f9c39 100644 --- a/laws/shared/src/test/scala/cats/effect/laws/WriterTPureConcSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/laws/WriterTPureConcSuite.scala @@ -24,12 +24,12 @@ import cats.effect.kernel.testkit.pure._ import cats.laws.discipline.arbitrary._ import org.scalacheck.Prop -import org.specs2.mutable._ -import org.typelevel.discipline.specs2.mutable.Discipline import scala.concurrent.duration._ -class WriterTPureConcSpec extends Specification with Discipline with BaseSpec { +import munit.DisciplineSuite + +class WriterTPureConcSuite extends DisciplineSuite with BaseSuite { import PureConcGenerators._ import OutcomeGenerators._ diff --git a/laws/shared/src/test/scala/cats/effect/testkit/TimeTSpec.scala b/laws/shared/src/test/scala/cats/effect/testkit/TimeTSuite.scala similarity index 92% rename from laws/shared/src/test/scala/cats/effect/testkit/TimeTSpec.scala rename to laws/shared/src/test/scala/cats/effect/testkit/TimeTSuite.scala index 218eccc97d..3e8f7ae87b 100644 --- a/laws/shared/src/test/scala/cats/effect/testkit/TimeTSpec.scala +++ b/laws/shared/src/test/scala/cats/effect/testkit/TimeTSuite.scala @@ -23,20 +23,20 @@ import cats.effect.laws.GenTemporalTests import cats.laws.discipline.arbitrary._ import org.scalacheck.{Arbitrary, Cogen, Gen, Prop} -import org.specs2.mutable._ -import org.typelevel.discipline.specs2.mutable.Discipline import scala.concurrent.duration._ import java.util.concurrent.TimeUnit +import munit.DisciplineSuite + private[testkit] trait LowPriorityInstances { implicit def eqTimeT[F[_], A](implicit FA: Eq[F[A]]): Eq[TimeT[F, A]] = Eq.by(TimeT.run(_)) } -class TimeTSpec extends Specification with Discipline with LowPriorityInstances { +class TimeTSuite extends DisciplineSuite with LowPriorityInstances { import PureConcGenerators._ import OutcomeGenerators._