Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/expect-setequal.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ expect_setequal <- function(object, expected) {
act <- quasi_label(enquo(object))
exp <- quasi_label(enquo(expected))

check_vector(object)
check_vector(expected)
check_vector(act$val, error_arg = "object")
check_vector(exp$val, error_arg = "expected")
if (!is.null(names(act$val)) && !is.null(names(exp$val))) {
testthat_warn("expect_setequal() ignores names")
}
Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/_snaps/expect-setequal.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@
Condition
Error in `expect_setequal()`:
! `expected` must be a vector, not a primitive function.
Code
expect_setequal(!!fun, 1)
Condition
Error in `expect_setequal()`:
! `object` must be a vector, not a primitive function.
Code
expect_setequal(1, !!fun)
Condition
Error in `expect_setequal()`:
! `expected` must be a vector, not a primitive function.

# useful message on failure

Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-expect-setequal.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ test_that("warns if both inputs are named", {
})

test_that("checks inputs", {
fun <- sum
expect_snapshot(error = TRUE, {
expect_setequal(sum, 1)
expect_setequal(1, sum)
expect_setequal(!!fun, 1)
expect_setequal(1, !!fun)
})
})

Expand Down
Loading