Skip to content

Commit

Permalink
Fix compilation on 2.11 and 2.12
Browse files Browse the repository at this point in the history
  • Loading branch information
JD557 committed Aug 18, 2022
1 parent 0f48c7a commit 2112ce7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ trait ImageWriter {
*/
def toByteArray(surface: Surface): Either[String, Array[Byte]] = {
val os = new ByteArrayOutputStream()
storeImage(surface, os).map(_ => os.toByteArray)
storeImage(surface, os).right.map(_ => os.toByteArray)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ object ByteReader {
val buffer = List.newBuilder[Int]
while (bufferedBytes.hasNext && p(bufferedBytes.head)) {
buffer += bufferedBytes.head
bufferedBytes.next
bufferedBytes.next()
}
bufferedBytes -> buffer.result()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ trait ByteWriter[F[_]] {
object ByteWriter {
object LazyListByteWriter extends ByteWriter[LazyList] {
def toOutputStream[E](data: ByteStreamState[E], os: OutputStream): Either[E, Unit] =
data.run(LazyList.empty[Array[Byte]]).map { case (s, _) =>
data.run(LazyList.empty[Array[Byte]]).right.map { case (s, _) =>
s.foreach(bytes => os.write(bytes))
}

Expand All @@ -59,7 +59,7 @@ object ByteWriter {

object IteratorByteWriter extends ByteWriter[Iterator] {
def toOutputStream[E](data: ByteStreamState[E], os: OutputStream): Either[E, Unit] =
data.run(Iterator.empty[Array[Byte]]).map { case (s, _) =>
data.run(Iterator.empty).right.map { case (s, _) =>
s.foreach(bytes => os.write(bytes))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ object ImageWriterSpec extends BasicTestSuite {

def roundtripTest(baseResource: Resource, imageFormat: ImageLoader with ImageWriter) = {
val (oldPixels, newPixels) = (for {
original <- imageFormat.loadImage(baseResource).get
original <- imageFormat.loadImage(baseResource).get.right.toOption
originalPixels = original.getPixels().map(_.toVector)
stored <- imageFormat.toByteArray(original)
loaded <- imageFormat.fromByteArray(stored)
stored <- imageFormat.toByteArray(original).right.toOption
loaded <- imageFormat.fromByteArray(stored).right.toOption
loadedPixels = loaded.getPixels().map(_.toVector)
} yield (originalPixels, loadedPixels)).toOption.get
} yield (originalPixels, loadedPixels)).get

assert(oldPixels == newPixels)
}
Expand Down

0 comments on commit 2112ce7

Please sign in to comment.