tests/testthat/test-expect-invisible.R

test_that("basically principles of visibilty hold", {
  expect_success(expect_invisible(x <- 10))
  expect_failure(expect_invisible(x))

  expect_success(expect_visible(x))
  expect_failure(expect_visible(x <- 1))
})

test_that("invisibly returns evaluated value", {
  out <- expect_invisible(expect_invisible(x <- 2 + 2))
  expect_equal(out, 4)

  out <- expect_invisible(expect_visible(2 + 2))
  expect_equal(out, 4)
})

Try the testthat package in your browser

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

testthat documentation built on Jan. 21, 2022, 1:10 a.m.