Skip to content

Commit 2df511d

Browse files
committed
fix r cmd check
1 parent fcf46ed commit 2df511d

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

R/qenv-get_var.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
#' `r lifecycle::badge("deprecated")`
55
#' Instead of [get_var()] use native \R operators/functions:
66
#' `x[[name]]`, `x$name` or [get()]:
7-
#'
7+
#'
88
#' @param ... function is deprecated.
9+
#' @param x (`qenv`)
10+
#' @param i (`character(1)`) variable name.
911
#'
1012
#' @aliases get_var,qenv-method
1113
#' @aliases get_var,qenv.error-method

man/get_var.Rd

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-qenv_get_var.R

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,39 @@
1-
testthat::test_that("get_var, `$` and `[[` return error if object is qenv.error", {
1+
testthat::test_that("`$` and `[[` return error if object is qenv.error", {
22
q <- eval_code(qenv(), quote(x <- 1))
33
q <- eval_code(q, quote(y <- w * x))
44

5-
testthat::expect_error(get_var(q, "x"), "when evaluating qenv code")
65
testthat::expect_error(q[["x"]], "when evaluating qenv code")
76
testthat::expect_error(q$x, "when evaluating qenv code")
87
})
98

10-
testthat::test_that("get_var, `$` and `[[` return object from qenv environment", {
9+
testthat::test_that("`$` and `[[` return object from qenv environment", {
1110
q <- eval_code(qenv(), quote(x <- 1))
1211
q <- eval_code(q, quote(y <- 5 * x))
1312

14-
lifecycle::expect_deprecated(testthat::expect_equal(get_var(q, "y"), 5))
1513
testthat::expect_equal(q[["x"]], 1)
1614
testthat::expect_equal(q$x, 1)
1715
})
1816

1917

20-
testthat::test_that("get_var, `$` and `[[` return NULL if object not in qenv environment", {
18+
testthat::test_that("`$` and `[[` return NULL if object not in qenv environment", {
2119
q <- eval_code(qenv(), quote(x <- 1))
2220
q <- eval_code(q, quote(y <- 5 * x))
2321

24-
testthat::expect_message(
25-
testthat::expect_null(get_var(q, "z"))
26-
)
2722
testthat::expect_null(q[["w"]])
2823
testthat::expect_null(q$w)
2924
})
3025

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

3429
new_env <- new.env(parent = parent.env(q))
3530
new_env$an_object <- 2
3631

37-
testthat::expect_null(get_var(q, "an_object"))
3832
testthat::expect_null(q[["an_object"]])
3933
testthat::expect_null(q$an_object)
4034
})
4135

42-
testthat::test_that("get_var, `$` and `[[` only returns objects from qenv, not .GlobalEnv", {
36+
testthat::test_that("`$` and `[[` only returns objects from qenv, not .GlobalEnv", {
4337
if (is.null(.GlobalEnv)) {
4438
withr::defer(rm("an_object", envir = .GlobalEnv))
4539
} else {
@@ -49,7 +43,6 @@ testthat::test_that("get_var, `$` and `[[` only returns objects from qenv, not .
4943
.GlobalEnv$an_object <- iris # nolint: object_name.
5044

5145
q <- qenv()
52-
testthat::expect_null(get_var(q, "iris"))
5346
testthat::expect_null(q[["iris"]])
5447
testthat::expect_null(q$iris)
5548
})

0 commit comments

Comments
 (0)