Skip to content

Commit

Permalink
Upgrade To ZIO 2.0.0-RC2 (#560)
Browse files Browse the repository at this point in the history
* upgrade zio version

* reduce samples on scala js
  • Loading branch information
adamgfraser authored Jan 31, 2022
1 parent b2be1f4 commit 5d70bca
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 45 deletions.
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ addCommandAlias(

addCommandAlias("testJS", "zioJsonJS/test")

val zioVersion = "2.0.0-RC1"
val zioVersion = "2.0.0-RC2"

lazy val root = project
.in(file("."))
Expand Down Expand Up @@ -268,7 +268,7 @@ lazy val zioJsonInteropHttp4s = project
"org.http4s" %% "http4s-dsl" % "0.23.7",
"dev.zio" %% "zio" % zioVersion,
"org.typelevel" %% "cats-effect" % "3.3.0",
"dev.zio" %% "zio-interop-cats" % "3.3.0-RC1" % "test",
"dev.zio" %% "zio-interop-cats" % "3.3.0-RC2" % "test",
"dev.zio" %% "zio-test" % zioVersion % "test",
"dev.zio" %% "zio-test-sbt" % zioVersion % "test"
),
Expand Down
24 changes: 0 additions & 24 deletions zio-json/jvm/src/main/scala/zio/JsonPackagePlatformSpecific.scala
Original file line number Diff line number Diff line change
Expand Up @@ -85,28 +85,4 @@ trait JsonPackagePlatformSpecific {
}
}
}

private[zio] def fromManagedPush[Env, Err, In, Out](
push: ZManaged[Env, Nothing, Option[Chunk[In]] => ZIO[Env, Err, Chunk[Out]]]
): ZPipeline[Env, Err, In, Out] = {

def pull(
push: Option[Chunk[In]] => ZIO[Env, Err, Chunk[Out]]
): ZChannel[Env, Nothing, Chunk[In], Any, Err, Chunk[Out], Any] =
ZChannel.readWith[Env, Nothing, Chunk[In], Any, Err, Chunk[Out], Any](
in =>
ZChannel
.fromZIO(push(Some(in)))
.flatMap(out => ZChannel.write(out))
.zipRight[Env, Nothing, Chunk[In], Any, Err, Chunk[Out], Any](pull(push)),
err => ZChannel.fail(err),
_ => ZChannel.fromZIO(push(None)).flatMap(out => ZChannel.write(out))
)

ZPipeline.fromChannel {
ZChannel.unwrapManaged[Env, Nothing, Chunk[In], Any, Err, Chunk[Out], Any] {
push.map(pull)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ trait JsonDecoderPlatformSpecific[A] { self: JsonDecoder[A] =>
final def decodeJsonPipeline(
delimiter: JsonStreamDelimiter = JsonStreamDelimiter.Array
): ZPipeline[Any, Throwable, Char, A] =
fromManagedPush {
ZPipeline.fromPush {
for {
// format: off
runtime <- ZManaged.runtime[Any]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ trait JsonEncoderPlatformSpecific[A] { self: JsonEncoder[A] =>
delimiter: Option[Char],
endWith: Option[Char]
): ZPipeline[Any, Throwable, A, Char] =
fromManagedPush {
ZPipeline.fromPush {
for {
runtime <- ZIO.runtime[Any].toManaged
chunkBuffer <- Ref.makeManaged(Chunk.fromIterable(startWith.toList))
Expand Down
34 changes: 17 additions & 17 deletions zio-json/shared/src/test/scala/zio/json/RoundTripSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ object RoundTripSpec extends DefaultRunnableSpec {
},
test("shorts") {
check(Gen.short)(assertRoundtrips[Short])
} @@ samples(10000),
} @@ jvm(samples(10000)),
test("ints") {
check(Gen.int)(assertRoundtrips[Int])
} @@ samples(10000),
} @@ jvm(samples(10000)),
test("longs") {
check(Gen.long)(assertRoundtrips[Long])
} @@ samples(10000),
} @@ jvm(samples(10000)),
test("bigInts") {
check(genBigInteger)(assertRoundtrips[java.math.BigInteger])
} @@ samples(10000),
} @@ jvm(samples(10000)),
test("floats") {
// NaN / Infinity is tested manually, because of == semantics
check(Gen.float.filter(java.lang.Float.isFinite))(assertRoundtrips[Float])
} @@ samples(10000),
} @@ jvm(samples(10000)),
test("doubles") {
// NaN / Infinity is tested manually, because of == semantics
check(Gen.double.filter(java.lang.Double.isFinite))(assertRoundtrips[Double])
} @@ samples(10000),
} @@ jvm(samples(10000)),
test("AST") {
check(genAst)(assertRoundtrips[Json])
},
Expand All @@ -49,19 +49,19 @@ object RoundTripSpec extends DefaultRunnableSpec {
},
test("Duration") {
check(genDuration)(assertRoundtrips[Duration])
} @@ samples(10000),
} @@ jvm(samples(10000)),
test("Instant") {
check(genInstant)(assertRoundtrips[Instant])
} @@ samples(10000),
} @@ jvm(samples(10000)),
test("LocalDate") {
check(genLocalDate)(assertRoundtrips[LocalDate])
} @@ samples(10000),
} @@ jvm(samples(10000)),
test("LocalDateTime") {
check(genLocalDateTime)(assertRoundtrips[LocalDateTime])
} @@ samples(10000),
} @@ jvm(samples(10000)),
test("LocalTime") {
check(genLocalTime)(assertRoundtrips[LocalTime])
} @@ samples(10000),
} @@ jvm(samples(10000)),
test("Month") {
check(genMonth)(assertRoundtrips[Month])
},
Expand All @@ -70,22 +70,22 @@ object RoundTripSpec extends DefaultRunnableSpec {
},
test("OffsetDateTime") {
check(genOffsetDateTime)(assertRoundtrips[OffsetDateTime])
} @@ samples(10000),
} @@ jvm(samples(10000)),
test("OffsetTime") {
check(genOffsetTime)(assertRoundtrips[OffsetTime])
} @@ samples(10000),
} @@ jvm(samples(10000)),
test("Period") {
check(genPeriod)(assertRoundtrips[Period])
} @@ samples(10000),
} @@ jvm(samples(10000)),
test("Year") {
check(genYear)(assertRoundtrips[Year])
} @@ samples(10000),
} @@ jvm(samples(10000)),
test("YearMonth") {
check(genYearMonth)(assertRoundtrips[YearMonth])
} @@ samples(10000),
} @@ jvm(samples(10000)),
test("ZonedDateTime") {
check(genZonedDateTime)(assertRoundtrips[ZonedDateTime])
} @@ samples(10000),
} @@ jvm(samples(10000)),
test("ZoneId") {
check(genZoneId)(assertRoundtrips[ZoneId])
},
Expand Down

0 comments on commit 5d70bca

Please sign in to comment.