# ---------------------------------------------------------------------------- #
# helper: RC class definition
person_factory <- setRefClass(
"person",
fields = list(
name = "character",
birth_year = "integer"
),
methods = list(
say_hello = function() {
"hello"
}
)
)
# ---------------------------------------------------------------------------- #
test_that("get_rc_fld_vals retrieves fields as they have been set", {
person <- person_factory$new(name = "Hans Rosling", birth_year = 1948L)
actval <- get_rc_fld_vals(person)
expval <- list(name = "Hans Rosling", birth_year = 1948L)
expect_equal(actval, expval)
})
# ---------------------------------------------------------------------------- #
test_that("get_rc_fld_vals retrieves fields and overrides a value", {
person <- person_factory$new(name = "Hans Rosling", birth_year = 1948L)
# set name to Robert Plant, also born 1948 :)
actval <- get_rc_fld_vals(person, list(name = "Robert Plant"))
expval <- list(name = "Robert Plant", birth_year = 1948L)
expect_equal(actval, expval)
})
# ---------------------------------------------------------------------------- #
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.