tests/testthat/test-replay.R

library(evaluate)

test_that("replay() should work when print() returns visible NULLs", {
  old <- options(prompt = "> ")
  on.exit(options(old), add = TRUE)

  # need to put S3 method in global namespace otherwise it isn't found
  assign("print.FOO_BAR", function(x, ...) NULL, envir = globalenv())
  on.exit(rm(print.FOO_BAR, envir = globalenv()), add = TRUE)

  ret <- evaluate('structure(1, class = "FOO_BAR")')
  expect_snapshot(replay(ret))
})

Try the evaluate package in your browser

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

evaluate documentation built on Nov. 2, 2023, 5:18 p.m.