From 2fbe7acfceebd5c5ee3830ddb689701f0a73e2fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Thu, 11 Jan 2024 18:51:25 +0100 Subject: [PATCH] Prefer compact() --- R/tweaks.R | 2 +- R/utils.R | 5 ----- tests/testthat/test-consistency.R | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/R/tweaks.R b/R/tweaks.R index fee0308cc..e6aad6050 100644 --- a/R/tweaks.R +++ b/R/tweaks.R @@ -145,7 +145,7 @@ make_tweaks <- function(envir = parent.frame()) { } } ret <- .(list_call) - ret <- ret[!vapply(ret, is.null, logical(1L))] + ret <- compact(ret) structure(ret, class = "DBItest_tweaks") }, as.environment(list(list_call = list_call)) diff --git a/R/utils.R b/R/utils.R index 7b4ebc551..385476a05 100644 --- a/R/utils.R +++ b/R/utils.R @@ -68,11 +68,6 @@ random_table_name <- function(n = 10) { paste0("dbit", paste(sample(letters, n, replace = TRUE), collapse = "")) } -compact <- function(x) { - x[!vapply(x, is.null, logical(1L))] -} - - try_silent <- function(code) { tryCatch( code, diff --git a/tests/testthat/test-consistency.R b/tests/testthat/test-consistency.R index 363eec667..c62c3e2f1 100644 --- a/tests/testthat/test-consistency.R +++ b/tests/testthat/test-consistency.R @@ -1,5 +1,5 @@ test_that("no unnamed specs", { - tests <- spec_all[!vapply(spec_all, is.null, logical(1L))] + tests <- compact(spec_all) vicinity <- NULL if (any(names(tests) == "")) { vicinity <- sort(unique(unlist(