tests/testthat/test-print.R

test_that(desc = "print doesn't change global options and returns object invisibly", code = {
  withr::local_options(list(tibble.width = 5))

  old_option <- getOption("tibble.width")
  old_tbl <- contingency_table(mtcars, am)

  capture.output({
    new_tbl <- print(old_tbl)
  })
  new_option <- getOption("tibble.width")

  expect_identical(new_option, old_option)
  expect_identical(new_tbl, old_tbl)
})

Try the statsExpressions package in your browser

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

statsExpressions documentation built on Aug. 24, 2026, 5:13 p.m.