tests/testthat/test-expr.R

test_that("expr() works as expected", {

  value <- 42
  actual <- expr({
    x <- !!value
  })

  expected <- quote({
    x <- 42
  })

  expect_identical(actual, expected)

})

test_that("expr() also supports expressions", {

  actual <- expr({
    pid <- !!Sys.getpid()
  })

  expected <- substitute({
    pid <- id
  }, list(id = Sys.getpid()))

  expect_identical(actual, expected)

})

test_that("expr() repairs parse trees", {

  a <- TRUE; b <- FALSE
  actual <- expr(!!a + !!b)
  expected <- quote(TRUE + FALSE)
  expect_identical(actual, expected)

})

Try the renv package in your browser

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

renv documentation built on May 29, 2024, 9:21 a.m.