tests/testthat/test_latch.R

test_that("latch", {

  testthat::expect_error(latch.e())
  testthat::expect_error(latch.w())

  x <- 1

  testthat::expect_error(latch.e(x))
  testthat::expect_error(latch.w(x))
  testthat::expect_error(latch.e(x, "error"))
  testthat::expect_error(latch.w(x, "warning"))

  le <- latch.e(x, e("Probematic"))
  lw <- latch.w(x, w("Suspicious"))

  testthat::expect_snapshot_output(le)
  testthat::expect_snapshot_output(lw)
  testthat::expect_true(is.e(le))
  testthat::expect_true(is.w(lw))
  testthat::expect_error(resolve(le))
  testthat::expect_warning(resolve(lw))

  unlatch(le)
  unlatch(lw)
})

Try the erratum package in your browser

Any scripts or data that you put into this service are public.

erratum documentation built on Jan. 4, 2022, 1:08 a.m.