Abstract over Specs2 test result kind to enable more consistent support for ScalaCheck #616
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces
AsFutureResult[A]
, which can be thought of an extension ofUnsafeRun[F].unsafeToFuture[A]
when anAsResult[A]
is available. As far as I can tell, this is necessary to support structures likeorg.scalacheck.effect.PropF[F]
, where it is not possible to write an instance ofUnsafeRun[PropF]
, sincePropF#check
returnsResult
and notA
. (This doesn't work, even using e.g.UnsafeRun[({ type λ[α] = PropF[F] })#λ]
.)This lets us abstract over different kinds of results, such as
A
(assuming anAsResult[A]
),F[A]
(assuming anUnsafeRun[F]
andAsResult[A]
), orPropF[F]
(assuming anUnsafeRun[F]
).If this is merged, I'll make a followup PR to typelevel/scalacheck-effect adding a new
scalacheck-effect-specs2
project with atrait Specs2ScalaCheckEffect
which will provide an instance ofAsFutureResult[PropF[F]]
.This enables users to use
CatsResource#withResource
with many different kinds of tests. This was motivated by work I recently completed introducing Cats Effect into parts of an existing project. That project had existing tests that returnedMatchResult[A]
andMatchResult[scala.concurrent.Future[A]]
(as well as some tests implemented in Twitter'sFuture
). With these changes, I was able to add tests that operate inIO
andPropF
while minimizing the changes needed to the existing tests. (Without these tests, using the existing tests withwithResources
would have involved a fair amount of boilerplate wrapping the existing tests inIO
.)