f = function(n) {
message("hi from f")
if (n > 5) {
stop("n must be <= 5")
}
runif(n)
}
encapsulate("none", f, list(n = 1), .seed = 1)
if (requireNamespace("evaluate", quietly = TRUE)) {
encapsulate("evaluate", f, list(n = 1), .seed = 1)
}
if (requireNamespace("callr", quietly = TRUE)) {
encapsulate("callr", f, list(n = 1), .seed = 1)
}
Run the code above in your browser using DataLab