packrat/lib/x86_64-w64-mingw32/3.4.3/withr/tests/testthat/test-defer.R

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))
})
UBC-MDS/Karl documentation built on May 22, 2019, 1:53 p.m.