Skip to content

Commit b1489f7

Browse files
marktoujilinewi101
authored andcommitted
implement assertElements
Add test for Schedule#onDecision and documentation for scheduling (zio#3346) * Add test for Schedule#onDecision and documentation for scheduling * Add documentation to datatypes, remove console functions from ScheduleSpec * fix mdoc compile issue specialize ChunkBuilder (zio#3400) Implement ZRefM (zio#3391) * implement ZRefM * fix Scala 2.13 compatibility issue * address review comments * implement SubscriptionRef * make constructor private * remove managed variant * remove unused import Implement ZIO#mapEffect (zio#3404) * implement mapEffect * implement mapPartial Improve TArray's performance (zio#3407) * Benchmark TArray * Implement fold and transform via unsafe * Improve readability * Implement find via unsafe * Implement findLast via unsafe * Implement foldM via unsafe * Benchmark indexWhere * Implement transformM via unsafe * Implement indexWhere via unsafe * Implement lastIndexOf via unsafe * Remove duplicated code * Implement foldM via ZIO.foldLeft * Remove 0-sized array from benchmark * Implement reduceOption via unsafe * Implement findM via foldM * Help inference via Option.empty * Implement findM via iterate * Implement findLastM via iterate * Remove useless val * Format the sources Update sbt-header to 5.6.0 (zio#3411) Add AssertionM for effectfull assertions (zio#3403) Add result field to AssertionValue to avoid test reevaluation. Protect AssertionValue.assertion to avoid test reevaluation. Use lazy val tryValue = Try(value) to avoid exception reevaluation: lazy val stores only successful case. implement launch (zio#3415) Add alternative combinator to ZSTM (zio#3414) * Drop duplicated test * Remove unnecessary .unit calls * Align the naming * Write failing tests * Keep semantically correct orElse tests * Fix test expectations * Fix orElse behavior on failures * Fix orElse behavior on retries * Reduce flakiness * Revert orElse changes * Introduce alternative combinator * Update docs * Reduce flakiness * Make right retry explicit * Race updater and transaction * Move left-right recovery test to JVM tests * Drop E from orElseSucceed Co-Authored-By: John A. De Goes <[email protected]> * Rename alternative to orTry Co-Authored-By: John A. De Goes <[email protected]> * Revert "Move left-right recovery test to JVM tests" This reverts commit 19f1162. * Tag retry test as JVM-only * Fix compilation issues * Fix docs * Improve scaladoc Co-Authored-By: John A. De Goes <[email protected]> * Fix doc mistake Co-authored-by: John A. De Goes <[email protected]> Update sbt-scalafix to 0.9.15 (zio#3423) Optimize TQueue (zio#3421) Update sbt-ci-release to 1.5.3 (zio#3425) ZIO Test: Support Laws for Capabilities Parameterized on Two Types (zio#3420) * implement ZLaws2 * use AnyF Back up Chunk[Boolean] by Chunk.BitChunks (zio#3419) fix publishing (zio#3433) WIP: Scala.js upgrade to v1.0.0 (zio#2392) (zio#2479) * Update to Scala.js 1.0.0-RC2 * fix for passing testJS * formatting fix * Merge remote-tracking branch 'upstream/master' into feature/scalajs-1.0.0-RC2 * Merge branch 'master' of https://github.com/zio/zio into feature/scalajs-1.0.0-RC2 * sonatype resolver added for izumi-reflect; magnolia updated to v0.12.8 Fix Scala.js build (post zio#2479) (zio#3436) * Fix Scala.js build (post zio#2479) * Move back to shared/Executor source and add jvm/js/native ExecutorPlatformSpecific trait * Fix imports causing build failure on 2.13/dotty Update Magnolia (zio#3432) * Update Magnolia There is a bug in Magnolia versions < 0.15 which causes derivation for case classes with default values to fail. The update should fix it. * Add scala-reflect % Provided dependency, now required for magnolia & exclude scala-compiler Co-authored-by: Kai <[email protected]> Co-authored-by: Kai <[email protected]> Update nyaya-gen to 0.9.1 (zio#3438) Remove sonatype public resolver (zio#3434) Add specialized accessor operations to Chunk (zio#3431) * Add specialized accessor operations to Chunk * Generate only non-empty chunks using chunkWithIndex generator Add ZIO STM blogpost (zio#3443) generalize (zio#3439) Update scala-java-time to 2.0.0 (zio#3446) suspend effects (zio#3444) Fix Publishing on Master (zio#3437) * fix publishing * fix bug add Scalac logo to the Sponsors section in Readme (zio#3379) Implement ZIO#service (zio#3422) * implement getService * add variants * rename Add Diagnostic Code to Has (zio#3377) * add diagnostic code * Fix environment composition * Fix 2.11/dotty Co-authored-by: ioleo <[email protected]> Use short forms where it makes sense (zio#3452) * Use short forms where it makes sense * One more `none` usage. Update to izumi-reflect 1.0.0-M1, use izumi-reflect on dotty (zio#3445) * Update to izumi-reflect-1.0.0-M1, depend on izumi-reflect in dotty * Use one VersionSpecific file for dotty & scala-2 * Adding type signatures to Mock modules to workaround scala/scala3#8764 error: ``` [error] -- Error: PureModule.scala:77:86 [error] 77 | val static = ZIO.accessM[PureModule](_.get.static) [error] | ^ [error] |could not find implicit value for izumi.reflect.Tag[zio.test.mock.module.PureModule.Service]. Did you forget to put on a Tag, TagK or TagKK context bound on one of the parameters in zio.test.mock.module.PureModule.Service? e.g. def x[T: Tag, F[_]: TagK] = .... [error] |I found: [error] | [error] | { [error] | izumi.reflect.Tag.apply[zio.test.mock.module.PureModule.Service](classOf[Any] [error] | , [error] | { [error] | <empty> :izumi.reflect.macrortti.LightTypeTag [error] | } [error] | ):izumi.reflect.Tag[zio.test.mock.module.PureModule.Service] [error] | } [error] | [error] |But method tagFromTagMacro in object Tag does not match type izumi.reflect.Tag[zio.test.mock.module.PureModule.Service]. [error] | [error] |The following import might make progress towards fixing the problem: [error] | [error] | import izumi.reflect.Tag.tagFromTagMacro ``` * add type signature to SpecSpec to workaround error: ``` [error] -- Error: SpecSpec.scala:17:51 [error] 17 | val layer = ZLayer.succeed(new Module.Service {}) [error] | ^ [error] |could not find implicit value for izumi.reflect.Tag[zio.test.SpecSpec.Module.Service]. Did you forget to put on a Tag, TagK or TagKK context bound on one of the parameters in zio.test.SpecSpec.Module.Service? e.g. def x[T: Tag, F[_]: TagK] = .... [error] |I found: [error] | [error] | { [error] | izumi.reflect.Tag.apply[zio.test.SpecSpec.Module.Service](classOf[Any], [error] | { [error] | <empty> :izumi.reflect.macrortti.LightTypeTag [error] | } [error] | ):izumi.reflect.Tag[zio.test.SpecSpec.Module.Service] [error] | } [error] | [error] |But method tagFromTagMacro in object Tag does not match type izumi.reflect.Tag[zio.test.SpecSpec.Module.Service]. [error] | [error] |The following import might make progress towards fixing the problem: [error] | [error] | import izumi.reflect.Tag.tagFromTagMacro ``` * Lift `exceptDotty` from HasSpec & ComposedMockSpec (TaggedSpec still won't pass because deriving is not implemented) * add type signatures to MockSpecUtils, update comments * Workaround type inference-caused test failures in PolyMockSpec - Any was inferred for `Tag` now, probably maybe because Tag parameter is AnyKind, add workaround * Fix `@mockable` macro, restrict valid `Tagged` definitions to just izumi.reflect.Tag * sbt fix fix type signature (zio#3455) Update util-core to 20.4.1 (zio#3457) generalize type signature (zio#3460) doc(test_effects) : add aspect ignore (zio#3462) upgrade monix version (zio#3467) Implement ZManaged#flattenM (zio#3464) * implement flattenM * format * fix Scaladoc reorder type parameters (zio#3463) Implement ZManaged#release (zio#3466) * implement ZManaged#release * rename Use ChunkBuilder more prominently in Chunk (zio#3453) * make Chunk use ChunkBuilder * fix lint failure * consistent parenthesis use * use parens for Chunkbuilder#make * followup * retrigger ci Update reactor-core to 3.3.5.RELEASE (zio#3472) Update magnolia to 0.16.0 (zio#3473) Update nyaya-gen to 0.9.2 (zio#3474) added blog to list (zio#3471) * updated blog for RC18 + http4s .21.x * added new blog to resource page Co-authored-by: Pierre Ricadat <[email protected]> Add zio-easymock to libraries with zio support list (zio#3481) Add ZIO#filterNot and ZSTM#filterNot (zio#3477) * Add ZIO#filterNot and ZSTM#filterNot * Fix typos implement assertElements and assertElements
1 parent ce2259f commit b1489f7

File tree

98 files changed

+4122
-1448
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+4122
-1448
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ To learn more about ZIO, see the following references:
3131

3232
# Sponsors
3333

34+
[![Scalac][Image-Scalac]][Link-Scalac]
35+
36+
[Scalac][Link-Scalac] sponsors ZIO Hackathons and contributes work to multiple projects in ZIO ecosystem.
37+
3438
[![Septimal Mind][Image-SeptimalMind]][Link-SeptimalMind]
3539

3640
[Septimal Mind][Link-SeptimalMind] sponsors work on ZIO Tracing and continuous maintenance.
@@ -39,6 +43,7 @@ To learn more about ZIO, see the following references:
3943

4044
[SoftwareMill][Link-SoftwareMill] generously provides ZIO with paid-for CircleCI build infrastructure.
4145

46+
4247
---
4348

4449
# [Learn More on the ZIO Homepage](https://zio.dev/)
@@ -68,6 +73,7 @@ Copyright 2017 - 2020 John A. De Goes and the ZIO Contributors. All rights reser
6873
[Link-SonatypeReleases]: https://oss.sonatype.org/content/repositories/releases/dev/zio/zio_2.12/ "Sonatype Releases"
6974
[Link-SonatypeSnapshots]: https://oss.sonatype.org/content/repositories/snapshots/dev/zio/zio_2.12/ "Sonatype Snapshots"
7075
[Link-Circle]: https://circleci.com/gh/zio/zio "circleci"
76+
[Link-Scalac]: https://scalac.io "Scalac"
7177
[Link-SoftwareMill]: https://softwaremill.com "SoftwareMill"
7278
[Link-SeptimalMind]: https://7mind.io "Septimal Mind"
7379
[Link-Discord]: https://discord.gg/2ccFBr4 "Discord"
@@ -82,5 +88,6 @@ Copyright 2017 - 2020 John A. De Goes and the ZIO Contributors. All rights reser
8288
[Badge-Discord]: https://img.shields.io/discord/629491597070827530?logo=discord "chat on discord"
8389
[Badge-Twitter]: https://img.shields.io/twitter/follow/zioscala.svg?style=plastic&label=follow&logo=twitter
8490

91+
[Image-Scalac]: ./website/static/img/scalac.svg "Scalac"
8592
[Image-SoftwareMill]: ./website/static/img/softwaremill.svg "SoftwareMill"
8693
[Image-SeptimalMind]: ./website/static/img/septimal_mind.svg "Septimal Mind"

benchmarks/src/main/scala/zio/FiberRefBenchmarks.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class FiberRefBenchmarks {
5353
for {
5454
fiberRefs <- ZIO.foreach(1.to(n))(i => FiberRef.make(i))
5555
_ <- ZIO.foreach_(1.to(n))(_ => ZIO.yieldNow)
56-
values <- ZIO.collectAllPar(fiberRefs.map(_.get))
56+
values <- ZIO.foreachPar(fiberRefs)(_.get)
5757
_ <- verify(values == 1.to(n))(s"Got $values")
5858
} yield ()
5959
}

benchmarks/src/main/scala/zio/ParSequenceBenchmark.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,22 @@ class ParSequenceBenchmark {
5757
result.runSyncUnsafe()
5858
}
5959
@Benchmark
60-
def monixGather(): Long = {
60+
def monixParSequence(): Long = {
6161
val tasks = (0 until count).map(_ => MTask.eval(1)).toList
62-
val result = MTask.gather(tasks).map(_.sum.toLong)
62+
val result = MTask.parSequence(tasks).map(_.sum.toLong)
6363
result.runSyncUnsafe()
6464
}
6565
@Benchmark
66-
def monixGatherUnordered(): Long = {
66+
def monixParSequenceUnordered(): Long = {
6767
val tasks = (0 until count).map(_ => MTask.eval(1)).toList
68-
val result = MTask.gatherUnordered(tasks).map(_.sum.toLong)
68+
val result = MTask.parSequenceUnordered(tasks).map(_.sum.toLong)
6969
result.runSyncUnsafe()
7070
}
7171

7272
@Benchmark
73-
def monixGatherN(): Long = {
73+
def monixParSequenceN(): Long = {
7474
val tasks = (0 until count).map(_ => MTask.eval(1)).toList
75-
val result = MTask.gatherN(parallelism)(tasks).map(_.sum.toLong)
75+
val result = MTask.parSequenceN(parallelism)(tasks).map(_.sum.toLong)
7676
result.runSyncUnsafe()
7777
}
7878

benchmarks/src/main/scala/zio/QueueSequentialBenchmark.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class QueueSequentialBenchmark {
5050
else task.flatMap(_ => repeat(task, max - 1))
5151

5252
val io = for {
53-
_ <- repeat(zioQ.offer(0).map(_ => ()), totalSize)
54-
_ <- repeat(zioQ.take.map(_ => ()), totalSize)
53+
_ <- repeat(zioQ.offer(0).unit, totalSize)
54+
_ <- repeat(zioQ.take.unit, totalSize)
5555
} yield 0
5656

5757
unsafeRun(io)

benchmarks/src/main/scala/zio/chunks/MixedChunkBenchmarks.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ class MixedChunkBenchmarks {
4848
@Benchmark
4949
def fold(): Int = chunk.fold(0)(_ + _)
5050

51+
@Benchmark
52+
def filterM(): Chunk[Int] =
53+
IOBenchmarks.unsafeRun(chunk.filterM[Any, Nothing](n => ZIO.succeed(n % 2 == 0)))
54+
5155
@Benchmark
5256
def map(): Chunk[Int] = chunk.map(_ * 2)
5357

@@ -61,6 +65,7 @@ class MixedChunkBenchmarks {
6165
def mapM(): UIO[Unit] = chunk.mapM_(_ => ZIO.unit)
6266

6367
@Benchmark
64-
def foldM(): UIO[Int] = chunk.foldM(0)((s, a) => ZIO.succeed(s + a))
68+
def foldM(): Int =
69+
IOBenchmarks.unsafeRun(chunk.foldM[Any, Nothing, Int](0)((s, a) => ZIO.succeed(s + a)))
6570

6671
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package zio.stm
2+
3+
import java.util.concurrent.TimeUnit
4+
5+
import org.openjdk.jmh.annotations._
6+
7+
import zio._
8+
9+
@State(Scope.Thread)
10+
@BenchmarkMode(Array(Mode.Throughput))
11+
@OutputTimeUnit(TimeUnit.SECONDS)
12+
@Measurement(iterations = 15, timeUnit = TimeUnit.SECONDS, time = 3)
13+
@Warmup(iterations = 15, timeUnit = TimeUnit.SECONDS, time = 3)
14+
@Fork(1)
15+
class TArrayOpsBenchmarks {
16+
import IOBenchmarks.unsafeRun
17+
18+
@Param(Array("10", "100", "1000", "10000", "100000"))
19+
var size: Int = _
20+
21+
private var idx: Int = _
22+
private var array: TArray[Int] = _
23+
24+
// used to ammortize the relative cost of unsafeRun
25+
// compared to benchmarked operations
26+
private val calls = List.fill(500)(false)
27+
28+
@Setup(Level.Trial)
29+
def setup(): Unit = {
30+
val data = (1 to size).toList
31+
idx = size / 2
32+
array = unsafeRun(TArray.fromIterable(data).commit)
33+
}
34+
35+
@Benchmark
36+
def lookup(): Unit =
37+
unsafeRun(ZIO.foreach_(calls)(_ => array(idx).commit))
38+
39+
@Benchmark
40+
def find(): Option[Int] =
41+
unsafeRun(array.find(_ == size).commit)
42+
43+
@Benchmark
44+
def findM(): Option[Int] =
45+
unsafeRun(array.findM(a => STM.succeedNow(a == size)).commit)
46+
47+
@Benchmark
48+
def fold(): Int =
49+
unsafeRun(array.fold(0)(_ + _).commit)
50+
51+
@Benchmark
52+
def foldM(): Int =
53+
unsafeRun(array.foldM(0)((acc, e) => STM.succeedNow(acc + e)).commit)
54+
55+
@Benchmark
56+
def indexWhere(): Int =
57+
unsafeRun(array.indexWhere(_ == size).commit)
58+
59+
@Benchmark
60+
def indexWhereM(): Int =
61+
unsafeRun(array.indexWhereM(a => STM.succeedNow(a == size)).commit)
62+
63+
@Benchmark
64+
def reduceOption(): Option[Int] =
65+
unsafeRun(array.reduceOption(_ + _).commit)
66+
67+
@Benchmark
68+
def reduceOptionM(): Option[Int] =
69+
unsafeRun(array.reduceOptionM((a, b) => STM.succeedNow(a + b)).commit)
70+
71+
@Benchmark
72+
def transform(): Unit =
73+
unsafeRun(array.transform(_ + 1).commit)
74+
75+
@Benchmark
76+
def transformM(): Unit =
77+
unsafeRun(array.transformM(i => STM.succeedNow(i + 1)).commit)
78+
79+
@Benchmark
80+
def update(): Unit =
81+
unsafeRun(ZIO.foreach_(calls)(_ => array.update(idx, _ + 1).commit))
82+
83+
@Benchmark
84+
def updateM(): Unit =
85+
unsafeRun(ZIO.foreach_(calls)(_ => array.updateM(idx, i => STM.succeedNow(i + 1)).commit))
86+
}

build.sbt

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ lazy val test = crossProject(JSPlatform, JVMPlatform)
206206
.settings(crossProjectSettings)
207207
.settings(macroDefinitionSettings)
208208
.settings(macroExpansionSettings)
209+
.settings(
210+
libraryDependencies ++= Seq(
211+
("org.portable-scala" %%% "portable-scala-reflect" % "1.0.0").withDottyCompat(scalaVersion.value)
212+
)
213+
)
209214

210215
lazy val testJVM = test.jvm.settings(dottySettings)
211216
lazy val testJS = test.js
@@ -229,10 +234,11 @@ lazy val testMagnolia = crossProject(JVMPlatform, JSPlatform)
229234
.in(file("test-magnolia"))
230235
.dependsOn(test)
231236
.settings(stdSettings("zio-test-magnolia"))
237+
.settings(macroDefinitionSettings)
232238
.settings(
233239
crossScalaVersions --= Seq("2.11.12", dottyVersion),
234240
scalacOptions += "-language:experimental.macros",
235-
libraryDependencies += "com.propensive" %%% "magnolia" % "0.12.6"
241+
libraryDependencies += ("com.propensive" %%% "magnolia" % "0.16.0").exclude("org.scala-lang", "scala-compiler")
236242
)
237243

238244
lazy val testMagnoliaJVM = testMagnolia.jvm
@@ -273,13 +279,8 @@ lazy val testRunner = crossProject(JVMPlatform, JSPlatform)
273279
.in(file("test-sbt"))
274280
.settings(stdSettings("zio-test-sbt"))
275281
.settings(crossProjectSettings)
276-
.settings(
277-
libraryDependencies ++= Seq(
278-
"org.portable-scala" %%% "portable-scala-reflect" % "1.0.0"
279-
),
280-
mainClass in (Test, run) := Some("zio.test.sbt.TestMain")
281-
)
282-
.jsSettings(libraryDependencies ++= Seq("org.scala-js" %% "scalajs-test-interface" % "0.6.32"))
282+
.settings(mainClass in (Test, run) := Some("zio.test.sbt.TestMain"))
283+
.jsSettings(libraryDependencies ++= Seq("org.scala-js" %% "scalajs-test-interface" % "1.0.1"))
283284
.jvmSettings(libraryDependencies ++= Seq("org.scala-sbt" % "test-interface" % "1.0"))
284285
.dependsOn(core)
285286
.dependsOn(test)
@@ -326,18 +327,18 @@ lazy val benchmarks = project.module
326327
Seq(
327328
"co.fs2" %% "fs2-core" % "2.3.0",
328329
"com.google.code.findbugs" % "jsr305" % "3.0.2",
329-
"com.twitter" %% "util-core" % "20.4.0",
330+
"com.twitter" %% "util-core" % "20.4.1",
330331
"com.typesafe.akka" %% "akka-stream" % "2.6.4",
331-
"io.monix" %% "monix" % "3.1.0",
332-
"io.projectreactor" % "reactor-core" % "3.3.4.RELEASE",
332+
"io.monix" %% "monix" % "3.2.0",
333+
"io.projectreactor" % "reactor-core" % "3.3.5.RELEASE",
333334
"io.reactivex.rxjava2" % "rxjava" % "2.2.19",
334335
"org.ow2.asm" % "asm" % "8.0.1",
335336
"org.scala-lang" % "scala-compiler" % scalaVersion.value % Provided,
336337
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
337338
"org.typelevel" %% "cats-effect" % "2.1.3",
338339
"org.scalacheck" %% "scalacheck" % "1.14.3",
339340
"hedgehog" %% "hedgehog-core" % "0.1.0",
340-
"com.github.japgolly.nyaya" %% "nyaya-gen" % "0.9.0"
341+
"com.github.japgolly.nyaya" %% "nyaya-gen" % "0.9.2"
341342
),
342343
unusedCompileDependenciesFilter -= libraryDependencies.value
343344
.map(moduleid => moduleFilter(organization = moduleid.organization, name = moduleid.name))

0 commit comments

Comments
 (0)