tests/async/test-timeout.R

test_that("timed out", {
  skip_on_cran()
  f <- function() delay(1/10)$then(function(value) "OK")
  expect_error(synchronise(async_timeout(f, 1/1000)), "Aync operation timed out")
})

test_that("did not time out", {
  skip_on_cran()
  f <- function() delay(1/100)$then(function(value) "OK")
  expect_equal(synchronise(async_timeout(f, 1/10)), "OK")
})

test_that("error before async_timeout", {
  skip_on_cran()
  f <- function() delay(1/1000)$then(function(value) stop("oops"))
  expect_error(synchronise(async_timeout(f, 1/10)), "oops")
})

test_that("error after async_timeout", {
  skip_on_cran()
  f <- function() delay(1/10)$then(function(value) stop("oops"))
  expect_error(synchronise(async_timeout(f, 1/1000)), "Aync operation timed out")
})

Try the pkgcache package in your browser

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

pkgcache documentation built on July 26, 2023, 5:44 p.m.