tests/testthat/test-s3-dots.R

test_that("dots", {
  expect_snapshot({
    # if dots1 and the evaluation env of `...` is in the same env we have
    # infinite recursion issues so we use `local()`
    dots1 <- local((function(...) get("..."))(a=x, y))
    construct(dots1, opts_environment("list2env"))
    construct(structure(dots1, class = "foo"), opts_environment("list2env"))

    f <- function(...) {
      y <- 1
      g(y = y, ...)
    }
    g <- function(...) get("...")
    x <- 1
    dots2 <- local(f(x = x))
    construct(dots2, opts_environment("list2env"))
  })
})

Try the constructive package in your browser

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

constructive documentation built on Sept. 11, 2024, 8:32 p.m.