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)])
})
toscm/toscutil documentation built on Feb. 23, 2025, 2:20 p.m.