tests/testthat/test-s7-S7_class_ref.R

test_that("S7_class_ref", {
  # S7 <= 0.2.2 doesn't use class references
  testthat::skip_on_os("linux")
  skip_if_not_installed("S7")
  skip_if(with_versions(S7 <= "0.2.2"))
  expect_snapshot({
    Dog <- evalq(
      S7::new_class("Dog", properties = list(name = S7::class_character)),
      .GlobalEnv
    )
    # check = FALSE because the check evaluates the code in the test environment
    # where `new_class()` infers the package "constructive"
    construct(Dog(name = "x"), check = FALSE)
    construct(attr(Dog(name = "x"), "_S7_class"), check = FALSE)
    construct(attr(Dog(name = "x"), "_S7_class"), opts_S7_class_ref("next"), check = FALSE)
  })
})

Try the constructive package in your browser

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

constructive documentation built on Oct. 22, 2026, 5:07 p.m.