Skip to content

Commit

Permalink
Merge 6aeaccc into 8ad27b9
Browse files Browse the repository at this point in the history
  • Loading branch information
chlebowa authored Dec 14, 2023
2 parents 8ad27b9 + 6aeaccc commit b9eec5d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/qenv-get_var.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ setGeneric("get_var", function(object, var) {

setMethod("get_var", signature = c("qenv", "character"), function(object, var) {
tryCatch(
get(var, envir = object@env),
get(var, envir = object@env, inherits = FALSE),
error = function(e) {
message(conditionMessage(e))
NULL
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-qenv_get_var.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ testthat::test_that("get_var and `[[` return NULL if object not in qenv environm
testthat::expect_null(q[["w"]])
testthat::expect_message(q[["w"]], "object 'w' not found")
})

testthat::test_that("get_var and `[[` only returns objects from qenv, not parent environment(s)", {
q <- qenv()

testthat::expect_null(get_var(q, "iris"))
testthat::expect_null(q[["iris"]])
})

0 comments on commit b9eec5d

Please sign in to comment.