Skip to content

Commit

Permalink
R7 was renamed to S7
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Feb 14, 2024
1 parent 84deb87 commit 6ea8980
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions R/standalone-obj-type.R
Original file line number Diff line number Diff line change
@@ -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.
#
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-standalone-obj-type.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)", {
Expand Down

0 comments on commit 6ea8980

Please sign in to comment.