tests/testthat/test-s7-S7_property.R

test_that("S7_property", {
  expect_snapshot({
    # examples from `?S7::new_property`
    slices <- S7::new_property(S7::class_numeric, default = 10)
    construct(slices)
    construct(slices, opts_S7_property("next"))
    now <- S7::new_property(getter = function(self) Sys.time())
    # to avoid changing environment adress issue
    environment(now$getter) <- .GlobalEnv
    construct(now)
    construct(now, opts_S7_property("next"))
  })
})

Try the constructive package in your browser

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

constructive documentation built on Nov. 5, 2025, 7:14 p.m.