tests/testthat/test-gc.R

## rxodeTest(
##   {
##     options(RxODE.unload.unused = TRUE)
##     library(RxODE)
##     library(testthat)
##     context("Garbage collection")
##     test_that("Check garbage collection unloads DLLs", {
##       options(RxODE.unload.unused = TRUE)

##       ode <- RxODE({
##         b <- -1
##         d / dt(X) <- a * X + Y * Z
##         d / dt(Y) <- b * (Y - Z)
##         d / dt(Z) <- -X * Y + c * Y - Z
##       })

##       name <- basename(rxDll(ode))
##       name <- substr(name, 0, nchar(name) - nchar(.Platform$dynlib.ext))

##       expect_false(is.null(getLoadedDLLs()[[name]]))
##       Sys.sleep(0.5)
##       gc()
##       Sys.sleep(0.5)
##       expect_false(is.null(getLoadedDLLs()[[name]]))
##       rm(ode)
##       Sys.sleep(0.5)
##       gc()
##       Sys.sleep(0.5)
##       expect_true(is.null(getLoadedDLLs()[[name]]))

##       options(RxODE.unload.unused = FALSE)
##     })
##     options(RxODE.unload.unused = FALSE)
##   },
##   test = "lvl2"
## )

Try the RxODE package in your browser

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

RxODE documentation built on March 23, 2022, 9:06 a.m.