tests/testthat/test-pause.R

test_that("pause takes expected time", {
  time <- system.time(pause(0.2))[[3]]
  # system.time is a little inaccurate so allow 10% padding
  expect_lt(abs(time - 0.2) / 0.2, 0.1)
})

test_that("works with integers", {
  expect_no_error(pause(0L))
})

test_that("pause has no srcrefs", {
  expect_equal(attr(pause, "srcref"), NULL)
})

test_that("checks its inputs", {
  expect_snapshot(error = TRUE, {
    pause(c(1, 2))
    pause("a")
  })
})

Try the profvis package in your browser

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

profvis documentation built on Sept. 20, 2024, 5:10 p.m.