Debian Codegraph @

tests/capableOfProfmem.R

raw
1 truth <- capabilities("profmem")
2 print(truth)
3
4 cache <- profmem:::capableOfProfmem()
5 print(cache)
6 stopifnot(identical(cache, truth))
7
8 cache <- profmem:::capableOfProfmem()
9 print(cache)
10 stopifnot(identical(cache, truth))
11
12 ## Fake calling profmem() when memory profiling is disabled
13 ## and assert that profmem() throws an error
14 f <- profmem:::capableOfProfmem
15 environment(f)$res <- FALSE
16 t <- profmem:::capableOfProfmem()
17 print(t)
18 stopifnot(identical(t, FALSE))
19 res <- tryCatch({
20 p <- profmem::profmem(x <- 1:1000)
21 }, error = identity)
22 stopifnot(inherits(res, "simpleError"))
23 environment(f)$res <- cache ## Undo
24
25
26