tests/testthat/test-environments.R

test_that("fn(), fn_() create functions in the calling environment, by default", {
  env <- environment()

  f <- fn(x ~ NULL)
  expect_identical(environment(f), env)

  f <- fn_(x ~ NULL)
  expect_identical(environment(f), env)
})

test_that("fn(), fn_() create functions whose environment is ..env", {
  env <- new.env()

  f <- fn(x ~ NULL, ..env = env)
  expect_identical(environment(f), env)

  f <- fn_(x ~ NULL, ..env = env)
  expect_identical(environment(f), env)
})

Try the gestalt package in your browser

Any scripts or data that you put into this service are public.

gestalt documentation built on Aug. 22, 2022, 5:08 p.m.