Skip to content

Commit

Permalink
evaluate formals in fn calling env to fix #85
Browse files Browse the repository at this point in the history
  • Loading branch information
mpadge committed Oct 18, 2023
1 parent a1c6696 commit a721bb1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: autotest
Title: Automatic Package Testing
Version: 0.0.2.201
Version: 0.0.2.202
Authors@R: c(
person("Mark", "Padgham", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2172-5265")),
Expand Down
16 changes: 16 additions & 0 deletions R/function-params.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ get_params <- function (res, i, this_fn) {
pkg_env [[this_fn]] <- tmp_fn
}
pars <- formals (fun = this_fn, envir = pkg_env)

# Eval any formals in function environment:
params_env <- as.environment (params)
parent.env (params_env) <- pkg_env
index <- which (vapply (
pars,
function (i) methods::is (i, "call") && !is.symbol (i),
logical (1)
))
pars [index] <- lapply (pars [index], function (p) {
res <- p
if (methods::is (p, "call") && !is.symbol (p)) {
res <- eval (p, envir = params_env)
}
})

nms <- names (pars)

pars <- clean_final_pars_list (params, pars, nms)
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"codeRepository": "https://github.com/ropensci-review-tools/autotest",
"issueTracker": "https://github.com/ropensci-review-tools/autotest/issues",
"license": "https://spdx.org/licenses/GPL-3.0",
"version": "0.0.2.201",
"version": "0.0.2.202",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
Expand Down

0 comments on commit a721bb1

Please sign in to comment.