test_that("creates a deferred value", {
do <- function() {
dx <- async_constant()
expect_true(is_deferred(dx))
dx
}
synchronise(do())
do <- function() {
dx <- async_constant("foobar")
expect_true(is_deferred(dx))
dx
}
synchronise(do())
})
test_that("resolves to the specified value", {
do <- function() {
async_constant("foobar")$
then(function(x) expect_equal(x, "foobar"))
}
synchronise(do())
do <- function() {
async_constant()$
then(function(x) expect_null(x))
}
synchronise(do())
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.