tests/capableOfProfmem.R

truth <- capabilities("profmem")
print(truth)

cache <- profmem:::capableOfProfmem()
print(cache)
stopifnot(identical(cache, truth))

cache <- profmem:::capableOfProfmem()
print(cache)
stopifnot(identical(cache, truth))

## Fake calling profmem() when memory profiling is disabled
## and assert that profmem() throws an error
f <- profmem:::capableOfProfmem
environment(f)$res <- FALSE
t <- profmem:::capableOfProfmem()
print(t)
stopifnot(identical(t, FALSE))
res <- tryCatch({
  p <- profmem::profmem(x <- 1:1000)
}, error = identity)
stopifnot(inherits(res, "simpleError"))
environment(f)$res <- cache  ## Undo

Try the profmem package in your browser

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

profmem documentation built on Dec. 15, 2020, 5:07 p.m.