Skip to content

Commit

Permalink
Upgrade to ZIO 2.0.0-RC6 (#916)
Browse files Browse the repository at this point in the history
* upgrade zio version

* fix compilation error
  • Loading branch information
adamgfraser authored May 3, 2022
1 parent 5255a0c commit a95f7b8
Show file tree
Hide file tree
Showing 51 changed files with 107 additions and 95 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ addCommandAlias(
";lawsNative/test;experimentalLawsNative/test" // `test` currently executes only compilation, see `nativeSettings` in `BuildHelper`
)

val zioVersion = "2.0.0-RC5"
val zioVersion = "2.0.0-RC6"

lazy val root = project
.in(file("."))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import scala.concurrent.{Future, blocking}

object FutureCommutativeEitherSpec extends ZIOSpecDefault {

def spec: Spec[Any, TestFailure[Throwable], TestSuccess] =
def spec: Spec[Any, Throwable] =
suite("FutureCommutativeEitherSpec")(
test("FutureCommutativeEither returns the first future that is completed") {
ZIO.blocking {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package zio.prelude

import zio.test.Assertion._
import zio.test.{ZIOSpecDefault, ZSpec, assert}
import zio.test.{Spec, ZIOSpecDefault, assert}

object AssertionSpec extends ZIOSpecDefault {

def spec: ZSpec[Environment, Any] = suite("Assertion")(
def spec: Spec[Environment, Any] = suite("Assertion")(
test("matches must fail when the regex only match a part of the string") {
assert((Assertion.matches("biking").apply("toto like biking")))(isLeft(anything))
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object AssociativeBothSpec extends ZIOSpecDefault {
implicit val chunkOptionAssociativeBoth: AssociativeBoth[ChunkOption] =
AssociativeBoth.compose[Chunk, Option]

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("AssociativeBothSpec")(
suite("laws")(
test("chunk . option")(checkAllLaws(AssociativeBothLaws)(chunkOptionGenF, Gen.int))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import zio.test.laws._

object AssociativeEitherSpec extends ZIOSpecDefault {

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("AssociativeEitherSpec")(
suite("laws")(
test("either")(checkAllLaws(AssociativeEitherLaws)(GenF.either(Gen.int), Gen.int))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import zio.test.laws._

object AssociativeFlattenSpec extends ZIOSpecDefault {

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("AssociativeFlattenSpec")(
suite("laws")(
test("map")(checkAllLaws(AssociativeFlattenLaws)(GenFs.map(Gen.int), Gen.int))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import zio.test._

object AssociativeSpec extends ZIOSpecDefault {

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("AssociativeSpec")(
suite("laws")(
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import zio.test._

object CoherentSpec extends ZIOSpecDefault {

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("CoherentSpec")(
test("HashOrd") {
val instance = implicitly[HashOrd[Double]].contramap[Int](_.toDouble)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import zio.test.laws._

object CommutativeBothSpec extends ZIOSpecDefault {

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("CommutativeBothSpec")(
suite("laws")(
test("chunk")(checkAllLaws(CommutativeBothLaws)(GenF.chunk, Gen.chunkOf(Gen.int))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object CommutativeEitherSpec extends ZIOSpecDefault {

coherent.CommutativeEitherDeriveEqualInvariant.derive[Set]

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("CommutativeEitherSpec")(
suite("laws")(
test("set")(checkAllLaws(CommutativeEitherLaws)(GenF.set, Gen.int))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object CommutativeSpec extends ZIOSpecDefault {
private implicit val DoubleEqual: Equal[Double] = Equal.DoubleEqualWithEpsilon()
private implicit val FloatEqual: Equal[Float] = Equal.FloatEqualWithEpsilon()

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("CommutativeSpec")(
suite("laws")(
test("boolean conjuction")(checkAllLaws(CommutativeLaws)(Gen.boolean.map(And(_)))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object CovariantSpec extends ZIOSpecDefault {
implicit val chunkOptionCovariant: Covariant[ChunkOption] =
Covariant[Chunk].compose(Covariant[Option])

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("CovariantSpec")(
suite("laws")(
test("cause")(checkAllLaws(CovariantLaws)(GenFs.cause, Gen.int)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object DebugSpec extends ZIOSpecDefault {
def expectedTupleFull(n: Int)(v: Int): String = s"scala.Tuple$n(${List.fill(n)(v).mkString(", ")})"
def expectedTupleSimple(n: Int)(v: Int): String = s"(${List.fill(n)(v).mkString(", ")})"

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("DebugSpec")(
suite("ScalaRenderer")(
test("unit")(check(Gen.unit)(primScalaTest(_, Some("()")))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import zio.test.laws._

object EqualSpec extends ZIOSpecDefault {

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("EqualSpec")(
suite("laws")(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ object EquivalenceSpec extends ZIOSpecDefault {
val genNothing: Gen[Any, Nothing] =
Gen(ZStream.empty)

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("EquivalenceSpec")(
suite("laws")(
test("either") {
Expand Down
4 changes: 2 additions & 2 deletions core-tests/shared/src/test/scala/zio/prelude/Fixtures.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package zio.prelude

import zio.test.laws.GenF
import zio.test.{Gen, Sized}
import zio.{Chunk, ZTraceElement}
import zio.{Chunk, Trace}

object Fixtures {
type ChunkOption[+A] = Chunk[Option[A]]

val chunkOptionGenF: GenF[Sized, ChunkOption] =
new GenF[Sized, ChunkOption] {
def apply[R1 <: Sized, A](gen: Gen[R1, A])(implicit
trace: ZTraceElement
trace: Trace
): Gen[R1, Chunk[Option[A]]] =
Gen.chunkOf(Gen.option(gen))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ object ForEachSpec extends ZIOSpecDefault {
implicit val chunkOptionForEach: ForEach[ChunkOption] =
ForEach[Chunk].compose[Option]

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("ForEachSpec")(
suite("laws")(
test("chunk")(checkAllLaws(ForEachLaws)(GenF.chunk, Gen.int)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object HashSpec extends ZIOSpecDefault {
final def scalaHashCodeConsistency[R, A: Hash](gen: Gen[R, A]): ZIO[R with TestConfig, Nothing, TestResult] =
check(gen)(a => assert(a.hash)(equalTo(a.hashCode)))

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("HashSpec")(
suite("laws")(
test("boolean")(checkAllLaws(HashLaws)(Gen.boolean)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object IdempotentSpec extends ZIOSpecDefault {
private implicit val DoubleEqual: Equal[Double] = Equal.DoubleEqualWithEpsilon()
private implicit val FloatEqual: Equal[Float] = Equal.FloatEqualWithEpsilon()

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("IdempotentSpec")(
suite("laws")(
test("boolean conjuction")(checkAllLaws(IdempotentLaws)(Gen.boolean.map(And(_)))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import zio.test.laws._

object IdentityBothSpec extends ZIOSpecDefault {

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("IdentityBothSpec")(
suite("laws")(
test("either")(checkAllLaws(IdentityBothLaws)(GenF.either(Gen.int), Gen.int)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import zio.test.laws._

object IdentityEitherSpec extends ZIOSpecDefault {

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("IdentityEitherSpec")(
suite("laws")(
test("chunk")(checkAllLaws(IdentityEitherlaws)(GenF.chunk, Gen.int)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import zio.test.laws._

object IdentityFlattenSpec extends ZIOSpecDefault {

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("IdentityFlattenSpec")(
suite("laws")(
test("chunk")(checkAllLaws(IdentityFlattenLaws)(GenF.chunk, Gen.chunkOf(Gen.int))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object IdentitySpec extends ZIOSpecDefault {
private implicit val DoubleEqual: Equal[Double] = Equal.DoubleEqualWithEpsilon()
private implicit val FloatEqual: Equal[Float] = Equal.FloatEqualWithEpsilon()

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("IdentitySpec")(
suite("laws")(
test("boolean conjuction")(checkAllLaws(IdentityLaws)(Gen.boolean.map(And(_)))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object InverseSpec extends ZIOSpecDefault {
private implicit val DoubleEqual: Equal[Double] = Equal.DoubleEqualWithEpsilon()
private implicit val FloatEqual: Equal[Float] = Equal.FloatEqualWithEpsilon()

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("InverseSpec")(
suite("laws")(
test("byte addition")(checkAllLaws(InverseLaws)(Gen.byte.map(Sum(_)))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import zio.test.laws._

object NaturalSpec extends ZIOSpecDefault {

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("NaturalSpec")(
suite("laws")(
test("product commutative")(checkAllLaws(CommutativeLaws)(Gens.anyNatural.map(Prod(_)))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import zio.prelude.NewtypeSpecTypes._
import zio.prelude.laws._
import zio.prelude.newtypes.{And, Or, Sum}
import zio.test.Assertion.{equalTo => _, _}
import zio.test.AssertionM.Render.param
import zio.test.{Assertion => TestAssertion, _}

object NewtypeSpec extends ZIOSpecDefault {
Expand Down Expand Up @@ -43,7 +42,7 @@ object NewtypeSpec extends ZIOSpecDefault {
)
},
test("invalid values at compile-time") {
assertM(typeCheck("Natural(-1, -8, 4, -3)"))(
assertZIO(typeCheck("Natural(-1, -8, 4, -3)"))(
isLeft(
containsStringWithoutAnsi("-1 did not satisfy greaterThanOrEqualTo(0)") &&
containsStringWithoutAnsi("-8 did not satisfy greaterThanOrEqualTo(0)") &&
Expand All @@ -52,7 +51,7 @@ object NewtypeSpec extends ZIOSpecDefault {
)
} @@ TestAspect.exceptScala3,
test("invalid value at run-time") {
assertM(typeCheck("Natural(-1)"))(
assertZIO(typeCheck("Natural(-1)"))(
isLeft(containsStringWithoutAnsi("-1 did not satisfy greaterThanOrEqualTo(0)"))
)
} @@ TestAspect.exceptScala3,
Expand Down Expand Up @@ -149,5 +148,5 @@ object NewtypeSpec extends ZIOSpecDefault {
}

private def containsStringWithoutAnsi(element: String): TestAssertion[String] =
TestAssertion.assertion("containsStringWithoutAnsi")(param(element))(_.removingAnsiCodes.contains(element))
TestAssertion.assertion("containsStringWithoutAnsi")(_.removingAnsiCodes.contains(element))
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object NonEmptyForEachSpec extends ZIOSpecDefault {
val genIntFunction2: Gen[Any, (Int, Int) => Int] =
Gen.function2(genInt)

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("NonEmptyForEachSpec")(
suite("laws")(
test("nonEmptyChunk")(checkAllLaws(NonEmptyForEachLaws)(GenFs.nonEmptyChunk, Gen.int))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ object NonEmptyListSpec extends ZIOSpecDefault {
index <- Gen.int(-2, cons.length + 2)
} yield (cons, index)

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("NonEmptyListSpec")(
suite("laws")(
test("associative")(checkAllLaws(AssociativeLaws)(genNonEmptyList)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object NonEmptySetSpec extends ZIOSpecDefault {
private lazy val genNonEmptySet: Gen[Sized, NonEmptySet[Int]] =
genSet.map(NonEmptySet.fromSetOption(_).get)

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("NonEmptySetSpec")(
suite("laws")(
test("commutativeEither")(checkAllLaws(CommutativeEitherLaws)(GenFs.nonEmptySet, Gen.int)),
Expand Down
2 changes: 1 addition & 1 deletion core-tests/shared/src/test/scala/zio/prelude/OrdSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object OrdSpec extends ZIOSpecDefault {
}
}

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("OrdSpec")(
suite("laws")(
test("boolean")(checkAllLaws(OrdLaws)(Gen.boolean)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object ParSeqSpec extends ZIOSpecDefault {

val hash = ParSeq.parSeqHash

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("parSeqSpec")(
suite("laws")(
test("covariant") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import zio.test.laws._

object PartialOrdSpec extends ZIOSpecDefault {

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("OrdSpec")(
suite("laws")(
test("map")(checkAllLaws(PartialOrdLaws)(Gen.mapOf(Gen.int, Gen.int))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ object SafeFunctionSpec extends ZIOSpecDefault {
def increment(n: Int): Int =
n + 1

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("SafeFunctionSpec")(
test("andThen") {
val wordCount = SafeFunction(words) andThen SafeFunction(count)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import zio.prelude.laws._
import zio.prelude.newtypes._
import zio.test._
import zio.test.laws._
import zio.{Chunk, ZTraceElement}
import zio.{Chunk, Trace}

object ZNonEmptySetSpec extends ZIOSpecDefault {

def genFZNonEmptySet[R <: Sized, B](
b: Gen[R, B]
): GenF[R, ({ type lambda[+x] = ZNonEmptySet[x, B] })#lambda] =
new GenF[R, ({ type lambda[+x] = ZNonEmptySet[x, B] })#lambda] {
def apply[R1 <: R, A](a: Gen[R1, A])(implicit trace: ZTraceElement): Gen[R1, ZNonEmptySet[A, B]] =
def apply[R1 <: R, A](a: Gen[R1, A])(implicit trace: Trace): Gen[R1, ZNonEmptySet[A, B]] =
genZNonEmptySet(a, b)
}

Expand All @@ -29,7 +29,7 @@ object ZNonEmptySetSpec extends ZIOSpecDefault {
implicit def SumIdentity[A: Identity]: Identity[Sum[A]] =
Identity[A].invmap(Equivalence(Sum.wrap, Sum.unwrap))

def spec: ZSpec[Environment, Any] =
def spec: Spec[Environment, Any] =
suite("ZNonEmptySetSpec")(
suite("laws")(
test("combine commutative")(
Expand All @@ -50,7 +50,7 @@ object ZNonEmptySetSpec extends ZIOSpecDefault {
ZNonEmptySetDeriveEqual(IntHashOrd, Identity[Sum[Int]])
),
IntHashOrd,
implicitly[ZTraceElement]
implicitly[Trace]
)
),
test("hash")(checkAllLaws(HashLaws)(genZNonEmptySet(Gen.int, Gen.int)))
Expand Down
Loading

0 comments on commit a95f7b8

Please sign in to comment.