From 6ea8980f28032346ea6778ac47791cd9a6dd4983 Mon Sep 17 00:00:00 2001 From: olivroy Date: Wed, 14 Feb 2024 11:17:12 -0500 Subject: [PATCH] R7 was renamed to S7 --- R/standalone-obj-type.R | 11 +++++++---- tests/testthat/test-standalone-obj-type.R | 6 +++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/R/standalone-obj-type.R b/R/standalone-obj-type.R index 106accce7..ab45a37b7 100644 --- a/R/standalone-obj-type.R +++ b/R/standalone-obj-type.R @@ -1,13 +1,16 @@ # --- # repo: r-lib/rlang # file: standalone-obj-type.R -# last-updated: 2023-05-01 +# last-updated: 2024-02-14 # license: https://unlicense.org # imports: rlang (>= 1.1.0) # --- # # ## Changelog # +# 2024-02-14: +# - `obj_type_friendly()` now works for S7 objects. +# # 2023-05-01: # - `obj_type_friendly()` now only displays the first class of S3 objects. # @@ -263,19 +266,19 @@ vec_type_friendly <- function(x, length = FALSE) { #' Return OO type #' @param x Any R object. #' @return One of `"bare"` (for non-OO objects), `"S3"`, `"S4"`, -#' `"R6"`, or `"R7"`. +#' `"R6"`, or `"S7"`. #' @noRd obj_type_oo <- function(x) { if (!is.object(x)) { return("bare") } - class <- inherits(x, c("R6", "R7_object"), which = TRUE) + class <- inherits(x, c("R6", "S7_object"), which = TRUE) if (class[[1]]) { "R6" } else if (class[[2]]) { - "R7" + "S7" } else if (isS4(x)) { "S4" } else { diff --git a/tests/testthat/test-standalone-obj-type.R b/tests/testthat/test-standalone-obj-type.R index f79bb16ca..a078185f6 100644 --- a/tests/testthat/test-standalone-obj-type.R +++ b/tests/testthat/test-standalone-obj-type.R @@ -16,9 +16,9 @@ test_that("obj_type_oo() works", { r6 <- R6Class("r6")$new() expect_equal(obj_type_oo(r6), "R6") - import_or_skip("R7", "new_class") - r7 <- new_class("r7")() - expect_equal(obj_type_oo(r7), "R7") + import_or_skip("S7", "new_class") + s7 <- new_class("s7")() + expect_equal(obj_type_oo(s7), "S7") }) test_that("stop_input_type() handles I() in `arg` (#1607)", {