File: test-helpers-where.R

package info (click to toggle)
r-cran-tidyselect 1.2.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 616 kB
  • sloc: sh: 13; makefile: 2
file content (16 lines) | stat: -rw-r--r-- 441 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
test_that("where() selects with a predicate", {
  expect_identical(select_loc(iris, where(is.factor)), c(Species = 5L))
  expect_identical(select_loc(iris, where(~ is.factor(.x))), c(Species = 5L))
})

test_that("where() checks return values", {
  expect_snapshot(error = TRUE, {
    where(NA)
  })

  expect_snapshot(error = TRUE, {
    select_loc(iris, where(~NA))
    select_loc(iris, where(~1))
    select_loc(iris, where(mean))
  })
})