tests/testthat/test_printToChar.R

context("printToChar")

test_that("printToChar", {
  if (!interactive()) {
  z = list()
  class(z) = "foo"
  print.foo <<- function(x, ...) catf("bar")
  s = printToChar(z)
  expect_equal(s, "bar")
  print.foo <<- function(x, ...) catf("bar\nblubb")
  s = printToChar(z)
  expect_equal(s, "bar\nblubb")
  }
})

Try the BBmisc package in your browser

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

BBmisc documentation built on Sept. 29, 2022, 5:12 p.m.