tests/test_capture.output.R

source("helper/helper.R")

f = get("capture.output", envir = getNamespace("utils"))
expect_same = makeCompareFun(f, backports:::capture.output)

output = function() {
  print("stdout")
  message("stderr")
}
suppressMessages({
  expect_same(output())
})

if (getRversion() >= "3.3.0") {
  suppressMessages({
    expect_same(output(), type = "message")
    expect_same(output(), type = "output")
  })
  expect_same(output(), type = c("message", "output"))
}

Try the backports package in your browser

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

backports documentation built on June 24, 2024, 5:24 p.m.