tests/testthat/test-language.R

context("language")

test_that("NULL is a valid language object", {
  expect_true(is_lang(NULL))
})

# coercion ----------------------------------------------------------------

test_that("as_name produces names", {
  expect_equal(as_name("a"), quote(a))
  expect_equal(as_name(quote(a)), quote(a))
  expect_equal(as_name(quote(a())), quote(a))
  expect_equal(as_name(~ a), quote(a))
  expect_equal(as_name(~ a()), quote(a))

  expect_error(as_name(c("a", "b")), "Can not coerce character vector of length > 1")
})

test_that("as_call produces calls", {
  expect_equal(as_call(quote(a)), quote(a()))
  expect_equal(as_call(quote(a())), quote(a()))
  expect_equal(as_call("a()"), quote(a()))
  expect_equal(as_call(~ a()), quote(a()))

  expect_error(as_call(c("a", "b")), "Can not coerce character vector of length > 1")
})

Try the lazyeval package in your browser

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

lazyeval documentation built on May 2, 2019, 2:11 a.m.