tests/testthat/test-function_locals.R

test_that("function_locals works", {
  f <- function(w = 1, x = 2) {
    y <- 3
    z <- 4
    return(function_locals())
  }
  # browser()
  ret <- f()
  expect_equal(ret, list(y = 3, z = 4)[names(ret)])

  f <- function(w = 1, x = 2) {
    y <- 3
    z <- 4
    return(function_locals(strip_function_args=FALSE))
  }
  ret <- f()
  expect_equal(ret, list(w = 1, x = 2, y = 3, z = 4)[names(ret)])
})

Try the toscutil package in your browser

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

toscutil documentation built on June 28, 2024, 5:06 p.m.