diff --git a/R/table-utils.R b/R/table-utils.R index cfdcd10c..42f35e77 100644 --- a/R/table-utils.R +++ b/R/table-utils.R @@ -113,7 +113,7 @@ require_col <- function(data,col,context=NULL) { gluet <- function(x, .envir = parent.frame(), ...) { x <- force(x) if(!is.environment(.envir)) { - abort("pmtables error: cannot glue into .envir that is not environment") + abort("pmtables error: cannot `glue()` - .envir is not an environment.") } glue(x,.open = "<", .close = ">", .envir = .envir) } diff --git a/tests/testthat/test-table-utils.R b/tests/testthat/test-table-utils.R index 2b20c498..7dcd9824 100644 --- a/tests/testthat/test-table-utils.R +++ b/tests/testthat/test-table-utils.R @@ -278,3 +278,12 @@ test_that("table-utils paste units [PMT-TEST-0239]", { c("B mg", "E", "D kg", "C pounds", "A") ) }) + +test_that("error is generated when calling gluet with non-environment", { + x <- list(a = 1, b = 2, c = 3) + what <- "" + expect_error(pmtables:::gluet(what, .envir = x), "pmtables error:") + env <- as.environment(x) + ans <- pmtables:::gluet(what, .envir = env) + expect_identical(unclass(ans), "213") +})