inst/testme/test-codetools-bug16.R

library(globals)

message("*** codetools::findGlobals() bug #16 ...")

exprs <- list(
 A = quote(x %% `$<-`("abc", 42)),
 B = quote(function() x %% `$<-`("abc", 42))
)

for (name in names(exprs)) {
  expr <- exprs[[name]]
  print(expr)
  globals <- globals::findGlobals(expr)
  print(globals)
  
  diffA <- setdiff(c("%%", "x", "$<-"), globals)
  print(diffA)
  stopifnot(length(diffA) == 0)
  
  diffB <- setdiff(globals, c("%%", "x", "$<-"))
  print(diffB)
  stopifnot(length(diffB) == 0)
}

message("*** codetools::findGlobals() bug #16 ... done")

Try the globals package in your browser

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

globals documentation built on June 8, 2025, 12:48 p.m.