New Upstream Snapshot - r-cran-r6
Ready changes
Summary
Merged new upstream version: 2.5.1+git20221028.1.e6b5eaf (was: 2.5.1).
Resulting package
Built on 2022-11-18T09:41 (took 6m57s)
The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:
apt install -t fresh-snapshots r-cran-r6
Lintian Result
Diff
diff --git a/DESCRIPTION b/DESCRIPTION
index ef225db..c941009 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,22 +1,28 @@
Package: R6
Title: Encapsulated Classes with Reference Semantics
-Version: 2.5.1
-Authors@R: person("Winston", "Chang", role = c("aut", "cre"), email = "winston@stdout.org")
-Description: Creates classes with reference semantics, similar to R's built-in
- reference classes. Compared to reference classes, R6 classes are simpler
- and lighter-weight, and they are not built on S4 classes so they do not
- require the methods package. These classes allow public and private
- members, and they support inheritance, even when the classes are defined in
- different packages.
-Depends: R (>= 3.0)
-Suggests: testthat, pryr
+Version: 2.5.1.9000
+Authors@R: c(
+ person("Winston", "Chang", , "winston@stdout.org", role = c("aut", "cre")),
+ person("RStudio", role = c("cph", "fnd"))
+ )
+Description: Creates classes with reference semantics, similar to R's
+ built-in reference classes. Compared to reference classes, R6 classes
+ are simpler and lighter-weight, and they are not built on S4 classes
+ so they do not require the methods package. These classes allow public
+ and private members, and they support inheritance, even when the
+ classes are defined in different packages.
License: MIT + file LICENSE
URL: https://r6.r-lib.org, https://github.com/r-lib/R6/
BugReports: https://github.com/r-lib/R6/issues
-RoxygenNote: 7.1.1
+Depends: R (>= 3.0)
+Suggests: lobstr, testthat (>= 3.0.0)
+Config/Needs/website: tidyverse/tidytemplate, ggplot2, microbenchmark,
+ scales
+Config/testthat/edition: 3
+Encoding: UTF-8
+RoxygenNote: 7.2.1
NeedsCompilation: no
-Packaged: 2021-08-06 20:18:46 UTC; winston
-Author: Winston Chang [aut, cre]
+Packaged: 2022-11-18 09:37:07 UTC; root
+Author: Winston Chang [aut, cre],
+ RStudio [cph, fnd]
Maintainer: Winston Chang <winston@stdout.org>
-Repository: CRAN
-Date/Publication: 2021-08-19 14:00:05 UTC
diff --git a/MD5 b/MD5
deleted file mode 100644
index c783804..0000000
--- a/MD5
+++ /dev/null
@@ -1,33 +0,0 @@
-1822b1884ade0c37ce3184713c8e8a6a *DESCRIPTION
-2491c4039e00be047cce99c452d3fd00 *LICENSE
-2290c691ec0011ac745e45d5874fa193 *NAMESPACE
-57bef973aa14163a545adc21ed2707fc *NEWS.md
-890797fed39cbc35799c315d9c322108 *R/aaa.R
-8fc2b68dd2ba714c478255c42d60fdb5 *R/aslist.R
-facbdd1ef5ec209c49ff8d72863971c5 *R/clone.R
-969da6f631df9a1f7fbdf9531f60b4dc *R/env_utils.R
-bdc3eed04493e6eda7707b085e127963 *R/generator_funs.R
-da8d32330b60debc59dc9ce8a31e877c *R/is.R
-27c3582306223bf21c70f249b68398eb *R/new.R
-31f32ed63aacaf439848ef43dde09add *R/print.R
-143bc629827ea97ed55602c49ea9263a *R/r6_class.R
-b88a321a00815f8fbf23a3eac1790f5d *R/utils.R
-c8050b317ee728b6a42dd3643db7109e *README.md
-d3db5f5dfeb806cd13424eba95b23b0a *man/R6Class.Rd
-1ab85a3b47a7e9757b9e11fe9ab73441 *man/as.list.R6.Rd
-ea0913a482ce1aa926631dd7bb46e330 *man/figures/logo.png
-5f3ac92823b5ad4db8d362c634805c54 *man/figures/logo.svg
-ba0b7a8329fd8be2251946b54e1119f5 *man/is.R6.Rd
-792c2b5c02379e27e3eccbee832b2b28 *tests/manual/README
-a6eb9df5a1cef6cf0b94c958ec25a7a3 *tests/manual/encapsulation.R
-cbaba26cf0c3e5a9004f9a03123028fa *tests/manual/test-inheritance.R
-08d4cdb1a57dc1e4307c6f4c8d83e65e *tests/testthat.R
-45a99007ec8c0255886a2100904c2cae *tests/testthat/helper.R
-9fb5a9f9d2a0be1d6a78b04596de3dc8 *tests/testthat/test-clone.R
-fbdae85d4a8f44fac2227898b2f657b5 *tests/testthat/test-finalizer.R
-890765388a44c68277dcb82c4dbb2141 *tests/testthat/test-nonportable-inheritance.R
-ad3a10994e14247f138f5fa7b0c14bb9 *tests/testthat/test-nonportable.R
-b14ef8fabb29c8e253c5faa8613b069a *tests/testthat/test-portable-inheritance.R
-44f73a7b77858cc4dc7e2f9f13ad041f *tests/testthat/test-portable.R
-d965b9c92c8417097ea262d09d704090 *tests/testthat/test-s3-methods.R
-f2a83c3eb893dde5fb896a58eca12b28 *tests/testthat/test-set.R
diff --git a/NEWS.md b/NEWS.md
index 893156d..9ccfaa5 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,12 @@
+R6 2.5.1.9000
+========
+
+* The deprecated `lock` parameter has been removed.
+
+* `R6Class()` now prints a message when a `finalize` method is public instead of private.
+
+* When a superclass is not cloneable, then subclasses cannot be cloneable (@IndrajeetPatil, #247).
+
R6 2.5.1
========
@@ -111,7 +120,7 @@ R6 2.1.0
R6 2.0.1
========
-* A superclass is validated on object instantation, not on class creation.
+* A superclass is validated on object instantiation, not on class creation.
* Added `debug` and `undebug` methods to generator object.
diff --git a/R/new.R b/R/new.R
index 6b8770c..4c58921 100644
--- a/R/new.R
+++ b/R/new.R
@@ -91,12 +91,10 @@ generator_funs$new <- function(...) {
if (portable) {
# Set up the superclass objects
super_struct <- create_super_env(inherit, public_bind_env,
- private_bind_env, portable = TRUE,
- cloneable = cloneable)
+ private_bind_env, portable = TRUE)
} else {
# Set up the superclass objects
- super_struct <- create_super_env(inherit, public_bind_env, portable = FALSE,
- cloneable = cloneable)
+ super_struct <- create_super_env(inherit, public_bind_env, portable = FALSE)
}
enclos_env$super <- super_struct$bind_env
@@ -105,6 +103,20 @@ generator_funs$new <- function(...) {
public_methods <- merge_vectors(super_struct$public_methods, public_methods)
private_methods <- merge_vectors(super_struct$private_methods, private_methods)
active <- merge_vectors(super_struct$active, active)
+
+ # If `cloneable` property differs between sub and superclass
+ # - super will override sub if super doesn't allow cloning
+ # - sub will override super if super allows cloning
+ if (!identical(cloneable, inherit$cloneable)) {
+ public_methods[["clone"]] <- NULL
+
+ if (!inherit$cloneable) {
+ message(
+ "Superclass ", inherit$classname, " has cloneable=FALSE, but subclass ", classname, " has cloneable=TRUE. ",
+ "A subclass cannot be cloneable when its superclass is not cloneable, so cloning will be disabled for ", classname, "."
+ )
+ }
+ }
}
# Copy objects to public bind environment -------------------------
@@ -201,7 +213,7 @@ encapsulate({
# recursing early on in the function, and then fill the methods downward by
# doing the work for each level and passing the needed information down.
create_super_env <- function(inherit, public_bind_env, private_bind_env = NULL,
- portable = TRUE, cloneable = TRUE) {
+ portable = TRUE) {
public_methods <- inherit$public_methods
private_methods <- inherit$private_methods
active <- inherit$active
@@ -247,7 +259,7 @@ encapsulate({
inherit_inherit <- inherit$get_inherit()
if (!is.null(inherit_inherit)) {
super_struct <- create_super_env(inherit_inherit, public_bind_env,
- private_bind_env, portable, cloneable)
+ private_bind_env, portable)
super_enclos_env$super <- super_struct$bind_env
# Merge this level's methods over the superclass methods
diff --git a/R/r6_class.R b/R/r6_class.R
index bf85738..5aaf8f7 100644
--- a/R/r6_class.R
+++ b/R/r6_class.R
@@ -122,7 +122,6 @@
#' and change the locked state of the class.
#' @param cloneable If \code{TRUE} (the default), the generated objects will
#' have method named \code{$clone}, which makes a copy of the object.
-#' @param lock Deprecated as of version 2.1; use \code{lock_class} instead.
#' @examples
#' # A queue ---------------------------------------------------------
#' Queue <- R6Class("Queue",
@@ -470,7 +469,7 @@ R6Class <- encapsulate(function(classname = NULL, public = list(),
inherit = NULL, lock_objects = TRUE,
class = TRUE, portable = TRUE,
lock_class = FALSE, cloneable = TRUE,
- parent_env = parent.frame(), lock) {
+ parent_env = parent.frame()) {
if (!all_named(public) || !all_named(private) || !all_named(active))
stop("All elements of public, private, and active must be named.")
@@ -492,14 +491,6 @@ R6Class <- encapsulate(function(classname = NULL, public = list(),
if (length(get_nonfunctions(active)) != 0)
stop("All items in active must be functions.")
- if (!missing(lock)) {
- message(paste0(
- "R6Class ", classname, ": 'lock' argument has been renamed to 'lock_objects' as of version 2.1.",
- "This code will continue to work, but the 'lock' option will be removed in a later version of R6"
- ))
- lock_objects <- lock
- }
-
# Create the generator object, which is an environment
generator <- new.env(parent = capsule)
@@ -538,5 +529,15 @@ R6Class <- encapsulate(function(classname = NULL, public = list(),
attr(generator, "name") <- paste0(classname, "_generator")
class(generator) <- "R6ClassGenerator"
+ # Print message; in a future version, this will be upgraded to a warning.
+ if ("finalize" %in% names(generator$public_methods)) {
+ message(
+ "R6Class ", classname,
+ ": finalize() method is public, but it should be private as of R6 2.4.0. ",
+ "This code will continue to work, but in a future version of R6, ",
+ "finalize() will be required to be private."
+ )
+ }
+
generator
})
diff --git a/README.md b/README.md
index db14c62..b29a9c3 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,11 @@
-R6: Encapsulated object-oriented programming for R <img src='man/figures/logo.png' align="right" height="138.5" />
+R6: Encapsulated object-oriented programming for R <img src='man/figures/logo.png' align="right" width="120" />
==================================================
- <!-- badges: start -->
- [![R-CMD-check](https://github.com/r-lib/R6/workflows/R-CMD-check/badge.svg)](https://github.com/r-lib/R6/actions)
- <!-- badges: end -->
+<!-- badges: start -->
+[![R-CMD-check](https://github.com/r-lib/R6/workflows/R-CMD-check/badge.svg)](https://github.com/r-lib/R6/actions)
+<!-- badges: end -->
-R6 is an implemention of encapsulated object-oriented programming for R, and is a simpler, faster, lighter-weight alternative to R's built-in reference classes. This style of programming is also sometimes referred to as classical object-oriented programming.
+R6 is an implementation of encapsulated object-oriented programming for R, and is a simpler, faster, lighter-weight alternative to R's built-in reference classes. This style of programming is also sometimes referred to as classical object-oriented programming.
Some features of R6:
diff --git a/debian/changelog b/debian/changelog
index a37cceb..a285acc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+r-cran-r6 (2.5.1+git20221028.1.e6b5eaf-1) UNRELEASED; urgency=low
+
+ * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk> Fri, 18 Nov 2022 09:37:20 -0000
+
r-cran-r6 (2.5.1-1) unstable; urgency=medium
* New upstream version 2.5.1
diff --git a/man/R6Class.Rd b/man/R6Class.Rd
index 0cdeef4..7921e08 100644
--- a/man/R6Class.Rd
+++ b/man/R6Class.Rd
@@ -16,8 +16,7 @@ R6Class(
portable = TRUE,
lock_class = FALSE,
cloneable = TRUE,
- parent_env = parent.frame(),
- lock
+ parent_env = parent.frame()
)
}
\arguments{
@@ -59,8 +58,6 @@ have method named \code{$clone}, which makes a copy of the object.}
\item{parent_env}{An environment to use as the parent of newly-created
objects.}
-
-\item{lock}{Deprecated as of version 2.1; use \code{lock_class} instead.}
}
\description{
R6 objects are essentially environments, structured in a way that makes them
diff --git a/tests/manual/encapsulation.R b/tests/manual/encapsulation.R
index e5bfe6f..bc72c21 100644
--- a/tests/manual/encapsulation.R
+++ b/tests/manual/encapsulation.R
@@ -1,4 +1,4 @@
-library(pryr)
+library(lobstr)
library(testthat)
library(inline)
diff --git a/tests/manual/test-inheritance.R b/tests/manual/test-inheritance.R
index 7f18695..e6f0db2 100644
--- a/tests/manual/test-inheritance.R
+++ b/tests/manual/test-inheritance.R
@@ -1,5 +1,4 @@
library(testthat)
-context("Inheritance across packages")
## Helper functions to create a new package, with some
## R code, and install it temporarily
diff --git a/tests/testthat/test-aslist.R b/tests/testthat/test-aslist.R
new file mode 100644
index 0000000..d7d943d
--- /dev/null
+++ b/tests/testthat/test-aslist.R
@@ -0,0 +1,28 @@
+test_that("list of public members is generated as expected by as.list.R6 method", {
+ Person <- R6Class("Person",
+ public = list(
+ name = NULL,
+ hair = NULL,
+ initialize = function(name = NA, hair = NA) {
+ self$name <- name
+ self$hair <- hair
+ },
+ set_hair = function(val) {
+ self$hair <- val
+ }
+ )
+ )
+
+ ann <- Person$new("Ann", "black")
+
+ annList <- as.list(ann)
+
+ expect_type(annList, "list")
+ expect_equal(
+ names(annList),
+ c(".__enclos_env__", "hair", "name", "clone", "set_hair", "initialize")
+ )
+
+ expect_equal(annList$hair, ann$hair)
+ expect_equal(annList$name, ann$name)
+})
diff --git a/tests/testthat/test-clone.R b/tests/testthat/test-clone.R
index 5051e98..268a8f2 100644
--- a/tests/testthat/test-clone.R
+++ b/tests/testthat/test-clone.R
@@ -1,5 +1,3 @@
-context("clone")
-
test_that("Can't use reserved name 'clone'", {
expect_error(R6Class("AC", public = list(clone = function() NULL)))
expect_error(R6Class("AC", private = list(clone = function() NULL)))
diff --git a/tests/testthat/test-cloning-inheritance.R b/tests/testthat/test-cloning-inheritance.R
new file mode 100644
index 0000000..11e7b60
--- /dev/null
+++ b/tests/testthat/test-cloning-inheritance.R
@@ -0,0 +1,30 @@
+test_that("Subclass can override superclass' cloneable property", {
+ # superclass cloneable ---------------------
+
+ Creature <- R6Class("Creature", cloneable = TRUE)
+
+ Sheep <- R6Class("Sheep", inherit = Creature, cloneable = TRUE)
+ expect_message(sheep <- Sheep$new(), NA)
+ expect_s3_class(sheep$clone(), "Sheep")
+ expect_true("clone" %in% names(Creature$public_methods))
+
+ Human <- R6Class("Human", inherit = Creature, cloneable = FALSE)
+ expect_message(human <- Human$new(), NA)
+ expect_error(human$clone(), "attempt to apply non-function")
+ expect_true("clone" %in% names(Creature$public_methods))
+
+ # superclass non-cloneable ---------------------
+
+ Creature <- R6Class("Creature", cloneable = FALSE)
+
+ Sheep <- R6Class("Sheep", inherit = Creature, cloneable = TRUE)
+ expect_message(sheep <- Sheep$new(), "Superclass Creature has cloneable=FALSE, but subclass Sheep has cloneable=TRUE.")
+ expect_error(sheep$clone(), "attempt to apply non-function")
+ # Make sure that the superclass wasn't inadvertantly modified.
+ expect_false("clone" %in% names(Creature$public_methods))
+
+ Human <- R6Class("Human", inherit = Creature, cloneable = FALSE)
+ expect_message(human <- Human$new(), NA)
+ expect_error(human$clone(), "attempt to apply non-function")
+ expect_false("clone" %in% names(Creature$public_methods))
+})
diff --git a/tests/testthat/test-finalizer.R b/tests/testthat/test-finalizer.R
index bd4fcad..39484f6 100644
--- a/tests/testthat/test-finalizer.R
+++ b/tests/testthat/test-finalizer.R
@@ -1,11 +1,8 @@
-context("finalizer")
-
-
test_that("Finalizers are called, portable", {
parenv <- new.env()
parenv$peekaboo <- FALSE
AC <- R6Class("AC",
- public = list(finalize = function() peekaboo <<- TRUE),
+ private = list(finalize = function() peekaboo <<- TRUE),
portable = TRUE,
parent_env = parenv
)
@@ -20,7 +17,7 @@ test_that("Finalizers are called, non-portable", {
parenv <- new.env()
parenv$peekaboo <- FALSE
AC <- R6Class("AC",
- public = list(finalize = function() peekaboo <<- TRUE),
+ private = list(finalize = function() peekaboo <<- TRUE),
portable = FALSE,
parent_env = parenv
)
@@ -37,10 +34,10 @@ test_that("Finalizers have the right environment, portable", {
AC <- R6Class(
"AC",
public = list(
- finalize = function() { pub <<- self$mypub; priv <<- private$mypriv },
mypub = TRUE
),
private = list(
+ finalize = function() { pub <<- self$mypub; priv <<- private$mypriv },
mypriv = TRUE
),
portable = TRUE,
@@ -60,10 +57,10 @@ test_that("Finalizers have the right environment, non-portable #1", {
AC <- R6Class(
"AC",
public = list(
- finalize = function() { pub <<- self$mypub; priv <<- private$mypriv },
mypub = TRUE
),
private = list(
+ finalize = function() { pub <<- self$mypub; priv <<- private$mypriv },
mypriv = TRUE
),
portable = FALSE,
@@ -83,10 +80,10 @@ test_that("Finalizers have the right environment, non-portable #2", {
AC <- R6Class(
"AC",
public = list(
- finalize = function() { pub <<- mypub; priv <<- mypriv },
mypub = TRUE
),
private = list(
+ finalize = function() { pub <<- mypub; priv <<- mypriv },
mypriv = TRUE
),
portable = FALSE,
@@ -104,7 +101,7 @@ test_that("Finalizers are inherited, portable", {
AC <- R6Class(
"AC",
- public = list(
+ private = list(
finalize = function() print("An AC was just deleted")
)
)
@@ -123,7 +120,7 @@ test_that("Children can override finalizers, portable", {
AC <- R6Class(
"AC",
- public = list(
+ private = list(
finalize = function() cat("An AC was just deleted")
)
)
@@ -131,7 +128,7 @@ test_that("Children can override finalizers, portable", {
BC <- R6Class(
"BC",
inherit = AC,
- public = list(
+ private = list(
finalize = function() cat("A BC was just deleted")
)
)
@@ -146,7 +143,7 @@ test_that("Children can call finalizers in the parent, portable", {
AC <- R6Class(
"AC",
- public = list(
+ private = list(
finalize = function() cat("An AC was just deleted\n")
)
)
@@ -154,7 +151,7 @@ test_that("Children can call finalizers in the parent, portable", {
BC <- R6Class(
"BC",
inherit = AC,
- public = list(
+ private = list(
finalize = function() {
super$finalize()
cat("A BC was just deleted\n")
@@ -173,7 +170,7 @@ test_that("Children can call finalizers in the parent, portable", {
test_that("Finalizers and two levels of inheritance, portable", {
AC <- R6Class(
"AC",
- public = list(
+ private = list(
finalize = function() cat("An AC was just deleted\n")
)
)
@@ -181,7 +178,7 @@ test_that("Finalizers and two levels of inheritance, portable", {
BC <- R6Class(
"BC",
inherit = AC,
- public = list(
+ private = list(
finalize = function() {
super$finalize()
cat("A BC was just deleted\n")
@@ -192,7 +189,7 @@ test_that("Finalizers and two levels of inheritance, portable", {
CC <- R6Class(
"CC",
inherit = BC,
- public = list(
+ private = list(
finalize = function() {
super$finalize()
cat("A CC was just deleted\n")
@@ -212,7 +209,7 @@ test_that("Finalizers are inherited, non-portable", {
AC <- R6Class(
"AC",
- public = list(
+ private = list(
finalize = function() print("An AC was just deleted")
),
portable = FALSE
@@ -233,7 +230,7 @@ test_that("Children can override finalizers, non-portable", {
AC <- R6Class(
"AC",
- public = list(
+ private = list(
finalize = function() cat("An AC was just deleted")
),
portable = FALSE
@@ -242,7 +239,7 @@ test_that("Children can override finalizers, non-portable", {
BC <- R6Class(
"BC",
inherit = AC,
- public = list(
+ private = list(
finalize = function() cat("A BC was just deleted")
),
portable = FALSE
@@ -258,7 +255,7 @@ test_that("Children can call finalizers in the parent, non-portable", {
AC <- R6Class(
"AC",
- public = list(
+ private = list(
finalize = function() cat("An AC was just deleted\n")
),
portable = FALSE
@@ -267,7 +264,7 @@ test_that("Children can call finalizers in the parent, non-portable", {
BC <- R6Class(
"BC",
inherit = AC,
- public = list(
+ private = list(
finalize = function() {
super$finalize()
cat("A BC was just deleted\n")
@@ -287,7 +284,7 @@ test_that("Children can call finalizers in the parent, non-portable", {
test_that("Finalizers and two levels of inheritance, portable", {
AC <- R6Class(
"AC",
- public = list(
+ private = list(
finalize = function() cat("An AC was just deleted\n")
)
)
@@ -295,7 +292,7 @@ test_that("Finalizers and two levels of inheritance, portable", {
BC <- R6Class(
"BC",
inherit = AC,
- public = list(
+ private = list(
finalize = function() {
super$finalize()
cat("A BC was just deleted\n")
@@ -306,7 +303,7 @@ test_that("Finalizers and two levels of inheritance, portable", {
CC <- R6Class(
"CC",
inherit = BC,
- public = list(
+ private = list(
finalize = function() {
super$finalize()
cat("A CC was just deleted\n")
@@ -324,7 +321,7 @@ test_that("Finalizers and two levels of inheritance, portable", {
test_that("Finalizers and two levels of inheritance, non-portable", {
AC <- R6Class(
"AC",
- public = list(
+ private = list(
finalize = function() cat("An AC was just deleted\n")
),
portable = FALSE
@@ -333,7 +330,7 @@ test_that("Finalizers and two levels of inheritance, non-portable", {
BC <- R6Class(
"BC",
inherit = AC,
- public = list(
+ private = list(
finalize = function() {
super$finalize()
cat("A BC was just deleted\n")
@@ -345,7 +342,7 @@ test_that("Finalizers and two levels of inheritance, non-portable", {
CC <- R6Class(
"CC",
inherit = BC,
- public = list(
+ private = list(
finalize = function() {
super$finalize()
cat("A CC was just deleted\n")
@@ -370,7 +367,9 @@ test_that("Finalizer method does not prevent GC of objects passed to initialize"
public = list(
initialize = function(x) {
force(x) # Need to eval x
- },
+ }
+ ),
+ private = list(
finalize = function(e) {
a_gc <<- a_gc + 1
}
@@ -418,19 +417,13 @@ test_that("Finalizer method does not prevent GC of objects passed to initialize"
})
-test_that("Private finalizers work", {
- sum <- 0
- C1 <- R6Class("C1",
- public = list(
- x = 1
- ),
- private = list(
- finalize = function() sum <<- sum + self$x
+test_that("Public finalizers emit message", {
+ expect_message(
+ R6Class("C1",
+ public = list(
+ x = 1,
+ finalize = function() NULL
+ )
)
)
-
- a <- C1$new()
- rm(a)
- gc()
- expect_identical(sum, 1)
})
diff --git a/tests/testthat/test-is.R b/tests/testthat/test-is.R
new file mode 100644
index 0000000..18dcb08
--- /dev/null
+++ b/tests/testthat/test-is.R
@@ -0,0 +1,10 @@
+test_that("Checking R6 class objects are recognized correctly by `is.R6()`", {
+ Person <- R6Class("Person")
+ Bob <- Person$new()
+ expect_true(is.R6(Bob))
+})
+
+test_that("Checking R6 class generators are recognized correctly by `is.R6Class()`", {
+ Person <- R6Class("Person")
+ expect_true(is.R6Class(Person))
+})
diff --git a/tests/testthat/test-nonportable-inheritance.R b/tests/testthat/test-nonportable-inheritance.R
index f87ac1f..f6d7a1c 100644
--- a/tests/testthat/test-nonportable-inheritance.R
+++ b/tests/testthat/test-nonportable-inheritance.R
@@ -1,5 +1,3 @@
-context("nonportable-inheritance")
-
test_that("Inheritance", {
AC <- R6Class("AC",
portable = FALSE,
diff --git a/tests/testthat/test-nonportable.R b/tests/testthat/test-nonportable.R
index 82acc70..0408797 100644
--- a/tests/testthat/test-nonportable.R
+++ b/tests/testthat/test-nonportable.R
@@ -1,5 +1,3 @@
-context("nonportable")
-
test_that("initialization", {
AC <- R6Class("AC",
portable = FALSE,
diff --git a/tests/testthat/test-portable-inheritance.R b/tests/testthat/test-portable-inheritance.R
index cab4db5..94abd6b 100644
--- a/tests/testthat/test-portable-inheritance.R
+++ b/tests/testthat/test-portable-inheritance.R
@@ -1,5 +1,3 @@
-context("portable-inheritance")
-
test_that("Inheritance", {
AC <- R6Class("AC",
portable = TRUE,
@@ -392,8 +390,8 @@ test_that("Inheritance is dynamic", {
# BC doesn't contain AC, and it has less stuff in it, so it should be smaller
# than AC.
- if (requireNamespace("pryr", quietly = TRUE)) {
- expect_true(pryr::object_size(BC) < pryr::object_size(AC))
+ if (requireNamespace("lobstr", quietly = TRUE)) {
+ expect_true(lobstr::obj_size(BC) < lobstr::obj_size(AC))
}
})
diff --git a/tests/testthat/test-portable.R b/tests/testthat/test-portable.R
index 97ec0a6..6a14eae 100644
--- a/tests/testthat/test-portable.R
+++ b/tests/testthat/test-portable.R
@@ -1,5 +1,3 @@
-context("portable")
-
test_that("initialization", {
AC <- R6Class("AC",
portable = TRUE,
diff --git a/tests/testthat/test-s3-methods.R b/tests/testthat/test-s3-methods.R
index 89cf1cd..8f20635 100644
--- a/tests/testthat/test-s3-methods.R
+++ b/tests/testthat/test-s3-methods.R
@@ -1,5 +1,3 @@
-context("S3 methods")
-
test_that("`$` and `[[` methods don't interfere with R6 operations", {
# Make sure that these method aren't used anywhere in internal R6 code
`$.AC` <- function(x, name) stop("Attempted to use `$.AC`")
diff --git a/tests/testthat/test-set.R b/tests/testthat/test-set.R
index 2c9c9c0..7f7a0c8 100644
--- a/tests/testthat/test-set.R
+++ b/tests/testthat/test-set.R
@@ -1,5 +1,3 @@
-context("set")
-
test_that("Setting values set values on generator", {
AC <- R6Class("AC",
public = list(
Debdiff
[The following lists of changes regard files as different if they have different names, permissions or owners.]
Files in second set of .debs but not in first
-rw-r--r-- root/root /usr/share/doc/r-cran-r6/tests/testthat/test-aslist.R -rw-r--r-- root/root /usr/share/doc/r-cran-r6/tests/testthat/test-cloning-inheritance.R -rw-r--r-- root/root /usr/share/doc/r-cran-r6/tests/testthat/test-is.R
Control files: lines which differ (wdiff format)
Depends: r-base-core (>= 4.1.3.20220413-2~jan+lint1), 4.2.2.20221110-1), r-api-4.0
Recommends: r-cran-testthat (>= 3.0.0)
Suggests: r-cran-lobstr