Skip to content

Commit

Permalink
minor fixes so it can compile agains zio head
Browse files Browse the repository at this point in the history
  • Loading branch information
TimPigden committed Dec 31, 2019
1 parent 30c86e0 commit c9df609
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 75 deletions.
11 changes: 6 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,21 @@ lazy val root = project
unusedCompileDependenciesFilter -= moduleFilter("org.scala-js", "scalajs-library")
)

lazy val zioVersion = "1.0.0-RC17+166-0a7246c5"
lazy val interopCats = crossProject(JSPlatform, JVMPlatform)
.in(file("interop-cats"))
.enablePlugins(BuildInfoPlugin)
.settings(stdSettings("zio-interop-cats"))
.settings(buildInfoSettings)
.settings(
libraryDependencies ++= Seq(
"dev.zio" %%% "zio" % "1.0.0-RC17",
"dev.zio" %%% "zio-streams" % "1.0.0-RC17" % Optional,
"dev.zio" %%% "zio-test" % "1.0.0-RC17" % Optional,
"dev.zio" %%% "zio" % zioVersion,
"dev.zio" %%% "zio-streams" % zioVersion % Optional,
"dev.zio" %%% "zio-test" % zioVersion % Optional,
"org.typelevel" %%% "cats-effect" % "2.0.0" % Optional,
"org.typelevel" %%% "cats-mtl-core" % "0.7.0" % Optional,
"co.fs2" %%% "fs2-core" % "2.1.0" % Test,
"dev.zio" %%% "zio-test-sbt" % "1.0.0-RC17" % Test,
"dev.zio" %%% "zio-test-sbt" % zioVersion % Test,
"org.specs2" %%% "specs2-core" % "4.8.1" % Test,
"org.specs2" %%% "specs2-scalacheck" % "4.8.1" % Test,
"org.specs2" %%% "specs2-matcher-extra" % "4.8.1" % Test,
Expand All @@ -81,7 +82,7 @@ lazy val coreOnlyTest = crossProject(JSPlatform, JVMPlatform)
.settings(
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % "2.0.0" % Test,
"dev.zio" %%% "zio-test-sbt" % "1.0.0-RC17" % Test
"dev.zio" %%% "zio-test-sbt" % zioVersion % Test
)
)
.settings(testFrameworks += new TestFramework("zio.test.sbt.ZTestFramework"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,46 @@ import zio.test.Assertion._
import zio.test.{ DefaultRunnableSpec, test, _ }

object CoreSummonSpec
extends DefaultRunnableSpec(
suite("summons from catz.core work with only a cats-core dependency")(
test("ZIO instances") {
val monad = implicitly[Monad[UIO]]
val monadError = implicitly[MonadError[Task, Throwable]]
val semigroupK = implicitly[SemigroupK[IO[NonEmptyList[Unit], ?]]]
val bifunctor = implicitly[Bifunctor[IO]]

monad.map(ZIO.unit)(identity)
monadError.map(ZIO.unit)(identity)
semigroupK.combineK(ZIO.unit, ZIO.unit)
bifunctor.leftMap(ZIO.fromOption(None))(identity)

assert((), anything)
},
test("ZManaged instances") {
val monad = implicitly[Monad[ZManaged[Any, Nothing, ?]]]
val monadError = implicitly[MonadError[Managed[Throwable, ?], Throwable]]
val semigroupK = implicitly[SemigroupK[Managed[Nothing, ?]]]
val bifunctor = implicitly[Bifunctor[Managed]]

monad.map(ZManaged.unit)(identity)
monadError.map(ZManaged.unit)(identity)
semigroupK.combineK(ZManaged.unit, ZManaged.unit)
bifunctor.leftMap(ZManaged.fail(()))(identity)

assert((), anything)
},
test("ZStream instances") {
val monad = implicitly[Monad[ZStream[Any, Nothing, ?]]]
val monadError = implicitly[MonadError[Stream[Throwable, ?], Throwable]]
val semigroupK = implicitly[SemigroupK[Stream[Nothing, ?]]]
val bifunctor = implicitly[Bifunctor[Stream]]

monad.map(ZStream.unit)(identity)
monadError.map(ZStream.unit)(identity)
semigroupK.combineK(ZStream.unit, ZStream.unit)
bifunctor.leftMap(ZStream.fail(()))(identity)

assert((), anything)
}
)
)
extends DefaultRunnableSpec {
override def spec = suite("summons from catz.core work with only a cats-core dependency")(
test("ZIO instances") {
val monad = implicitly[Monad[UIO]]
val monadError = implicitly[MonadError[Task, Throwable]]
val semigroupK = implicitly[SemigroupK[IO[NonEmptyList[Unit], ?]]]
val bifunctor = implicitly[Bifunctor[IO]]

monad.map(ZIO.unit)(identity)
monadError.map(ZIO.unit)(identity)
semigroupK.combineK(ZIO.unit, ZIO.unit)
bifunctor.leftMap(ZIO.fromOption(None))(identity)

assert(())(anything)
},
test("ZManaged instances") {
val monad = implicitly[Monad[ZManaged[Any, Nothing, ?]]]
val monadError = implicitly[MonadError[Managed[Throwable, ?], Throwable]]
val semigroupK = implicitly[SemigroupK[Managed[Nothing, ?]]]
val bifunctor = implicitly[Bifunctor[Managed]]

monad.map(ZManaged.unit)(identity)
monadError.map(ZManaged.unit)(identity)
semigroupK.combineK(ZManaged.unit, ZManaged.unit)
bifunctor.leftMap(ZManaged.fail(()))(identity)

assert(())(anything)
},
test("ZStream instances") {
val monad = implicitly[Monad[ZStream[Any, Nothing, ?]]]
val monadError = implicitly[MonadError[Stream[Throwable, ?], Throwable]]
val semigroupK = implicitly[SemigroupK[Stream[Nothing, ?]]]
val bifunctor = implicitly[Bifunctor[Stream]]

monad.map(ZStream.unit)(identity)
monadError.map(ZStream.unit)(identity)
semigroupK.combineK(ZStream.unit, ZStream.unit)
bifunctor.leftMap(ZStream.fail(()))(identity)

assert(())(anything)
}
)
}
2 changes: 1 addition & 1 deletion interop-cats/shared/src/main/scala/zio/interop/cats.scala
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private class CatsConcurrentEffect[R](rts: Runtime[R])
)
.interruptible
.nonDaemon
.forkInternal
.fork
.daemon
.map(_.interrupt.unit)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ final class STM[F[+_], +A] private[stm] (private[stm] val underlying: ZSTM[Throw
final def commit(implicit R: Runtime[Any], A: Async[F]): F[A] = STM.atomically(self)

/**
* See [[zio.stm.STM#const]]
*/
final def const[B](b: => B): STM[F, B] = self map (_ => b)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ trait CatsTestFunctions {
* Checks the assertion holds for the given effectfully-computed value.
*/
final def assertF[F[_], R, A](value: F[A], assertion: Assertion[A])(implicit F: Effect[F]): RIO[R, TestResult] =
assertM(fromEffect(value), assertion)
assertM(fromEffect(value))(assertion)

/**
* Checks the effectual test passes for "sufficient" numbers of samples from
Expand Down Expand Up @@ -99,31 +99,31 @@ trait CatsTestFunctions {
final def checkSomeF[F[_], R, A](
rv: Gen[R, A]
)(n: Int)(test: A => F[TestResult])(implicit F: Effect[F]): RIO[R, TestResult] =
checkSomeM(n)(rv)(a => fromEffect(test(a)))
checkNM(n)(rv)(a => fromEffect(test(a)))

/**
* A version of `checkSomeM` that accepts two random variables.
* A version of `checkNM` that accepts two random variables.
*/
final def checkSomeF[F[_], R, A, B](rv1: Gen[R, A], rv2: Gen[R, B])(
n: Int
)(test: (A, B) => F[TestResult])(implicit F: Effect[F]): RIO[R, TestResult] =
checkSomeM(n)(rv1, rv2)((a, b) => fromEffect(test(a, b)))
checkNM(n)(rv1, rv2)((a, b) => fromEffect(test(a, b)))

/**
* A version of `checkSomeM` that accepts three random variables.
* A version of `checkNM` that accepts three random variables.
*/
final def checkSomeF[F[_], R, A, B, C](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C])(
n: Int
)(test: (A, B, C) => F[TestResult])(implicit F: Effect[F]): RIO[R, TestResult] =
checkSomeM(n)(rv1, rv2, rv3)((a, b, c) => fromEffect(test(a, b, c)))
checkNM(n)(rv1, rv2, rv3)((a, b, c) => fromEffect(test(a, b, c)))

/**
* A version of `checkSomeM` that accepts four random variables.
* A version of `checkNM` that accepts four random variables.
*/
final def checkSomeF[F[_], R, A, B, C, D](rv1: Gen[R, A], rv2: Gen[R, B], rv3: Gen[R, C], rv4: Gen[R, D])(
n: Int
)(test: (A, B, C, D) => F[TestResult])(implicit F: Effect[F]): RIO[R, TestResult] =
checkSomeM(n)(rv1, rv2, rv3, rv4)((a, b, c, d) => fromEffect(test(a, b, c, d)))
checkNM(n)(rv1, rv2, rv3, rv4)((a, b, c, d) => fromEffect(test(a, b, c, d)))

/**
* Builds a spec with a single effectful test.
Expand Down
32 changes: 16 additions & 16 deletions interop-cats/shared/src/test/scala/zio/test/interop/TestSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ import zio.test.TestAspect._
import zio.test._

object TestSpec
extends DefaultRunnableSpec(
suite("TestSpec")(
testF("arbitrary effects can be tested") {
for {
result <- IO("Hello from Cats!")
} yield assert(result, equalTo("Hello from Cats!"))
},
timeout(0.milliseconds) {
testF("ZIO interruption is tied to F interruption") {
for {
_ <- IO.never
} yield assert((), anything)
}
} @@ failure
)
)
extends DefaultRunnableSpec {
override def spec = suite("TestSpec")(
testF("arbitrary effects can be tested") {
for {
result <- IO("Hello from Cats!")
} yield assert(result)(equalTo("Hello from Cats!"))
},
timeout(0.milliseconds) {
testF("ZIO interruption is tied to F interruption") {
for {
_ <- IO.never
} yield assert(())(anything)
}
} @@ failure
)
}
2 changes: 1 addition & 1 deletion project/BuildHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ object BuildHelper {
def stdSettings(prjName: String) = Seq(
name := s"$prjName",
scalacOptions := stdOptions,
crossScalaVersions := Seq("2.13.1", "2.12.10", "2.11.12"),
crossScalaVersions := Seq("2.12.10"),
scalaVersion in ThisBuild := crossScalaVersions.value.head,
scalacOptions := stdOptions ++ extraOptions(scalaVersion.value),
libraryDependencies ++= compileOnlyDeps ++ testDeps ++ Seq(
Expand Down

0 comments on commit c9df609

Please sign in to comment.