1717package munit
1818
1919import cats .implicits ._
20- import org .scalacheck .{Gen , Test }
20+ import org .scalacheck .{Gen , Test => ScalaCheckTest }
2121import org .scalacheck .Test .PropException
2222import org .scalacheck .effect .PropF
2323import org .scalacheck .rng .Seed
2424import org .scalacheck .util .Pretty
2525
26- import java .lang .reflect .{InvocationTargetException , UndeclaredThrowableException }
27- import scala .annotation .tailrec
28- import scala .concurrent .ExecutionException
29-
3026/** Extends `ScalaCheckSuite`, adding support for evaluation of effectful properties (`PropF[F]`
3127 * values).
3228 *
@@ -51,7 +47,7 @@ trait ScalaCheckEffectSuite extends ScalaCheckSuite {
5147 val testResultTransform =
5248 new ValueTransform (
5349 " ScalaCheck TestResult" ,
54- { case p : Test .Result =>
50+ { case p : ScalaCheckTest .Result =>
5551 super .munitValueTransform(parseTestResult(p))
5652 }
5753 )
@@ -72,7 +68,7 @@ trait ScalaCheckEffectSuite extends ScalaCheckSuite {
7268 prop.check(scalaCheckTestParameters, genParameters).map(fixResultException).map(parseTestResult)
7369 }
7470
75- private def parseTestResult (result : Test .Result )(implicit loc : Location ): Unit = {
71+ private def parseTestResult (result : ScalaCheckTest .Result )(implicit loc : Location ): Unit = {
7672 if (! result.passed) {
7773 val seed = genParameters.initialSeed.get
7874 val seedMessage =
@@ -85,23 +81,14 @@ trait ScalaCheckEffectSuite extends ScalaCheckSuite {
8581 }
8682 }
8783
88- private def fixResultException (result : Test .Result ): Test .Result =
84+ private def fixResultException (result : ScalaCheckTest .Result ): ScalaCheckTest .Result =
8985 result.copy(
9086 status = result.status match {
91- case p @ PropException (_, e, _) => p.copy(e = rootCause(e))
87+ case p @ PropException (_, e, _) => p.copy(e = Exceptions . rootCause(e))
9288 case default => default
9389 }
9490 )
9591
96- // https://github.com/scalameta/munit/blob/68c2d13868baec9a77384f11f97505ecc0ce3eba/munit/shared/src/main/scala/munit/MUnitRunner.scala#L318-L326
97- @ tailrec
98- private def rootCause (x : Throwable ): Throwable = x match {
99- case _ : InvocationTargetException | _ : ExceptionInInitializerError |
100- _ : UndeclaredThrowableException | _ : ExecutionException if x.getCause != null =>
101- rootCause(x.getCause)
102- case _ => x
103- }
104-
10592}
10693
10794object ScalaCheckEffectSuite {}
0 commit comments