Skip to content

Commit

Permalink
Add unit test for #253
Browse files Browse the repository at this point in the history
  • Loading branch information
zeehio committed Apr 16, 2023
1 parent e6b5eaf commit f951307
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/testthat/test-clone.R
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,28 @@ test_that("Cloning inherited methods for non-portable classes", {
expect_identical(a$x, 3)
})

test_that("Unknown environments are not copied nor $-inspected", {

`$.asdfasdf` <- function(x, value) {
stop("error")
}

bar <- R6Class("bar",
public = list(
x = NULL,
initialize = function() {
x <- new.env(parent = emptyenv())
class(x) <- "asdfasdf"
self$x <- x
x
}
)
)

obj <- bar$new()
obj2 <- obj$clone(deep = TRUE)
expect_equal(obj$x, obj2$x)
})

test_that("Deep cloning", {
AC <- R6Class("AC", public = list(x = 1))
Expand Down

0 comments on commit f951307

Please sign in to comment.