Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3932,6 +3932,14 @@ object ZStreamSpec extends ZIOBaseSpec {
)
})
),
suite("toQueueOfElements")(
test("propagates defects") {
for {
queue <- ZStream.dieMessage("die").toQueueOfElements(1)
exit <- queue.take
} yield assert(exit)(dies(hasMessage(equalTo("die"))))
}
),
suite("toReader")(
test("read one-by-one") {
check(tinyListOf(Gen.chunkOf(Gen.char))) { chunks =>
Expand Down
4 changes: 2 additions & 2 deletions streams/shared/src/main/scala/zio/stream/ZStream.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2756,13 +2756,13 @@ final class ZStream[-R, +E, +A] private (val channel: ZChannel[R, Any, Any, Any,
queue: => Enqueue[Exit[Option[E], A]]
)(implicit trace: Trace): ZIO[R with Scope, Nothing, Unit] = {
lazy val writer: ZChannel[R, E, Chunk[A], Any, Nothing, Exit[Option[E], A], Any] =
ZChannel.readWith[R, E, Chunk[A], Any, Nothing, Exit[Option[E], A], Any](
ZChannel.readWithCause[R, E, Chunk[A], Any, Nothing, Exit[Option[E], A], Any](
in =>
in.foldLeft[ZChannel[R, Any, Any, Any, Nothing, Exit[Option[E], A], Any]](ZChannel.unit) {
case (channel, a) =>
channel *> ZChannel.write(Exit.succeed(a))
} *> writer,
err => ZChannel.write(Exit.fail(Some(err))),
err => ZChannel.write(Exit.failCause(err.map(Some(_)))),
_ => ZChannel.write(Exit.fail(None))
)

Expand Down