Explorar el Código

Refactor get_quos_name() and add tests for tidyr_helpers

pull/18/merge
Garrick Aden-Buie hace 7 años
padre
commit
caa9188b69
Se han modificado 2 ficheros con 9 adiciones y 2 borrados
  1. +2
    -2
      R/tidyr_helpers.R
  2. +7
    -0
      tests/testthat/test-tidyr_helpers.R

+ 2
- 2
R/tidyr_helpers.R Ver fichero

@@ -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 Ver fichero

@@ -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"))
})

Cargando…
Cancelar
Guardar