inst/example_packages/exampleGood/tests/testthat/test-r6-example.R

test_that("Example R6 Accumulator class constructor is traced", {
  expect_silent(acc <- Accumulator$new(3L))
  expect_true(acc$sum == 3L)
})

test_that("Example R6 Accumulator class methods are traced", {
  expect_silent(acc <- Accumulator$new(3L))
  expect_true(acc$add(3L)$sum == 6L)
})

test_that("Example R6 Person class public methods are traced", {
  expect_silent(p <- Person$new("Doug"))
  expect_output(p$print())
})

test_that("Example R6 Rando class active field functions are traced", {
  expect_silent(rand <- Rando$new())
  expect_true(is.numeric(rand$random))
})

Try the checked package in your browser

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

checked documentation built on June 10, 2025, 9:08 a.m.