diff --git a/tests/shared/src/test/scala-2.13+/cats/tests/ScalaVersionSpecific.scala b/tests/shared/src/test/scala-2.13+/cats/tests/ScalaVersionSpecific.scala index 1efbd376a0..0aa3bdd8fc 100644 --- a/tests/shared/src/test/scala-2.13+/cats/tests/ScalaVersionSpecific.scala +++ b/tests/shared/src/test/scala-2.13+/cats/tests/ScalaVersionSpecific.scala @@ -179,7 +179,7 @@ trait ScalaVersionSpecificRegressionSuite { self: RegressionSuite => // shouldn't have ever evaluated validate(8) checkAndResetCount(3) - assert(LazyList(1, 2, 6, 8).traverse_(validate) === (Either.left("6 is greater than 5"))) + assert(LazyList(1, 2, 6, 8).traverseVoid(validate) === Either.left("6 is greater than 5")) checkAndResetCount(3) } } diff --git a/tests/shared/src/test/scala/cats/tests/KleisliSuite.scala b/tests/shared/src/test/scala/cats/tests/KleisliSuite.scala index 56de674069..c7a8ec034c 100644 --- a/tests/shared/src/test/scala/cats/tests/KleisliSuite.scala +++ b/tests/shared/src/test/scala/cats/tests/KleisliSuite.scala @@ -378,16 +378,16 @@ class KleisliSuite extends CatsSuite { assertEquals(program.run(A123), List((1, "2", true))) } - test("traverse_ doesn't stack overflow") { + test("traverseVoid doesn't stack overflow") { // see: https://github.com/typelevel/cats/issues/3947 - val resL = (1 to 10000).toList.traverse_(_ => Kleisli.liftF[Id, String, Unit](())).run("") - val resV = (1 to 10000).toVector.traverse_(_ => Kleisli.liftF[Id, String, Unit](())).run("") + val resL = (1 to 10000).toList.traverseVoid(_ => Kleisli.liftF[Id, String, Unit](())).run("") + val resV = (1 to 10000).toVector.traverseVoid(_ => Kleisli.liftF[Id, String, Unit](())).run("") assert(resL === resV) } - test("traverse_ doesn't stack overflow with List + Eval") { + test("traverseVoid doesn't stack overflow with List + Eval") { // see: https://github.com/typelevel/cats/issues/3947 - (1 to 10000).toList.traverse_(_ => Kleisli.liftF[Eval, String, Unit](Eval.Unit)).run("").value + (1 to 10000).toList.traverseVoid(_ => Kleisli.liftF[Eval, String, Unit](Eval.Unit)).run("").value } /** diff --git a/tests/shared/src/test/scala/cats/tests/ParallelSuite.scala b/tests/shared/src/test/scala/cats/tests/ParallelSuite.scala index 869b2611b5..4dc50a6d20 100644 --- a/tests/shared/src/test/scala/cats/tests/ParallelSuite.scala +++ b/tests/shared/src/test/scala/cats/tests/ParallelSuite.scala @@ -78,24 +78,24 @@ class ParallelSuite } } - test("ParTraverse_ identity should be equivalent to parSequence_") { + test("ParTraverseVoid identity should be equivalent to parSequenceVoid") { forAll { (es: SortedSet[Either[String, Int]]) => - assert(Parallel.parTraverse_(es)(identity) === (Parallel.parSequence_[SortedSet, Either[String, *], Int](es))) + assert(Parallel.parTraverseVoid(es)(identity) === Parallel.parSequenceVoid[SortedSet, Either[String, *], Int](es)) } } - test("ParTraverse_ syntax should be equivalent to Parallel.parTraverse_") { + test("ParTraverseVoid syntax should be equivalent to Parallel.parTraverseVoid") { forAll { (es: SortedSet[Either[String, Int]]) => assert( - Parallel.parTraverse_[SortedSet, Either[String, *], Either[String, Int], Int](es)(identity) === (es - .parTraverse_(identity)) + Parallel.parTraverseVoid[SortedSet, Either[String, *], Either[String, Int], Int](es)(identity) === + es.parTraverseVoid(identity) ) } } - test("ParSequence_ syntax should be equivalent to Parallel.parSequence_") { + test("ParSequenceVoid syntax should be equivalent to Parallel.parSequenceVoid") { forAll { (es: SortedSet[Either[String, Int]]) => - assert(Parallel.parSequence_[SortedSet, Either[String, *], Int](es) === (es.parSequence_)) + assert(Parallel.parSequenceVoid[SortedSet, Either[String, *], Int](es) === es.parSequenceVoid) } } @@ -105,9 +105,9 @@ class ParallelSuite } } - test("ParNonEmptyTraverse_ identity should be equivalent to parNonEmptySequence_") { + test("ParNonEmptyTraverseVoid identity should be equivalent to parNonEmptySequenceVoid") { forAll { (es: NonEmptyList[Either[String, Int]]) => - assert(Parallel.parNonEmptyTraverse_(es)(identity) === (Parallel.parNonEmptySequence_(es))) + assert(Parallel.parNonEmptyTraverseVoid(es)(identity) === Parallel.parNonEmptySequenceVoid(es)) } } @@ -310,10 +310,10 @@ class ParallelSuite } } - test("ParReplicateA_ should be equivalent to fill parSequence_") { + test("ParReplicateA_ should be equivalent to fill parSequenceVoid") { forAll(Gen.choose(1, 20), Arbitrary.arbitrary[Either[String, String]]) { (repetitions: Int, e: Either[String, String]) => - assert(Parallel.parReplicateA_(repetitions, e) === Parallel.parSequence_(List.fill(repetitions)(e))) + assert(Parallel.parReplicateA_(repetitions, e) === Parallel.parSequenceVoid(List.fill(repetitions)(e))) } } diff --git a/tests/shared/src/test/scala/cats/tests/ReducibleSuite.scala b/tests/shared/src/test/scala/cats/tests/ReducibleSuite.scala index 01dd07fd02..a17a44e443 100644 --- a/tests/shared/src/test/scala/cats/tests/ReducibleSuite.scala +++ b/tests/shared/src/test/scala/cats/tests/ReducibleSuite.scala @@ -234,11 +234,11 @@ abstract class ReducibleSuite[F[_]: Reducible](name: String)(implicit assert(out.toList === List(2, 4, 6, 9)) } - test(s"Reducible[$name].nonEmptyTraverse_ can breakout") { + test(s"Reducible[$name].nonEmptyTraverseVoid can breakout") { val notAllEven = fromValues(2, 4, 6, 9, 10, 12, 14) val out = mutable.ListBuffer[Int]() - notAllEven.nonEmptyTraverse_ { a => out += a; if (a % 2 == 0) Some(a) else None } + notAllEven.nonEmptyTraverseVoid { a => out += a; if (a % 2 == 0) Some(a) else None } assert(out.toList === List(2, 4, 6, 9)) } diff --git a/tests/shared/src/test/scala/cats/tests/RegressionSuite.scala b/tests/shared/src/test/scala/cats/tests/RegressionSuite.scala index b326f39c3b..2d852e2cb3 100644 --- a/tests/shared/src/test/scala/cats/tests/RegressionSuite.scala +++ b/tests/shared/src/test/scala/cats/tests/RegressionSuite.scala @@ -162,23 +162,23 @@ class RegressionSuite extends CatsSuite with ScalaVersionSpecificRegressionSuite assert(Vector(1, 2, 6, 8).traverse(validate) === (Either.left("6 is greater than 5"))) checkAndResetCount(3) - assert(List(1, 2, 6, 8).traverse_(validate) === (Either.left("6 is greater than 5"))) + assert(List(1, 2, 6, 8).traverseVoid(validate) === Either.left("6 is greater than 5")) checkAndResetCount(3) { @annotation.nowarn("cat=deprecation") - val obtained = Stream(1, 2, 6, 8).traverse_(validate) + val obtained = Stream(1, 2, 6, 8).traverseVoid(validate) assert(obtained === Either.left("6 is greater than 5")) } checkAndResetCount(3) - assert(Vector(1, 2, 6, 8).traverse_(validate) === (Either.left("6 is greater than 5"))) + assert(Vector(1, 2, 6, 8).traverseVoid(validate) === Either.left("6 is greater than 5")) checkAndResetCount(3) - assert(NonEmptyList.of(1, 2, 6, 7, 8).traverse_(validate) === (Either.left("6 is greater than 5"))) + assert(NonEmptyList.of(1, 2, 6, 7, 8).traverseVoid(validate) === Either.left("6 is greater than 5")) checkAndResetCount(3) - assert(NonEmptyList.of(6, 7, 8).traverse_(validate) === (Either.left("6 is greater than 5"))) + assert(NonEmptyList.of(6, 7, 8).traverseVoid(validate) === Either.left("6 is greater than 5")) checkAndResetCount(1) } diff --git a/tests/shared/src/test/scala/cats/tests/SyntaxSuite.scala b/tests/shared/src/test/scala/cats/tests/SyntaxSuite.scala index 2f8e82e4bd..2b7f19277d 100644 --- a/tests/shared/src/test/scala/cats/tests/SyntaxSuite.scala +++ b/tests/shared/src/test/scala/cats/tests/SyntaxSuite.scala @@ -39,7 +39,6 @@ import cats.data.{ ValidatedNec, ValidatedNel } -import cats.syntax.OptionOps import cats.syntax.all._ import scala.collection.immutable.{SortedMap, SortedSet} @@ -155,11 +154,11 @@ object SyntaxSuite { val a1: A = fz.foldMap(f3) val f4 = mock[A => G[B]] - val gu0: G[Unit] = fa.traverse_(f4) + val gu0: G[Unit] = fa.traverseVoid(f4) val fga = mock[F[G[A]]] - val gu1: G[Unit] = fga.sequence_ - val ga: G[A] = fga.foldK + val gu1: G[Unit] = fga.sequenceVoid // NestedFoldableOps + val ga1: G[A] = fga.foldK // NestedFoldableOps val f5 = mock[A => Boolean] val oa: Option[A] = fa.find(f5) @@ -201,7 +200,19 @@ object SyntaxSuite { val gunit: G[F[A]] = fga.nonEmptySequence } - def testParallel[M[_]: Parallel, T[_]: Traverse, A, B]: Unit = { + def testParallelFoldable[M[_]: Parallel, T[_]: Foldable, A, B](): Unit = { + val ta = mock[T[A]] + val tma = mock[T[M[A]]] + val famb = mock[A => M[B]] + + val mu1 = ta.parTraverseVoid(famb) + val mu2 = tma.parSequenceVoid + + // Suppress "unused local val" warnings and make sure the types were inferred correctly. + val _ = (mu1: M[Unit], mu2: M[Unit]) + } + + def testParallelTraverse[M[_]: Parallel, T[_]: Traverse, A, B](): Unit = { val ta = mock[T[A]] val f = mock[A => M[B]] val mtb = ta.parTraverse(f) @@ -348,7 +359,7 @@ object SyntaxSuite { val mtab2 = tmab.parLeftSequence } - def testParallelFoldable[T[_]: Foldable, M[_]: Parallel, A, B: Monoid]: Unit = { + def testParallelFoldableMonoid[T[_]: Foldable, M[_]: Parallel, A, B: Monoid](): Unit = { val ta = mock[T[A]] val f = mock[A => M[B]] val mb = ta.parFoldMapA(f) @@ -379,9 +390,9 @@ object SyntaxSuite { val lb: Eval[B] = fa.reduceRightTo(f4)(f6) val f7 = mock[A => G[B]] - val gu1: G[Unit] = fa.nonEmptyTraverse_(f7) + val gu1: G[Unit] = fa.nonEmptyTraverseVoid(f7) - val gu2: G[Unit] = fga.nonEmptySequence_ + val gu2: G[Unit] = fga.nonEmptySequenceVoid } def testFunctor[F[_]: Functor, A, B]: Unit = { diff --git a/tests/shared/src/test/scala/cats/tests/TraverseSuite.scala b/tests/shared/src/test/scala/cats/tests/TraverseSuite.scala index 94fffaea5e..1c6e8a1ad0 100644 --- a/tests/shared/src/test/scala/cats/tests/TraverseSuite.scala +++ b/tests/shared/src/test/scala/cats/tests/TraverseSuite.scala @@ -83,9 +83,9 @@ abstract class TraverseSuite[F[_]: Traverse](name: String)(implicit ArbFInt: Arb } } - test(s"Traverse[$name].traverse matches traverse_ with Option") { + test(s"Traverse[$name].traverse matches traverseVoid with Option") { forAll { (fa: F[Int], fn: Int => Option[Int]) => - assert(Applicative[Option].void(fa.traverse(fn)) == fa.traverse_(fn)) + assert(Applicative[Option].void(fa.traverse(fn)) == fa.traverseVoid(fn)) } }