Skip to content

Commit

Permalink
Generalizing all the parFlatMap tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TonioGela committed Oct 6, 2022
1 parent c8b6cd0 commit 325b4b4
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tests/shared/src/test/scala/cats/tests/ParallelSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -391,26 +391,27 @@ class ParallelSuite
}

test("ParFlatMapN over List should be consistent with parMapN flatten") {
forAll { (as: List[Int], bs: List[Int], cs: List[Int]) =>
val mf: (Int, Int, Int) => List[Int] = _ :: _ :: _ :: Nil
forAll { (as: List[Int], bs: List[Int], cs: List[Int], mf: (Int, Int, Int) => List[Int]) =>
assert((as, bs, cs).parFlatMapN(mf) == (as, bs, cs).parMapN(mf).flatten)
}
}

test("ParFlatMapN over NonEmptyList should be consistent with parMapN flatten") {
forAll { (as: NonEmptyList[Int], bs: NonEmptyList[Int], cs: NonEmptyList[Int]) =>
val mf: (Int, Int, Int) => NonEmptyList[Int] = (a, b, c) => NonEmptyList.of(a, b, c)
assert((as, bs, cs).parFlatMapN(mf) == (as, bs, cs).parMapN(mf).flatten)
forAll {
(as: NonEmptyList[Int], bs: NonEmptyList[Int], cs: NonEmptyList[Int], mf: (Int, Int, Int) => NonEmptyList[Int]) =>
assert((as, bs, cs).parFlatMapN(mf) == (as, bs, cs).parMapN(mf).flatten)
}
}

test("ParFlatMap over List should be consistent with flatmap") {
forAll { as: List[Int] => assert(Tuple1(as).parFlatMap(_ :: Nil) == Tuple1(as).flatMap(_ :: Nil)) }
forAll { (as: List[Int], mf: Int => List[Int]) =>
assert(Tuple1(as).parFlatMap(mf) == Tuple1(as).flatMap(mf))
}
}

test("ParFlatMap over NonEmptyList should be consistent with flatmap") {
forAll { as: NonEmptyList[Int] =>
assert(Tuple1(as).parFlatMap(NonEmptyList.one) == Tuple1(as).flatMap(NonEmptyList.one))
forAll { (as: NonEmptyList[Int], mf: Int => NonEmptyList[Int]) =>
assert(Tuple1(as).parFlatMap(mf) == Tuple1(as).flatMap(mf))
}
}

Expand Down

0 comments on commit 325b4b4

Please sign in to comment.