Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

S3method("[[",qenv.error)
S3method(within,qenv)
S3method(within,qenv.error)
export(concat)
export(dev_suppress)
export(eval_code)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

* Exported the `qenv` class from the package.
* The `@code` field in the `qenv` class now holds `character`, not `expression`.
* Added `within` support for `qenv.error` class.

# teal.code 0.4.1

Expand Down
8 changes: 8 additions & 0 deletions R/qenv-within.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,11 @@ within.qenv <- function(data, expr, ...) {

eval_code(object = data, code = as.expression(calls))
}


#' @keywords internal
#'
#' @export
within.qenv.error <- function(data, expr, ...) {
data
}
9 changes: 9 additions & 0 deletions tests/testthat/test-qenv-within.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,12 @@ testthat::test_that("external values are not taken from calling frame", {

# nolint end
# styler: on

testthat::test_that("within run on qenv.error returns the qenv.error as is", {
q <- qenv()
q <- within(q, i <- iris)
qe <- within(q, stop("right there"))
qee <- within(qe, m <- mtcars)

testthat::expect_identical(qe, qee)
})