tests/testthat/test-dynamic.R

test_that("dynamic variables are cool and good", {

  a <- 0L
  envir <- environment()

  example <- function() {
    dynamic(
      key   = list(),
      value = a <<- a + 1L,
      envir = envir
    )
  }

  local({

    example()
    expect_equal(a, 1L)

    example()
    expect_equal(a, 1L)

  })


})

Try the renv package in your browser

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

renv documentation built on Sept. 19, 2023, 9:06 a.m.