From c819edc2a023db6214e99018534461e45f771638 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Tue, 5 Nov 2024 16:43:29 -0600 Subject: [PATCH] Make code easier to understnad --- R/expect-setequal.R | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/R/expect-setequal.R b/R/expect-setequal.R index 42b6aa7c0..cfca84654 100644 --- a/R/expect-setequal.R +++ b/R/expect-setequal.R @@ -35,16 +35,16 @@ expect_setequal <- function(object, expected) { warn("expect_setequal() ignores names") } - act_miss <- !act$val %in% exp$val - exp_miss <- !exp$val %in% act$val + act_miss <- setdiff(act$val, exp$val) + exp_miss <- setdiff(exp$val, act$val) - if (any(exp_miss) || any(act_miss)) { + if (length(exp_miss) || length(act_miss)) { fail(paste0( act$lab, " (`actual`) and ", exp$lab, " (`expected`) don't have the same values.\n", - if (any(act_miss)) - paste0("* Only in `actual`: ", values(act$val[act_miss]), "\n"), - if (any(exp_miss)) - paste0("* Only in `expected`: ", values(exp$val[exp_miss]), "\n") + if (length(act_miss)) + paste0("* Only in `actual`: ", values(act_miss), "\n"), + if (length(exp_miss)) + paste0("* Only in `expected`: ", values(exp_miss), "\n") )) } else { succeed()