Przeglądaj źródła

Refactor get_quos_name() and add tests for tidyr_helpers

pull/18/merge
Garrick Aden-Buie 7 lat temu
rodzic
commit
caa9188b69
2 zmienionych plików z 9 dodań i 2 usunięć
  1. +2
    -2
      R/tidyr_helpers.R
  2. +7
    -0
      tests/testthat/test-tidyr_helpers.R

+ 2
- 2
R/tidyr_helpers.R Wyświetl plik

@@ -12,8 +12,8 @@
#' get_quos_names(-x)
#' get_quos_names(x:y)
get_quos_names <- function(...) {
q <- quos(...)
sapply(q, function(i) as.character(i[[2]]))
q <- rlang::quos(...)
purrr::map_chr(q, rlang::quo_name)
}

#' Parses a simple vector so that it looks like its input

+ 7
- 0
tests/testthat/test-tidyr_helpers.R Wyświetl plik

@@ -0,0 +1,7 @@
context("test-tidyr_helpers")

test_that("get_quos_names works", {
expect_equivalent(get_quos_names(-x), "-x")
expect_equivalent(get_quos_names(x:y), "x:y")
expect_equivalent(get_quos_names(-x, -y, -z), c("-x", "-y", "-z"))
})

Ładowanie…
Anuluj
Zapisz