context("defer")
test_that("defer_parent works", {
local_file <- function(path) {
file.create(path)
defer_parent(unlink(path))
}
# create tempfile path
path <- tempfile()
# use 'local_file' in a function
local({
local_file(path)
stopifnot(file.exists(path))
})
# file is deleted as we leave 'local' scope
expect_false(file.exists(path))
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.