tests/testthat/test-wrap.R

test_that("wrap works", {
  v <- c(0, 0, 0)
  set <- function(x) v[2] <<- x
  f <- wrap(set, v[1] <<- v[1] + 1, v[3] <<- v[3] + 3)
  expect_equal(v, c(0, 0, 0))
  f(2)
  expect_equal(v, 1:3)
})

Try the withr package in your browser

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

withr documentation built on Nov. 2, 2023, 5:24 p.m.