Skip to content

Commit faa843b

Browse files
committed
fix: use newlines in code parseing on multiline expression with within
1 parent c668d98 commit faa843b

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

R/qenv-eval_code.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ setMethod("eval_code", signature = c("qenv", "character"), function(object, code
8888
})
8989

9090
setMethod("eval_code", signature = c("qenv", "language"), function(object, code) {
91-
eval_code(object, code = paste(vapply(lang2calls(code), deparse1, character(1)), collapse = "\n"))
91+
eval_code(object, code = paste(vapply(lang2calls(code), deparse1, collapse = "\n", character(1L)), collapse = "\n"))
9292
})
9393

9494
setMethod("eval_code", signature = c("qenv", "expression"), function(object, code) {
95-
eval_code(object, code = paste(vapply(lang2calls(code), deparse1, character(1)), collapse = "\n"))
95+
eval_code(object, code = paste(vapply(lang2calls(code), deparse1, collapse = "\n", character(1L)), collapse = "\n"))
9696
})
9797

9898
setMethod("eval_code", signature = c("qenv.error", "ANY"), function(object, code) {

tests/testthat/test-qenv_join.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ testthat::test_that("Joined qenv does not duplicate common code", {
3636
q2 <- eval_code(q2, quote(mtcars2 <- mtcars))
3737

3838
testthat::expect_true(.check_joinable(q1, q2))
39-
q <- join(q1, q2)
39+
q <- c(q1, q2)
4040

4141
testthat::expect_identical(
4242
q@code,

tests/testthat/test-qenv_within.R

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ testthat::test_that("simple and compound expressions are evaluated", {
1414
)
1515
})
1616

17+
testthat::test_that("multiline expressions are evaluated", {
18+
q <- qenv()
19+
testthat::expect_no_error(
20+
within(q, a <- function(x) {
21+
y <- x + 1
22+
y + 3
23+
})
24+
)
25+
})
26+
1727
# code identity ----
1828
testthat::test_that("styling of input code does not impact evaluation results", {
1929
q <- qenv()
@@ -114,5 +124,3 @@ testthat::test_that("within run on qenv.error returns the qenv.error as is", {
114124

115125
testthat::expect_identical(qe, qee)
116126
})
117-
118-
})

0 commit comments

Comments
 (0)