tests/testthat/test-use_method.R

test_that("bandicoot::use_method() can attach the function to the target environment", {
  e <- new.env()
  e$..type.. <- "test"
  e$..instantiated.. <- FALSE
  bandicoot::register_method(e, a = function() return(self))

  expect_equal(environment(bandicoot::use_method(e, BASE$..str..)), e$..method_env..)
})

test_that("bandicoot::use_method() can run the function in the target environment", {
  e <- new.env()
  e$..type.. <- "test"
  e$..instantiated.. <- FALSE
  bandicoot::register_method(e, a = function() return(self))

  expect_equal(bandicoot::use_method(e, BASE$..str..)(), "<test class>")
})

Try the bandicoot package in your browser

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

bandicoot documentation built on May 29, 2024, 8:01 a.m.