tests/testthat/helper-examples.R

# Compile one of the files in inst/examples into a fresh environment and
# return that environment. Compiling against Ceres and Eigen is slow, so
# these tests do not run on CRAN.
source_example <- function(file) {
    skip_on_cran()
    skip_if_not_installed("RcppEigen")
    path <- system.file("examples", file, package = "ceres")
    if (!nzchar(path)) stop("example not found: ", file)
    env <- new.env()
    Rcpp::sourceCpp(path, env = env, showOutput = FALSE)
    env
}

Try the ceres package in your browser

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

ceres documentation built on Nov. 28, 2026, 1:07 a.m.