1
2context("async_constant")
3
4test_that("creates a deferred value", {
5  do <- function() {
6    dx <- async_constant()
7    expect_true(is_deferred(dx))
8    dx
9  }
10  synchronise(do())
11
12  do <- function() {
13    dx <- async_constant("foobar")
14    expect_true(is_deferred(dx))
15    dx
16  }
17  synchronise(do())
18})
19
20test_that("resolves to the specified value", {
21  do <- function() {
22    async_constant("foobar")$
23      then(function(x) expect_equal(x, "foobar"))
24  }
25  synchronise(do())
26
27  do <- function() {
28    async_constant()$
29      then(function(x) expect_null(x))
30  }
31  synchronise(do())
32})
33