tests/testthat/test-utils-glue.R

test_that("glue_chr() returns plain character, evals in correct env", {
  x <- letters[1:2]
  y <- LETTERS[25:26]
  f <- toupper
  expect_identical(glue_chr("{f(x)}-{y}"), c("A-Y", "B-Z"))
})

test_that("glue_data_chr() returns plain character, evals in correct env", {
  z <- list(x = letters[1:2], y = LETTERS[25:26])
  f <- tolower
  x <- 1
  y <- 2
  expect_identical(glue_data_chr(z, "{x}-{f(y)}"), c("a-y", "b-z"))
})

Try the usethis package in your browser

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

usethis documentation built on Sept. 11, 2024, 5:29 p.m.