Skip to content

Instantly share code, notes, and snippets.

@gustavofranke
Created January 10, 2018 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gustavofranke/e62793365280564329edd7f81c9008f9 to your computer and use it in GitHub Desktop.
Save gustavofranke/e62793365280564329edd7f81c9008f9 to your computer and use it in GitHub Desktop.
import org.scalatest.FunSuite
import scala.concurrent.duration._
import scala.concurrent.{Await, Future}
// the following is equivalent to `implicit val ec = ExecutionContext.global`
import scala.concurrent.ExecutionContext.Implicits.global
class FutureFun extends FunSuite {
test("future basics") {
def unWrap[T](x: Future[T]): T = Await.result(x, 5 seconds)
val q: Future[Int] = Future { 5 / 1 }
assert(unWrap(q) == 5)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment