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