tests/testthat/test-utils.R

test_that("body_replace replaces bits of bodies", {
  test_fun <- function(x) {
    x^exp
  }
  body(test_fun) <- body_replace(body(test_fun), quote(exp), quote(!!exp))
  expected_fun <- function(x) {
    x^!!exp
  }
  expect_identical(test_fun, expected_fun)
})

Try the factory package in your browser

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

factory documentation built on Aug. 21, 2019, 9:05 a.m.