All Downloads are FREE. Search and download functionalities are using the official Maven repository.

utest.PlatformShims.scala Maven / Gradle / Ivy

There is a newer version: 0.7.11
Show newest version
package utest

import scala.concurrent.Future
import org.portablescala.reflect.Reflect

/**
 * Platform specific stuff that differs between JVM and JS
 */
object PlatformShims {
  def await[T](f: Future[T]): T = {
    f.value match {
      case Some(v) => v.get
      case None => throw new IllegalStateException(
        "Test that returns Future must be run asynchronously in Scala.js, see TestTreeSeq::runAsync"
      )
    }
  }

  type EnableReflectiveInstantiation =
    org.portablescala.reflect.annotation.EnableReflectiveInstantiation

  def loadModule(name: String, loader: ClassLoader): Any = {
    Reflect
      .lookupLoadableModuleClass(name + "$", loader)
      .getOrElse(throw new ClassNotFoundException(name))
      .loadModule()
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy