Debian Codegraph @

tests/testthat/test-sfl.R

raw
1 test_that("Only string scalars for types", {
2 expect_error(sfl(mad, skim_type = c("1", "2")))
3 })
4
5 test_that("Zero-length sfl's supported", {
6 input <- sfl(skim_type = "numeric")
7 expect_length(input$funs, 0)
8 })
9
10 test_that("The interface for sfl's separates keep and drop functions", {
11 input <- sfl(mad = mad, hist = NULL, skim_type = "test")
12 expect_s3_class(input, "skimr_function_list")
13 expect_length(input, 2)
14 expect_named(input, c("funs", "skim_type"))
15 expect_identical(input$skim_type, "test")
16
17 funs <- input$funs
18 expect_type(funs, "list")
19 expect_named(funs, c("mad", "hist"))
20 })
21
22 test_that("sfl's support dummy names", {
23 input <- sfl(mean = ~ mean(., na.rm = TRUE), skim_type = "test")
24 funs <- input$funs
25 expect_equal(funs$mean, rlang::quo(mean(., na.rm = TRUE)), ignore_attr = "class")
26 })
27
28 test_that("sfl's automatically generate function names", {
29 input <- sfl(mad, hist = NULL, ~ length(.)^2, "var")
30 expect_named(input$funs, c("mad", "hist", "~length(.)^2", '"var"'))
31 })