Skip to content

Commit e9b4b71

Browse files
committed
@llrs-roche review
1 parent 8e9bf13 commit e9b4b71

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tests/testthat/test-qenv_eval_code.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ 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@.xData, list2env(list(a = 1, b = 2)))
46+
testthat::test_that("eval_code preserves original formatting when `srcref` is present in the expression", {
47+
code <- "# comment
48+
a <- 1L"
49+
expr <- parse(text = code, keep.source = TRUE)
50+
q1 <- eval_code(qenv(), expr)
51+
testthat::expect_identical(get_code(q1), code)
52+
testthat::expect_equal(q1, list2env(list(a = 1L)))
4653
})
4754

4855
testthat::test_that("eval_code works with quoted", {

0 commit comments

Comments
 (0)