Skip to content

Commit 7e1f07a

Browse files
committed
test within(keep_output)
1 parent 3cd6246 commit 7e1f07a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/testthat/test-qenv_within.R

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,17 @@ testthat::test_that("Code executed with integer shorthand (1L) is the same as or
154154
q <- within(qenv(), a <- 1L)
155155
testthat::expect_identical(get_code(q), "a <- 1L")
156156
})
157+
158+
testthat::test_that("keep_output stores the last output of the `code` evaluation in its 'output' attribute", {
159+
q <- within(qenv(),
160+
{
161+
a <- 1L
162+
b <- 2L
163+
c <- 3L
164+
},
165+
keep_output = TRUE
166+
)
167+
testthat::expect_identical(attr(q@code[[1]], "output"), NULL)
168+
testthat::expect_identical(attr(q@code[[2]], "output"), NULL)
169+
testthat::expect_identical(attr(q@code[[3]], "output"), 3L)
170+
})

0 commit comments

Comments
 (0)