Skip to content

Commit 314a829

Browse files
committed
- simplify Reduce call
- fix R CMD check
1 parent 90f181e commit 314a829

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

R/qenv-eval_code.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ setMethod("eval_code", signature = c("qenv", "expression"), function(object, cod
103103
if (length(srcref)) {
104104
eval_code(object, code = paste(attr(code, "wholeSrcref"), collapse = "\n"))
105105
} else {
106-
Reduce(function(object, x) eval_code(object, x), init = object, x = code)
106+
Reduce(eval_code, init = object, x = code)
107107
}
108108
})
109109

tests/testthat/test-qenv_eval_code.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ testthat::test_that("eval_code works with expression", {
4343
q1 <- eval_code(qenv(), expression(a <- 1, b <- 2))
4444
testthat::expect_identical(get_code(q1), "a <- 1\nb <- 2")
4545
testthat::expect_equal(q1, list2env(list(a = 1, b = 2)))
46+
})
47+
4648
testthat::test_that("eval_code preserves original formatting when `srcref` is present in the expression", {
4749
code <- "# comment
4850
a <- 1L"

0 commit comments

Comments
 (0)