Skip to content

Commit

Permalink
fix: multiclass assertion with has_class
Browse files Browse the repository at this point in the history
  • Loading branch information
AleKoure committed Dec 5, 2023
1 parent e4c7e38 commit cc48edb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ has_class <- function(..., class){
check_this <- list(...)
parent <- parent.frame()
given_classes <- lapply(check_this, function(name) class(parent$.top_env[[name]]))
all(given_classes %in% class)
all(unlist(given_classes) %in% class)
}


Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,7 @@ test_that("has_class works with verify", {
wt_var <- "wt"
expect_equal(verify(mtcars, has_class(mpg_var, class = "numeric")), mtcars)
expect_equal(mtcars %>% verify(has_class(mpg_var, wt_var, class = "numeric")), mtcars)

time_df = data.frame(time_var = Sys.time())
expect_equal(time_df %>% verify(has_class("time_var", class = c("POSIXct", "POSIXt"))), time_df)
})

0 comments on commit cc48edb

Please sign in to comment.