Skip to content

Commit

Permalink
dear incremental compiler: why do you hate package objects so much?
Browse files Browse the repository at this point in the history
  • Loading branch information
rmgk committed Dec 13, 2024
1 parent 7b136a1 commit cbe85d5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
6 changes: 1 addition & 5 deletions Modules/Channels/js/src/test/scala/EchoWSTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@ import de.rmgk.delay.{Async, Callback}

import scala.util.{Failure, Success}

def printErrors[T](cb: T => Unit): Callback[T] =
case Success(mb) => cb(mb)
case Failure(ex) => ex.printStackTrace()

class EchoWSTest extends munit.FunSuite {

test("echo") {

val outgoing = WebsocketConnect.connect("wss://echo.websocket.org/.ws").prepare: conn =>
printErrors { msg =>
TestUtil.printErrors { msg =>
println(s"received: ${new String(msg.asArray)}")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ import java.util.concurrent.{Executors, Semaphore}
import scala.concurrent.ExecutionContext
import scala.util.{Failure, Success}

def printErrors[T](cb: T => Unit): Callback[T] =
case Success(mb) => cb(mb)
case Failure(ex) => ex match
case ex: IOException if ex.getCause.isInstanceOf[InterruptedException] =>
case ex: ClosedChannelException =>
case ex => ex.printStackTrace()
import TestUtil.printErrors

trait EchoCommunicationTest[Info](
serverConn: ExecutionContext => (Info, LatentConnection[MessageBuffer]),
Expand Down
20 changes: 20 additions & 0 deletions Modules/Channels/shared/src/test/scala/channels/TestUtil.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package channels

import de.rmgk.delay.Callback

import java.io.IOException
import java.net.{InetAddress, InetSocketAddress, ServerSocket, SocketException}
import java.nio.channels.ClosedChannelException
import java.util.concurrent.{Executors, Semaphore}
import scala.concurrent.ExecutionContext
import scala.util.{Failure, Success}

object TestUtil {

def printErrors[T](cb: T => Unit): Callback[T] =
case Success(mb) => cb(mb)
case Failure(ex) => ex match
case ex: IOException if ex.getCause.isInstanceOf[InterruptedException] =>
case ex: ClosedChannelException =>
case ex => ex.printStackTrace()
}

0 comments on commit cbe85d5

Please sign in to comment.