Created
January 10, 2018 14:02
-
-
Save gustavofranke/e62793365280564329edd7f81c9008f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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