Skip to content

Commit

Permalink
Merge pull request #53 from scala-steward/update/zio-2.0.0-RC4
Browse files Browse the repository at this point in the history
Update zio, zio-streams, zio-test, ... to 2.0.0-RC4
  • Loading branch information
vigoo authored Apr 9, 2022
2 parents fd36285 + 1a63037 commit 0ea97be
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import zio.test.Assertion.{anything, isRight}
import zio.test._

/** Tests whether the benchmark examples run with success */
object BenchmarksSpec extends DefaultRunnableSpec {
object BenchmarksSpec extends ZIOSpecDefault {
override def spec: ZSpec[TestEnvironment, Any] =
suite("Benchmarks")(
suite("basic")(
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ addCommandAlias(
";zioParserNative/test"
)

val zioVersion = "2.0.0-RC3"
val zioVersion = "2.0.0-RC5"

lazy val root = (project in file("."))
.aggregate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import zio.test.Assertion._
import zio.test.TestAspect._
import zio.test._

object CalibanParserSpec extends DefaultRunnableSpec {
object CalibanParserSpec extends ZIOSpecDefault {

def spec0: Spec[Any, TestFailure[ParsingError], TestSuccess] = suite("CalibanParserSpec")(
test("simple query with fields") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package zio.parser.target

import zio.parser.internal.Stack
import zio.stream.ZStream
import zio.{ChunkBuilder, Queue, Runtime, UIO, ZIO, ZQueue}
import zio.{ChunkBuilder, Queue, Runtime, UIO, ZIO}

class ZStreamTarget[R, Output](runtime: Runtime[R]) extends Target[Output] {
private val queue: Queue[Output] = runtime.unsafeRun(ZQueue.unbounded[Output])
private val queue: Queue[Output] = runtime.unsafeRun(Queue.unbounded[Output])

val stream: ZStream[Any, Nothing, Output] = ZStream.fromQueue(queue)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import zio.parser.Parser.ParserError
import zio.test.Assertion._
import zio.test._

object ParserSpec extends DefaultRunnableSpec {
object ParserSpec extends ZIOSpecDefault {
private val charA: Syntax[String, Char, Char, Char, Char] = Syntax.char('a', "not a").as('a')
private val charB: Syntax[String, Char, Char, Char, Char] = Syntax.char('b', "not b").as('b')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import zio.Chunk
import zio.test.Assertion._
import zio.test._

object PrinterSpec extends DefaultRunnableSpec {
object PrinterSpec extends ZIOSpecDefault {
private val charA: Syntax[String, Char, Char, Char, Char] =
Syntax.charIn('a')

Expand Down
34 changes: 23 additions & 11 deletions zio-parser/shared/src/test/scala/zio/parser/RegexSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import zio._
import zio.test.Assertion._
import zio.test._

import scala.annotation.nowarn

object RegexSpec extends DefaultRunnableSpec {
object RegexSpec extends ZIOSpecDefault {
val keywordStrings: List[String] =
List(
"abstract",
Expand Down Expand Up @@ -62,7 +60,7 @@ object RegexSpec extends DefaultRunnableSpec {

val keywords: Regex.Tabular.Tabular = Regex.Tabular(keywordsRegex)

override def spec: ZSpec[Environment, Any] =
override def spec: ZSpec[TestEnvironment, Any] =
suite("RegexSpec")(
suite("string")(
test("positive matches") {
Expand Down Expand Up @@ -211,24 +209,38 @@ object RegexSpec extends DefaultRunnableSpec {
}
)

@nowarn private def singleChar(name: String, r: Regex, test: Char => Boolean, gen: Gen[Random, Char] = Gen.char) =
testM(name) {
private def singleChar(
name: String,
r: Regex,
f: Char => Boolean,
gen: Gen[Any, Char] = Gen.char
): ZSpec[TestConfig, Any] =
test(name) {
val compiled = r.compile
check(gen) { ch =>
assertTrue(compiled.test(0, ch.toString) == 1 == test(ch))
assertTrue(compiled.test(0, ch.toString) == 1 == f(ch))
}
}

@nowarn private def multiCharPassing(name: String, r: Regex, gen: Gen[Random, Char]) =
testM(name) {
private def multiCharPassing(
name: String,
r: Regex,
gen: Gen[Any, Char]
): ZSpec[Sized with TestConfig, Any] =
test(name) {
val compiled = r.compile
check(Gen.chunkOf1(gen)) { input =>
assertTrue(compiled.test(0, new String(input.toArray)) == input.length)
}
}

@nowarn private def multiCharFailing(name: String, r: Regex, gen: Gen[Random, Char], counterexample: Char) =
testM(name) {
private def multiCharFailing(
name: String,
r: Regex,
gen: Gen[Any, Char],
counterexample: Char
): ZSpec[Sized with TestConfig, Any] =
test(name) {
val compiled = r.compile
check(Gen.chunkOf1(gen)) { input =>
Random.nextIntBetween(0, input.length).map { injectionPoint =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import zio.parser.{Printer, _}
import zio.test.Assertion._
import zio.test._

object BashPrettyPrinterExample extends DefaultRunnableSpec {
object BashPrettyPrinterExample extends ZIOSpecDefault {
override def spec: ZSpec[TestEnvironment, Any] =
suite("Bash pretty printer example")(
suite("Conditions")(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import zio.parser.{Parser, Printer, Syntax, _}
import zio.test.Assertion._
import zio.test._

object ContextualExample extends DefaultRunnableSpec {
object ContextualExample extends ZIOSpecDefault {

// Context sensitive example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import zio.parser.{Syntax, _}
import zio.test.Assertion._
import zio.test._

object ExpressionExample extends DefaultRunnableSpec {
object ExpressionExample extends ZIOSpecDefault {

sealed trait OpType
case object Add extends OpType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import zio.parser.{Syntax, _}
import zio.test.Assertion.{equalTo, isRight}
import zio.test._

object JsonExample extends DefaultRunnableSpec {
object JsonExample extends ZIOSpecDefault {
sealed abstract class Json
object Json {
final case class Obj(fields: Chunk[(String, Json)]) extends Json
Expand Down

0 comments on commit 0ea97be

Please sign in to comment.