tests/testthat/test-funs-predicates.R

context("funs-predicates")

test_that("all_exprs() creates intersection", {
  expect_identical(all_exprs(am == 1), quo(am == 1))

  quo <- set_env(quo((!!quo(cyl == 2)) & (!!quo(am == 1))), base_env())
  expect_identical(all_exprs(cyl == 2, am == 1), quo)
})

test_that("any_exprs() creates union", {
  expect_identical(any_exprs(am == 1), quo(am == 1))

  quo <- set_env(quo((!!quo(cyl == 2)) | (!!quo(am == 1))), base_env())
  expect_identical(any_exprs(cyl == 2, am == 1), quo)
})

test_that("all_exprs() without expression returns an error", {
  expect_error(
    all_exprs(),
    "At least one expression must be given",
    fixed = TRUE
  )
})

Try the dplyr package in your browser

Any scripts or data that you put into this service are public.

dplyr documentation built on July 4, 2019, 5:08 p.m.