Debian Codegraph @

tests/exceptions.R

raw
1 library("profmem")
2
3 profmem_stack <- profmem:::profmem_stack
4
5 ## In case there are active profmem session in the current R session
6 ## (shouldn't happen during 'R CMD check' though)
7 while (profmem_stack("depth") > 0) profmem_stack("pop")
8
9 ## Trying to pop from empty stack
10 res <- tryCatch({
11 p <- profmem_stack("pop")
12 }, error = identity)
13 print(res)
14 stopifnot(inherits(res, "error"))
15
16 ## Trying non-existing stack action
17 res <- tryCatch({
18 p <- profmem_stack("non-existing")
19 }, error = identity)
20 print(res)
21 stopifnot(inherits(res, "error"))
22
23
24 if (capabilities("profmem")) {
25
26 ## Trying to end existing profmem session
27 res <- tryCatch({
28 p <- profmem_end()
29 }, error = identity)
30 print(res)
31 stopifnot(inherits(res, "error"))
32
33 } ## if (capabilities("profmem"))