Skip to content

Commit

Permalink
Only print first S4 class
Browse files Browse the repository at this point in the history
When used in list-columns, S4 objects only print the class name than the full class hierarchy. Fixes #33.
  • Loading branch information
hadley committed Mar 17, 2016
1 parent 905c4c7 commit 6cfb350
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/utils-format.r
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ obj_type.default <- function(x) {
} else if (!isS4(x)) {
paste0("<S3:", paste0(class(x), collapse = ", "), ">")
} else {
paste0("<S4:", paste0(methods::is(x), collapse = ", "), ">")
paste0("<S4:", paste0(methods::is(x)[[1]], collapse = ", "), ">")
}
}

Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-trunc-mat.r
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,8 @@ test_that("trunc_mat output matches known output", {
knit_cacheable = TRUE)
)
})

test_that("obj_type shows only first class name for S4", {
A <- methods::setClass("A")
expect_equal(obj_type(A), "<S4:classGeneratorFunction>")
})

0 comments on commit 6cfb350

Please sign in to comment.