/usr/lib/R/site-library/Biobase/unitTests/test_cache.R is in r-bioc-biobase 2.34.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | test_cache_basic <- function() {
pre <- "tmp_R_TEST_"
cfile <- file.path(tempdir(), paste(pre, "theVar.RData", sep=""))
on.exit(file.remove(cfile), add=TRUE)
expensive <- function(n) n + 1
cache(theVar <- expensive(5), dir=tempdir(), prefix=pre)
checkEquals(6, theVar)
checkTrue(file.exists(cfile))
## call again
remove(theVar)
cache(theVar <- expensive(5), dir=tempdir(), prefix=pre)
checkEquals(6, theVar)
}
test_cache_infunc <- function() {
pre <- "tmp_R_TEST_"
cfile <- file.path(tempdir(), paste(pre, "theVar.RData", sep=""))
on.exit(file.remove(cfile), add=TRUE)
expensive <- function(n) n + 1
aFunc <- function() {
m <- 1
cache(theVar <- expensive(m), dir=tempdir(), prefix=pre)
theVar
}
val <- aFunc()
checkEquals(2, val)
checkTrue(file.exists(cfile))
## call again
remove(val)
val <- aFunc()
checkEquals(2, val)
}
|