Skip to content

Commit

Permalink
Add tests for mergePreferred
Browse files Browse the repository at this point in the history
  • Loading branch information
shagoon committed Jun 2, 2023
1 parent ad9e8c7 commit f155c51
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions core/shared/src/test/scala/fs2/StreamMergeSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,37 @@ class StreamMergeSuite extends Fs2Suite {
}
}
}

test("mergePreferred prefers") {
forAllF { (leftStream: Stream[Pure, Int], rightStream: Stream[Pure, Int]) =>
val leftTagged = leftStream.covary[IO]
val rightTagged = rightStream.covary[IO].delayBy(10.milli)
leftTagged
.mergePreferred(rightTagged)
.assertEmitsSameAs(leftStream ++ rightStream)
}
}

test("mergePreferred fully consumes this") {
forAllF { (stream: Stream[Pure, Int]) =>
stream.covary[IO].mergePreferred(Stream.empty.covary[IO]).assertEmitsSameAs(stream)
}
}

test("mergePreferred fully consumes that") {
forAllF { (stream: Stream[Pure, Int]) =>
Stream.empty.covary[IO].mergePreferred(stream.covary[IO]).assertEmitsSameAs(stream)
}
}

test("mergePreferred fully consumes both") {
forAllF { (leftStream: Stream[Pure, Int], rightStream: Stream[Pure, Int]) =>
val leftTagged = leftStream.covary[IO]
val rightTagged = rightStream.covary[IO]
leftTagged
.mergePreferred(rightTagged)
.assertEmitsUnorderedSameAs(leftStream ++ rightStream)
}
}

}

0 comments on commit f155c51

Please sign in to comment.