Running 'Globals.R' [155s]
  Running 'cleanup.R' [0s]
  Running 'conservative.R' [155s]
  Running 'dotdotdot.R' [1s]
  Running 'findGlobals.R' [1s]
  Running 'formulas.R' [169s]
  Running 'globalsByName.R' [0s]
  Running 'globalsOf,locals.R' [158s]
  Running 'globalsOf.R' [172s]
  Running 'liberal.R' [173s]
  Running 'utils.R' [0s]
  Running 'walkAST.R' [1s]
  Running 'zzz.R' [0s]
Running the tests in 'tests/Globals.R' failed.
Complete output:
  > source("incl/start.R")
  > 
  > assert_attributes <- function(globals) {
  +   attrs <- attributes(globals)
  +   names <- names(attrs)
  +   stopifnot(
  +     length(attrs) >= 2L,
  +     "class" %in% names,
  +     "where" %in% names,
  +     ## 'where' and 'class' should be the last two (reproducibility)
  +     names[length(names) - 1L] == "where",
  +     names[length(names)     ] == "class",
  +     inherits(globals, "Globals")
  +   )
  +   invisible(TRUE)
  + }
  > 
  > a <- 1
  > b <- 2
  > 
  > message("*** Globals() ...")
  *** Globals() ...
  > 
  > globals0 <- globalsByName(c("a", "rnorm"))
  > 
  > globals <- globals0
  > str(globals)
  List of 2
   $ a    : num 1
   $ rnorm:function (n, mean = 0, sd = 1)  
   - attr(*, "where")=List of 2
    ..$ a    :<environment: R_GlobalEnv> 
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 2L,
  +   length(where) == length(globals),
  +   all(names(globals) == c("a", "rnorm")),
  +   all(names(globals) == names(where))
  + )
  > message("*** Globals() - names ...")
  *** Globals() - names ...
  > 
  > globals <- globals0
  > str(globals)
  List of 2
   $ a    : num 1
   $ rnorm:function (n, mean = 0, sd = 1)  
   - attr(*, "where")=List of 2
    ..$ a    :<environment: R_GlobalEnv> 
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 2L,
  +   length(where) == length(globals),
  +   all(names(globals) == c(names(globals0))),
  +   all(names(globals) == names(where))
  + )
  > 
  > names(globals)[1] <- "A"
  > str(globals)
  List of 2
   $ A    : num 1
   $ rnorm:function (n, mean = 0, sd = 1)  
   - attr(*, "where")=List of 2
    ..$ A    :<environment: R_GlobalEnv> 
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 2L,
  +   length(where) == length(globals),
  +   all(names(globals) == c("A", names(globals0)[-1])),
  +   all(names(globals) == names(where))
  + )
  > 
  > message("*** Globals() - names ... DONE")
  *** Globals() - names ... DONE
  > 
  > message("*** Globals() - subsetting ...")
  *** Globals() - subsetting ...
  > 
  > globals <- globals0[1]
  > str(globals)
  List of 1
   $ a: num 1
   - attr(*, "where")=List of 1
    ..$ a:<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 1L,
  +   length(where) == length(globals),
  +   all(names(globals) == c("a")),
  +   all(names(globals) == names(where))
  + )
  > 
  > globals <- globals0[2]
  > str(globals)
  List of 1
   $ rnorm:function (n, mean = 0, sd = 1)  
   - attr(*, "where")=List of 1
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 1L,
  +   length(where) == length(globals),
  +   all(names(globals) == c("rnorm")),
  +   all(names(globals) == names(where))
  + )
  > 
  > globals <- globals0[2:1]
  > str(globals)
  List of 2
   $ rnorm:function (n, mean = 0, sd = 1)  
   $ a    : num 1
   - attr(*, "where")=List of 2
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
    ..$ a    :<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 2L,
  +   length(where) == length(globals),
  +   all(names(globals) == c("rnorm", "a")),
  +   all(names(globals) == names(where))
  + )
  > 
  > ## rev() works automatically thanks to `[`() :)
  > globals <- rev(globals0)
  > str(globals)
  List of 2
   $ rnorm:function (n, mean = 0, sd = 1)  
   $ a    : num 1
   - attr(*, "where")=List of 2
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
    ..$ a    :<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 2L,
  +   length(where) == length(globals),
  +   all(names(globals) == rev(names(globals0))),
  +   all(names(globals) == names(where)),
  +   identical(rev(globals), globals0)
  + )
  > 
  > message("*** Globals() - subsetting ... DONE")
  *** Globals() - subsetting ... DONE
  > 
  > 
  > message("*** Globals() - subsetted assignment ...")
  *** Globals() - subsetted assignment ...
  > 
  > message("1.")
  1.
  > globals <- globals0
  > globals$a <- globals0["a"]
  > str(globals)
  List of 2
   $ a    : num 1
   $ rnorm:function (n, mean = 0, sd = 1)  
   - attr(*, "where")=List of 2
    ..$ a    :<environment: R_GlobalEnv> 
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 2L,
  +   length(where) == length(globals),
  +   all(names(globals) == names(globals0)),
  +   all(names(globals) == names(where)),
  +   identical(globals, globals0)
  + )
  > 
  > message("2.")
  2.
  > globals <- globals0
  > globals[["a"]] <- globals0["a"]
  > str(globals)
  List of 2
   $ a    : num 1
   $ rnorm:function (n, mean = 0, sd = 1)  
   - attr(*, "where")=List of 2
    ..$ a    :<environment: R_GlobalEnv> 
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 2L,
  +   length(where) == length(globals),
  +   all(names(globals) == names(globals0)),
  +   all(names(globals) == names(where)),
  +   identical(globals, globals0)
  + )
  > 
  > message("3.")
  3.
  > globals <- globals0
  > globals$b <- globals0["a"]
  > str(globals)
  List of 3
   $ a    : num 1
   $ rnorm:function (n, mean = 0, sd = 1)  
   $ b    : num 1
   - attr(*, "where")=List of 3
    ..$ a    :<environment: R_GlobalEnv> 
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
    ..$ b    :<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 3L,
  +   length(where) == length(globals),
  +   all(names(globals) == c(names(globals0), "b")),
  +   all(names(globals) == names(where)),
  +   identical(globals$b, globals0$a)
  + )
  > 
  > message("4.")
  4.
  > globals <- globals0
  > globals[["b"]] <- globals0["a"]
  > str(globals)
  List of 3
   $ a    : num 1
   $ rnorm:function (n, mean = 0, sd = 1)  
   $ b    : num 1
   - attr(*, "where")=List of 3
    ..$ a    :<environment: R_GlobalEnv> 
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
    ..$ b    :<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 3L,
  +   length(where) == length(globals),
  +   all(names(globals) == c(names(globals0), "b")),
  +   all(names(globals) == names(where)),
  +   identical(globals$b, globals0$a)
  + )
  > 
  > message("5.")
  5.
  > globals <- globals0
  > globals["b"] <- globals0["a"]
  > str(globals)
  List of 3
   $ a    : num 1
   $ rnorm:function (n, mean = 0, sd = 1)  
   $ b    : num 1
   - attr(*, "where")=List of 3
    ..$ a    :<environment: R_GlobalEnv> 
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
    ..$ b    :<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 3L,
  +   length(where) == length(globals),
  +   all(names(globals) == c(names(globals0), "b")),
  +   all(names(globals) == names(where)),
  +   identical(globals$b, globals0$a)
  + )
  > 
  > message("6.")
  6.
  > globals <- globals0
  > globals["b"] <- list(globals0[["a"]])
  > str(globals)
  List of 3
   $ a    : num 1
   $ rnorm:function (n, mean = 0, sd = 1)  
   $ b    : num 1
   - attr(*, "where")=List of 3
    ..$ a    :<environment: R_GlobalEnv> 
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
    ..$ b    :<environment: R_EmptyEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 3L,
  +   length(where) == length(globals),
  +   all(names(globals) == c(names(globals0), "b")),
  +   all(names(globals) == names(where)),
  +   identical(globals$b, globals0$a)
  + )
  > 
  > message("7.")
  7.
  > globals <- globals0
  > globals$a <- NULL
  > str(globals)
  List of 1
   $ rnorm:function (n, mean = 0, sd = 1)  
   - attr(*, "where")=List of 1
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 1L,
  +   length(where) == length(globals),
  +   all(names(globals) == names(globals0)[-1]),
  +   all(names(globals) == names(where)),
  +   is.null(globals$a)
  + )
  > 
  > message("8.")
  8.
  > globals <- globals0
  > globals$a <- 1:2
  > str(globals)
  List of 2
   $ a    : int [1:2] 1 2
   $ rnorm:function (n, mean = 0, sd = 1)  
   - attr(*, "where")=List of 2
    ..$ a    :<environment: R_EmptyEnv> 
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 2L,
  +   length(where) == length(globals),
  +   all(names(globals) == names(globals0)),
  +   all(names(globals) == names(where)),
  +   identical(globals$a, 1:2)
  + )
  > 
  > message("9.")
  9.
  > globals <- globals0
  > globals[c("b", "a")] <- list(1:3, 42)
  > str(globals)
  List of 3
   $ a    : num 42
   $ rnorm:function (n, mean = 0, sd = 1)  
   $ b    : int [1:3] 1 2 3
   - attr(*, "where")=List of 3
    ..$ a    :<environment: R_EmptyEnv> 
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
    ..$ b    :<environment: R_EmptyEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 3L,
  +   length(where) == length(globals),
  +   all(names(globals) == c(names(globals0), "b")),
  +   all(names(globals) == names(where)),
  +   identical(globals$b, 1:3),
  +   identical(globals$a, 42)
  + )
  > 
  > message("10.")
  10.
  > globals <- Globals()
  > globals["empty"] <- list(NULL)
  > str(globals)
  List of 1
   $ empty: NULL
   - attr(*, "where")=List of 1
    ..$ empty:<environment: R_EmptyEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 1L,
  +   length(where) == length(globals),
  +   all(names(globals) == "empty"),
  +   is.null(globals[["empty"]])
  + )
  > 
  > 
  > message("*** Globals() - subsetted assignment ... DONE")
  *** Globals() - subsetted assignment ... DONE
  > 
  > 
  > message("*** Globals() - combining ...")
  *** Globals() - combining ...
  > 
  > globals_a <- globals0[1:2]
  > globals_b <- globals0[1:2]
  > globals <- c(globals_a, globals_b)
  > str(globals)
  List of 4
   $ a    : num 1
   $ rnorm:function (n, mean = 0, sd = 1)  
   $ a    : num 1
   $ rnorm:function (n, mean = 0, sd = 1)  
   - attr(*, "where")=List of 4
    ..$ a    :<environment: R_GlobalEnv> 
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
    ..$ a    :<environment: R_GlobalEnv> 
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 4L,
  +   length(where) == length(globals),
  +   all(names(globals) == c(names(globals_a), names(globals_b))),
  +   all(names(globals) == names(where))
  + )
  > 
  > globals_a <- globals0[1:2]
  > globals_b <- list(b = 1, c = letters)
  > globals <- c(globals_a, globals_b)
  > str(globals)
  List of 4
   $ a    : num 1
   $ rnorm:function (n, mean = 0, sd = 1)  
   $ b    : num 1
   $ c    : chr [1:26] "a" "b" "c" "d" ...
   - attr(*, "where")=List of 4
    ..$ a    :<environment: R_GlobalEnv> 
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
    ..$ b    :<environment: R_EmptyEnv> 
    ..$ c    :<environment: R_EmptyEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 4L,
  +   length(where) == length(globals),
  +   all(names(globals) == c(names(globals_a), names(globals_b))),
  +   all(names(globals) == names(where))
  + )
  > 
  > globals_a <- globals0[1:2]
  > globals_b <- list()
  > globals <- c(globals_a, globals_b)
  > str(globals)
  List of 2
   $ a    : num 1
   $ rnorm:function (n, mean = 0, sd = 1)  
   - attr(*, "where")=List of 2
    ..$ a    :<environment: R_GlobalEnv> 
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 2L,
  +   length(where) == length(globals),
  +   all(names(globals) == c(names(globals_a), names(globals_b))),
  +   all(names(globals) == names(where))
  + )
  > 
  > globals_a <- globals0[1:2]
  > globals <- c(globals_a, b = 1, c = letters)
  > str(globals)
  List of 4
   $ a    : num 1
   $ rnorm:function (n, mean = 0, sd = 1)  
   $ b    : num 1
   $ c    : chr [1:26] "a" "b" "c" "d" ...
   - attr(*, "where")=List of 4
    ..$ a    :<environment: R_GlobalEnv> 
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
    ..$ b    :<environment: R_EmptyEnv> 
    ..$ c    :<environment: R_EmptyEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 4L,
  +   length(where) == length(globals),
  +   all(names(globals) == c(names(globals_a), "b", "c")),
  +   all(names(globals) == names(where))
  + )
  > 
  > 
  > globals <- Globals()
  > globals_1 <- c(globals, fcn = median)
  > str(globals_1)
  List of 1
   $ fcn:function (x, na.rm = FALSE, ...)  
   - attr(*, "where")=List of 1
    ..$ fcn:<environment: namespace:stats> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > 
  > globals_2 <- globals
  > globals_2$fcn <- median
  > str(globals_2)
  List of 1
   $ fcn:function (x, na.rm = FALSE, ...)  
   - attr(*, "where")=List of 1
    ..$ fcn:<environment: namespace:stats> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > 
  > stopifnot(identical(globals_2, globals_1))
  > 
  > 
  > message("*** Globals() - combining ... DONE")
  *** Globals() - combining ... DONE
  > 
  > 
  > message("*** Globals() - unique ...")
  *** Globals() - unique ...
  > 
  > globals <- globals0[c(1:2, 1:2, 1:2)]
  > str(globals)
  List of 6
   $ a    : num 1
   $ rnorm:function (n, mean = 0, sd = 1)  
   $ a    : num 1
   $ rnorm:function (n, mean = 0, sd = 1)  
   $ a    : num 1
   $ rnorm:function (n, mean = 0, sd = 1)  
   - attr(*, "where")=List of 6
    ..$ a    :<environment: R_GlobalEnv> 
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
    ..$ a    :<environment: R_GlobalEnv> 
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
    ..$ a    :<environment: R_GlobalEnv> 
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 6L,
  +   length(where) == length(globals),
  +   all(names(globals) == rep(names(globals0), times = 3L)),
  +   all(names(globals) == names(where))
  + )
  > 
  > globals <- unique(globals)
  > str(globals)
  List of 2
   $ a    : num 1
   $ rnorm:function (n, mean = 0, sd = 1)  
   - attr(*, "where")=List of 2
    ..$ a    :<environment: R_GlobalEnv> 
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == length(globals0),
  +   length(where) == length(globals),
  +   all(names(globals) == names(globals0)),
  +   all(names(globals) == names(where))
  + )
  > 
  > message("*** Globals() - unique ... DONE")
  *** Globals() - unique ... DONE
  > 
  > 
  > message("*** Globals() - coercion ...")
  *** Globals() - coercion ...
  > 
  > globals <- as.Globals(globals0)
  > stopifnot(
  +   assert_attributes(globals),
  +   identical(globals, globals0)
  + )
  > 
  > 
  > globals <- as.Globals(unclass(globals0))
  > stopifnot(
  +   assert_attributes(globals),
  +   identical(globals, globals0)
  + )
  > 
  > globals_t <- unclass(globals0)
  > attr(globals_t, "where") <- NULL
  > globals <- as.Globals(globals_t)
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == length(globals0),
  +   names(globals) == names(globals0)
  + )
  > 
  > message("*** Globals() - coercion ... DONE")
  *** Globals() - coercion ... DONE
  > 
  > 
  > message("*** Globals() - empty ...")
  *** Globals() - empty ...
  > 
  > globals <- Globals()
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 0L
  + )
  > 
  > globals <- Globals(list())
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 0L
  + )
  > 
  > globals <- as.Globals(list())
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 0L
  + )
  > 
  > message("*** Globals() - empty ... DONE")
  *** Globals() - empty ... DONE
  > 
  > 
  > message("*** Globals() - NULL ...")
  *** Globals() - NULL ...
  > ## https://github.com/HenrikBengtsson/globals/issues/79
  > 
  > denv <- getOption("globals.environment_of.default", emptyenv())
  > 
  > globals <- as.Globals(list(a = NULL))
  > str(globals)
  List of 1
   $ a: NULL
   - attr(*, "where")=List of 1
    ..$ a:<environment: R_EmptyEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 1L,
  +   length(where) == length(globals),
  +   all(names(where) == names(globals)),
  +   identical(names(globals), c("a")),
  +   is.null(globals[["a"]]),
  +   identical(where[["a"]], denv)
  + )
  > 
  > globals <- c(Globals(), list(a = NULL))
  > str(globals)
  List of 1
   $ a: NULL
   - attr(*, "where")=List of 1
    ..$ a:<environment: R_EmptyEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > where <- attr(globals, "where")
  > stopifnot(
  +   assert_attributes(globals),
  +   length(globals) == 1L,
  +   length(where) == length(globals),
  +   all(names(where) == names(globals)),
  +   identical(names(globals), c("a")),
  +   is.null(globals[["a"]]),
  +   identical(where[["a"]], denv)
  + )
  > 
  > message("*** Globals() - NULL ... DONE")
  *** Globals() - NULL ... DONE
  > 
  > 
  > message("*** Globals() - exceptions ...")
  *** Globals() - exceptions ...
  > 
  > res <- tryCatch({ Globals(NULL) }, error = identity)
  > stopifnot(inherits(res, "simpleError"))
  > 
  > res <- tryCatch({ Globals(list(1, 2)) }, error = identity)
  > stopifnot(inherits(res, "simpleError"))
  > 
  > res <- tryCatch({ Globals(list(a = 1, 2)) }, error = identity)
  > stopifnot(inherits(res, "simpleError"))
  > 
  > ## Assigning more than one element
  > globals <- globals0
  > res <- tryCatch({ globals$a <- globals0[2:1] }, error = identity)
  > stopifnot(inherits(res, "simpleError"))
  > 
  > ## Appending unnamed objects
  > res <- tryCatch({ c(globals0, 2) }, error = identity)
  > stopifnot(inherits(res, "simpleError"))
  > 
  > message("*** Globals() - exceptions ... DONE")
  *** Globals() - exceptions ... DONE
  > 
  > message("*** Globals() ... DONE")
  *** Globals() ... DONE
  > 
  > source("incl/end.R")
  > 
  > proc.time()
     user  system elapsed 
     0.42    0.06    0.42 
Running the tests in 'tests/conservative.R' failed.
Complete output:
  > source("incl/start.R")
  > 
  > ## WORKAROUND: Avoid problem reported in testthat Issue #229, which
  > ## causes covr::package_coverage() to given an error. /HB 2015-02-16
  > suppressWarnings({
  +   rm(list = c("a", "b", "c", "x", "y", "z", "square",
  +             "pathname", "url", "filename"))
  + })
  > 
  > 
  > message("Setting up expressions")
  Setting up expressions
  > exprs <- list(
  +   A = quote({
  +     Sys.sleep(1)
  +     x <- 0.1
  +   }),
  +   B = quote({ y <- 0.2 }),
  +   C = quote({ z <- a + 0.3 }),
  +   D = quote({ pathname <- file.path(dirname(url), filename) }),
  +   E = quote({ b <- c }),
  +   F = quote({
  +     a <- { runif(1) }
  +     b <- { rnorm(1) }
  +     x <- a * b
  +     abs(x)
  +   }),
  +   G = quote({
  +     y <- square(a)
  +   }),
  +   H = quote({
  +     b <- a
  +     a <- 1
  +   })
  + )
  > 
  > atleast <- list(
  +   A = c(),
  +   B = c(),
  +   C = c("a"),
  +   D = c("filename"),
  +   E = c("c"),
  +   F = c(),
  +   G = c("a", "square"),
  +   H = c() ## FIXME: Should be c("a"), cf. Issue #5.
  + )
  > 
  > not <- list(
  +   A = c("x"),
  +   B = c("y"),
  +   C = c("z"),
  +   D = c("pathname"),
  +   E = c("b"),
  +   F = c("a", "b", "x"),
  +   G = c(),
  +   H = c()
  + )
  > 
  > 
  > ## Define globals
  > a <- 3.14
  > c <- 2.71
  > square <- function(x) x ^ 2
  > filename <- "index.html"
  > # Yes, pretend we forget 'url'
  > 
  > message("Find globals")
  Find globals
  > for (kk in seq_along(exprs)) {
  +   key <- names(exprs)[kk]
  +   expr <- exprs[[key]]
  +   cat(sprintf("Expression #%d ('%s'):\n", kk, key))
  +   print(expr)
  + 
  +   names <- findGlobals(expr, method = "conservative")
  +   cat(sprintf("Globals: %s\n", paste(sQuote(names), collapse = ", ")))
  +   stopifnot(all(atleast[[key]] %in% names))
  +   stopifnot(!any(names %in% not[[key]]))
  + 
  +   globals <- globalsOf(expr, method = "conservative")
  +   cat(sprintf("Globals: %s\n", paste(sQuote(names(globals)), collapse = ", ")))
  +   stopifnot(all(atleast[[key]] %in% names(globals)))
  +   stopifnot(!any(names(globals) %in% not[[key]]))
  +   str(globals)
  + 
  +   cat("\n")
  + }
  Expression #1 ('A'):
  {
      Sys.sleep(1)
      x <- 0.1
  }
  Globals: '{', 'Sys.sleep', '<-'
  Globals: '{', 'Sys.sleep', '<-'
  List of 3
   $ {        :.Primitive("{") 
   $ Sys.sleep:function (time)  
   $ <-       :.Primitive("<-") 
   - attr(*, "where")=List of 3
    ..$ {        :<environment: base> 
    ..$ Sys.sleep:<environment: base> 
    ..$ <-       :<environment: base> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  
  Expression #2 ('B'):
  {
      y <- 0.2
  }
  Globals: '{', '<-'
  Globals: '{', '<-'
  List of 2
   $ { :.Primitive("{") 
   $ <-:.Primitive("<-") 
   - attr(*, "where")=List of 2
    ..$ { :<environment: base> 
    ..$ <-:<environment: base> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  
  Expression #3 ('C'):
  {
      z <- a + 0.3
  }
  Globals: '{', '<-', '+', 'a'
  Globals: '{', '<-', '+', 'a'
  List of 4
   $ { :.Primitive("{") 
   $ <-:.Primitive("<-") 
   $ + :function (e1, e2)  
   $ a : num 3.14
   - attr(*, "where")=List of 4
    ..$ { :<environment: base> 
    ..$ <-:<environment: base> 
    ..$ + :<environment: base> 
    ..$ a :<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  
  Expression #4 ('D'):
  {
      pathname <- file.path(dirname(url), filename)
  }
  Globals: '{', '<-', 'file.path', 'dirname', 'url', 'filename'
  Globals: '{', '<-', 'file.path', 'dirname', 'url', 'filename'
  List of 6
   $ {        :.Primitive("{") 
   $ <-       :.Primitive("<-") 
   $ file.path:function (..., fsep = .Platform$file.sep)  
   $ dirname  :function (path)  
   $ url      :function (description, open = "", blocking = TRUE, encoding = getOption("encoding"), 
      method = getOption("url.method", "default"), headers = NULL)  
   $ filename : chr "index.html"
   - attr(*, "where")=List of 6
    ..$ {        :<environment: base> 
    ..$ <-       :<environment: base> 
    ..$ file.path:<environment: base> 
    ..$ dirname  :<environment: base> 
    ..$ url      :<environment: base> 
    ..$ filename :<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  
  Expression #5 ('E'):
  {
      b <- c
  }
  Globals: '{', '<-', 'c'
  Globals: '{', '<-', 'c'
  List of 3
   $ { :.Primitive("{") 
   $ <-:.Primitive("<-") 
   $ c : num 2.71
   - attr(*, "where")=List of 3
    ..$ { :<environment: base> 
    ..$ <-:<environment: base> 
    ..$ c :<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  
  Expression #6 ('F'):
  {
      a <- {
          runif(1)
      }
      b <- {
          rnorm(1)
      }
      x <- a * b
      abs(x)
  }
  Globals: '{', '<-', 'runif', 'rnorm', '*', 'abs'
  Globals: '{', '<-', 'runif', 'rnorm', '*', 'abs'
  List of 6
   $ {    :.Primitive("{") 
   $ <-   :.Primitive("<-") 
   $ runif:function (n, min = 0, max = 1)  
   $ rnorm:function (n, mean = 0, sd = 1)  
   $ *    :function (e1, e2)  
   $ abs  :function (x)  
   - attr(*, "where")=List of 6
    ..$ {    :<environment: base> 
    ..$ <-   :<environment: base> 
    ..$ runif:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
    ..$ *    :<environment: base> 
    ..$ abs  :<environment: base> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  
  Expression #7 ('G'):
  {
      y <- square(a)
  }
  Globals: '{', '<-', 'square', 'a'
  Globals: '{', '<-', 'square', 'a', '^'
  List of 5
   $ {     :.Primitive("{") 
   $ <-    :.Primitive("<-") 
   $ square:function (x)  
   $ a     : num 3.14
   $ ^     :function (e1, e2)  
   - attr(*, "where")=List of 5
    ..$ {     :<environment: base> 
    ..$ <-    :<environment: base> 
    ..$ square:<environment: R_GlobalEnv> 
    ..$ a     :<environment: R_GlobalEnv> 
    ..$ ^     :<environment: base> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  
  Expression #8 ('H'):
  {
      b <- a
      a <- 1
  }
  Globals: '{', '<-'
  Globals: '{', '<-'
  List of 2
   $ { :.Primitive("{") 
   $ <-:.Primitive("<-") 
   - attr(*, "where")=List of 2
    ..$ { :<environment: base> 
    ..$ <-:<environment: base> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  
  > 
  > names <- findGlobals(exprs, method = "conservative", unlist = TRUE)
  > cat(sprintf("Globals: %s\n", paste(sQuote(names), collapse = ", ")))
  Globals: '{', 'Sys.sleep', '<-', '+', 'a', 'file.path', 'dirname', 'url', 'filename', 'c', 'runif', 'rnorm', '*', 'abs', 'square'
  > 
  > ## Cleanup
  > source("incl/end.R")
  > 
  > proc.time()
     user  system elapsed 
     0.32    0.09    0.40 
Running the tests in 'tests/formulas.R' failed.
Complete output:
  > source("incl/start.R")
  > 
  > message("findGlobals() with formula ...")
  findGlobals() with formula ...
  > 
  > g <- findGlobals(. ~ x + y : z, substitute = TRUE)
  > print(g)
  [1] "~" "." "+" "x" ":" "y" "z"
  > assert_identical_sets(g, c("~", ".", "+", "x", ":", "y", "z"))
  > 
  > g <- findGlobals(map(1L, ~ typeof(.x)), substitute = TRUE)
  > print(g)
  [1] "map"    "~"      "typeof" ".x"    
  > assert_identical_sets(g, c("map", "~", "typeof", ".x"))
  > 
  > 
  > message("- findGlobals() with NULL in the formula ...")
  - findGlobals() with NULL in the formula ...
  > ## BUG: https://github.com/HenrikBengtsson/globals/issues/59
  > for (substitute in c(TRUE, FALSE)) {
  +   message("- substitute = ", substitute)
  +   
  +   g <- findGlobals(. ~ NULL, substitute = substitute)
  +   print(g)
  +   assert_identical_sets(g, c(".", "~"))
  + 
  +   g <- findGlobals(NULL ~ NULL, substitute = substitute)
  +   print(g)
  +   assert_identical_sets(g, c("~"))
  + 
  +   g <- findGlobals(~ NULL, substitute = substitute)
  +   print(g)
  +   assert_identical_sets(g, c("~"))
  + 
  +   g <- findGlobals(NULL ~ ., substitute = substitute)
  +   print(g)
  +   assert_identical_sets(g, c("~", "."))
  + }
  - substitute = TRUE
  [1] "~" "."
  [1] "~"
  [1] "~"
  [1] "~" "."
  - substitute = FALSE
  [1] "~" "."
  [1] "~"
  [1] "~"
  [1] "~" "."
  > 
  > # ## substitute=FALSE
  > # Browse[2]> str(expr)
  > #  language ~NULL
  > # 
  > # ## substitute=TRUE
  > # Browse[2]> str(expr)
  > # Class 'formula'  language ~NULL
  > #   ..- attr(*, ".Environment")=<environment: R_GlobalEnv> 
  > 
  > 
  > message("- findGlobals() with ellipsis in formulas ...")
  - findGlobals() with ellipsis in formulas ...
  > ## BUG: https://github.com/HenrikBengtsson/globals/issues/62
  > 
  > g <- findGlobals(list(..., ..3) ~ list(., .x, ..., ..1, ..2))
  > print(g)
  [1] "~"    "list" "..."  "..3"  "."    ".x"   "..1"  "..2" 
  > assert_identical_sets(g, c("~", "list", "...", "..3", ".", ".x", "..1", "..2"))
  > 
  > message("- findGlobals() with NULL in formulas ...")
  - findGlobals() with NULL in formulas ...
  > ## BUG: https://github.com/HenrikBengtsson/globals/issues/64
  > 
  > env <- new.env(parent = globalenv())
  > env$`~` <- function(...) "OVERRIDE!"
  > 
  > x <- ~ NULL
  > g <- eval(quote(findGlobals(x)), env)
  > assert_identical_sets(g, "~")
  > 
  > x <- list(~ NULL)
  > g <- eval(quote(findGlobals(x)), env)
  > assert_identical_sets(g, "~")
  > 
  > x <- list(NULL ~ NULL)
  > g <- eval(quote(findGlobals(x)), env)
  > assert_identical_sets(g, "~")
  > 
  > x <- list(NULL ~ b)
  > g <- eval(quote(findGlobals(x)), env)
  > assert_identical_sets(g, c("~", "b"))
  > 
  > 
  > message("findGlobals() with formula ... DONE")
  findGlobals() with formula ... DONE
  > 
  > 
  > message("globalsOf() with formula ...")
  globalsOf() with formula ...
  > 
  > foo <- function(x) {
  +   map(1L, ~ typeof(x + .x))
  + }
  > 
  > g <- globalsOf(foo(1L), substitute = TRUE, mustExist = FALSE)
  > str(g)
  List of 8
   $ foo   :function (x)  
   $ {     :.Primitive("{") 
   $ map   : NULL
   $ ~     :.Primitive("~") 
   $ typeof:function (x)  
   $ +     :function (e1, e2)  
   $ x     :List of 1
    ..$ :Class 'formula'  language NULL ~ b
    .. .. ..- attr(*, ".Environment")=<environment: R_GlobalEnv> 
   $ .x    : NULL
   - attr(*, "where")=List of 8
    ..$ foo   :<environment: R_GlobalEnv> 
    ..$ {     :<environment: base> 
    ..$ map   : NULL
    ..$ ~     :<environment: base> 
    ..$ typeof:<environment: base> 
    ..$ +     :<environment: base> 
    ..$ x     :<environment: R_GlobalEnv> 
    ..$ .x    : NULL
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > assert_identical_sets(names(g), c("foo", "map", "{", "~", "typeof", "+", "x", ".x"))
  > 
  > message("globalsOf() with formula ... DONE")
  globalsOf() with formula ... DONE
  > 
  > source("incl/end.R")
  > 
  > proc.time()
     user  system elapsed 
     0.28    0.07    0.34 
Running the tests in 'tests/globalsOf,locals.R' failed.
Complete output:
  > source("incl/start.R")
  > 
  > message("*** globalsOf() w/ local() ...")
  *** globalsOf() w/ local() ...
  > 
  > for (locals in c(TRUE, FALSE)) {
  +   message(sprintf("- locals=%s", locals))
  + 
  +   f <- local({
  +     a <- 42
  +     function() a
  +   })
  +   
  +   globals <- globalsOf(quote(f), locals = locals)
  +   str(globals)
  +   where <- attr(globals, "where")
  +   if (locals) {
  +     stopifnot(
  +       length(globals) == 2L,
  +       identical(sort(names(globals)), c("a", "f")),
  +       identical(where[["a"]], environment(globals[["f"]]))
  +     )
  +   } else {
  +     stopifnot(
  +       length(globals) == 1L,
  +       identical(names(globals), "f")
  +     )
  +   }
  +   
  +   message(sprintf("- locals=%s with nested local():s", locals))
  +   
  +   f <- local({
  +     b <- 3.14
  +     local({
  +       a <- 42
  +       function() a + b
  +     })
  +   })
  +   
  +   globals <- globalsOf(quote(f), locals = locals)
  +   globals <- cleanup(globals)
  +   str(globals)
  +   where <- attr(globals, "where")
  +   if (locals) {
  +     stopifnot(
  +       length(globals) == 3L,
  +       identical(sort(names(globals)), c("a", "b", "f")),
  +       identical(where[["a"]], environment(globals[["f"]])),
  +       identical(where[["b"]], parent.env(environment(globals[["f"]])))
  +     )
  +   } else {
  +     stopifnot(
  +       length(globals) == 1L,
  +       identical(names(globals), "f")
  +     )
  +   }
  + } # for (locals ...)
  - locals=TRUE
  List of 2
   $ f:function ()  
   $ a: num 42
   - attr(*, "where")=List of 2
    ..$ f:<environment: R_GlobalEnv> 
    ..$ a:<environment: 0x00000284ad3a8fb8> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  - locals=TRUE with nested local():s
  List of 3
   $ f:function ()  
   $ a: num 42
   $ b: num 3.14
   - attr(*, "where")=List of 3
    ..$ f:<environment: R_GlobalEnv> 
    ..$ a:<environment: 0x00000284ad835d10> 
    ..$ b:<environment: 0x00000284ad835db8> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  - locals=FALSE
  List of 1
   $ f:function ()  
   - attr(*, "where")=List of 1
    ..$ f:<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  - locals=FALSE with nested local():s
  List of 1
   $ f:function ()  
   - attr(*, "where")=List of 1
    ..$ f:<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > 
  > message("*** globalsOf() w/ local() ... DONE")
  *** globalsOf() w/ local() ... DONE
  > 
  > source("incl/end.R")
  > 
  > proc.time()
     user  system elapsed 
     0.28    0.03    0.29 
Running the tests in 'tests/globalsOf.R' failed.
Complete output:
  > source("incl/start.R")
  > 
  > message("*** globalsOf() ...")
  *** globalsOf() ...
  > 
  > message(" ** globalsOf(..., method = 'conservative'):")
   ** globalsOf(..., method = 'conservative'):
  > expr <- exprs$A
  > globals_c <- globalsOf(expr, method = "conservative")
  > str(globals_c)
  List of 5
   $ { :.Primitive("{") 
   $ <-:.Primitive("<-") 
   $ c : num 3
   $ d : NULL
   $ + :function (e1, e2)  
   - attr(*, "where")=List of 5
    ..$ { :<environment: base> 
    ..$ <-:<environment: base> 
    ..$ c :<environment: R_GlobalEnv> 
    ..$ d :<environment: R_GlobalEnv> 
    ..$ + :<environment: base> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > assert_identical_sets(names(globals_c), c("{", "<-", "c", "d", "+"))
  > globals_c <- cleanup(globals_c)
  > str(globals_c)
  List of 2
   $ c: num 3
   $ d: NULL
   - attr(*, "where")=List of 2
    ..$ c:<environment: R_GlobalEnv> 
    ..$ d:<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > assert_identical_sets(names(globals_c), c("c", "d"))
  > where <- attr(globals_c, "where")
  > stopifnot(
  +   length(where) == length(globals_c),
  +   identical(where$c, globalenv()),
  +   identical(where$d, globalenv())
  + )
  > 
  > message(" ** globalsOf(..., method = 'liberal'):")
   ** globalsOf(..., method = 'liberal'):
  > expr <- exprs$A
  > globals_l <- globalsOf(expr, method = "liberal")
  > str(globals_l)
  List of 8
   $ { :.Primitive("{") 
   $ <-:.Primitive("<-") 
   $ b : num 2
   $ c : num 3
   $ d : NULL
   $ + :function (e1, e2)  
   $ a : num 0
   $ e :function ()  
   - attr(*, "where")=List of 8
    ..$ { :<environment: base> 
    ..$ <-:<environment: base> 
    ..$ b :<environment: R_GlobalEnv> 
    ..$ c :<environment: R_GlobalEnv> 
    ..$ d :<environment: R_GlobalEnv> 
    ..$ + :<environment: base> 
    ..$ a :<environment: R_GlobalEnv> 
    ..$ e :<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > assert_identical_sets(names(globals_l), c("{", "<-", "b", "c", "d", "+", "a", "e"))
  > globals_l <- cleanup(globals_l)
  > str(globals_l)
  List of 5
   $ b: num 2
   $ c: num 3
   $ d: NULL
   $ a: num 0
   $ e:function ()  
   - attr(*, "where")=List of 5
    ..$ b:<environment: R_GlobalEnv> 
    ..$ c:<environment: R_GlobalEnv> 
    ..$ d:<environment: R_GlobalEnv> 
    ..$ a:<environment: R_GlobalEnv> 
    ..$ e:<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > assert_identical_sets(names(globals_l), c("b", "c", "d", "a", "e"))
  > where <- attr(globals_l, "where")
  > stopifnot(
  +   length(where) == length(globals_l),
  +   identical(where$b, globalenv()),
  +   identical(where$c, globalenv()),
  +   identical(where$d, globalenv())
  + )
  > 
  > message(" ** globalsOf(..., method = 'ordered'):")
   ** globalsOf(..., method = 'ordered'):
  > expr <- exprs$A
  > globals_i <- globalsOf(expr, method = "ordered")
  > str(globals_i)
  List of 8
   $ { :.Primitive("{") 
   $ <-:.Primitive("<-") 
   $ b : num 2
   $ c : num 3
   $ d : NULL
   $ a : num 0
   $ + :function (e1, e2)  
   $ e :function ()  
   - attr(*, "where")=List of 8
    ..$ { :<environment: base> 
    ..$ <-:<environment: base> 
    ..$ b :<environment: R_GlobalEnv> 
    ..$ c :<environment: R_GlobalEnv> 
    ..$ d :<environment: R_GlobalEnv> 
    ..$ a :<environment: R_GlobalEnv> 
    ..$ + :<environment: base> 
    ..$ e :<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > assert_identical_sets(names(globals_i), c("{", "<-", "b", "c", "d", "+", "a", "e"))
  > globals_i <- cleanup(globals_i)
  > str(globals_i)
  List of 5
   $ b: num 2
   $ c: num 3
   $ d: NULL
   $ a: num 0
   $ e:function ()  
   - attr(*, "where")=List of 5
    ..$ b:<environment: R_GlobalEnv> 
    ..$ c:<environment: R_GlobalEnv> 
    ..$ d:<environment: R_GlobalEnv> 
    ..$ a:<environment: R_GlobalEnv> 
    ..$ e:<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > assert_identical_sets(names(globals_i), c("b", "c", "d", "a", "e"))
  > where <- attr(globals_i, "where")
  > stopifnot(
  +   length(where) == length(globals_i),
  +   identical(where$b, globalenv()),
  +   identical(where$c, globalenv()),
  +   identical(where$d, globalenv())
  + )
  > 
  > globals_i <- globalsOf(function(x) x <- x)
  > print(globals_i)
  $`<-`
  .Primitive("<-")
  
  attr(,"where")
  attr(,"where")$`<-`
  <environment: base>
  
  attr(,"class")
  [1] "Globals" "list"   
  > globals_i <- cleanup(globals_i)
  > str(globals_i)
   Named list()
   - attr(*, "where")= Named list()
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > assert_identical_sets(names(globals_i), character(0L))
  > where <- attr(globals_i, "where")
  > stopifnot(
  +   length(where) == length(globals_i),
  +   identical(where, setNames(list(), character(0L)))
  + )
  > 
  > 
  > globals_i <- globalsOf(function(x) x[1] <- 0)
  > print(globals_i)
  $`<-`
  .Primitive("<-")
  
  $`[`
  .Primitive("[")
  
  $`[<-`
  .Primitive("[<-")
  
  attr(,"where")
  attr(,"where")$`<-`
  <environment: base>
  
  attr(,"where")$`[`
  <environment: base>
  
  attr(,"where")$`[<-`
  <environment: base>
  
  attr(,"class")
  [1] "Globals" "list"   
  > globals_i <- cleanup(globals_i)
  > str(globals_i)
   Named list()
   - attr(*, "where")= Named list()
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > assert_identical_sets(names(globals_i), character(0L))
  > where <- attr(globals_i, "where")
  > stopifnot(
  +   length(where) == length(globals_i),
  +   identical(where, setNames(list(), character(0L)))
  + )
  > 
  > globals_i <- globalsOf(function(x) a <- x$a)
  > print(globals_i)
  $`<-`
  .Primitive("<-")
  
  $`$`
  .Primitive("$")
  
  attr(,"where")
  attr(,"where")$`<-`
  <environment: base>
  
  attr(,"where")$`$`
  <environment: base>
  
  attr(,"class")
  [1] "Globals" "list"   
  > globals_i <- cleanup(globals_i)
  > str(globals_i)
   Named list()
   - attr(*, "where")= Named list()
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > assert_identical_sets(names(globals_i), character(0L))
  > where <- attr(globals_i, "where")
  > stopifnot(
  +   length(where) == length(globals_i),
  +   identical(where, setNames(list(), character(0L)))
  + )
  > 
  > globals_i <- globalsOf(function(...) args <- list(...))
  > print(globals_i)
  $`<-`
  .Primitive("<-")
  
  $list
  function (...)  .Primitive("list")
  
  attr(,"where")
  attr(,"where")$`<-`
  <environment: base>
  
  attr(,"where")$list
  <environment: base>
  
  attr(,"class")
  [1] "Globals" "list"   
  > globals_i <- cleanup(globals_i)
  > str(globals_i)
   Named list()
   - attr(*, "where")= Named list()
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > assert_identical_sets(names(globals_i), character(0L))
  > where <- attr(globals_i, "where")
  > stopifnot(
  +   length(where) == length(globals_i),
  +   identical(where, setNames(list(), character(0L)))
  + )
  > 
  > 
  > x <- 1
  > globals_i <- globalsOf({ function(x) x; x }, substitute = TRUE)
  > print(globals_i)
  $`{`
  .Primitive("{")
  
  $x
  [1] 1
  
  attr(,"where")
  attr(,"where")$`{`
  <environment: base>
  
  attr(,"where")$x
  <environment: R_GlobalEnv>
  
  attr(,"class")
  [1] "Globals" "list"   
  > globals_i <- cleanup(globals_i)
  > str(globals_i)
  List of 1
   $ x: num 1
   - attr(*, "where")=List of 1
    ..$ x:<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > assert_identical_sets(names(globals_i), "x")
  > where <- attr(globals_i, "where")
  > stopifnot(
  +   length(where) == length(globals_i)
  + )
  > 
  > 
  > 
  > message(" ** globalsOf() w/ globals in functions:")
   ** globalsOf() w/ globals in functions:
  > 
  > a <- 1
  > bar <- function(x) x - a
  > foo <- function(x) bar(x)
  > 
  > for (method in c("ordered", "conservative", "liberal")) {
  +   globals <- globalsOf({ foo(3) }, substitute = TRUE, method = method,
  +                          recursive = FALSE, mustExist = FALSE)
  +   assert_identical_sets(names(globals), c("{", "foo"))
  +   stopifnot(!any("a" %in% names(globals)))
  +   globals <- cleanup(globals)
  +   str(globals)
  +   assert_identical_sets(names(globals), c("foo"))
  +   stopifnot(!any("a" %in% names(globals)))
  + 
  +   globals <- globalsOf({ foo(3) }, substitute = TRUE, method = "ordered",
  +                          recursive = TRUE, mustExist = FALSE)
  +   assert_identical_sets(names(globals), c("{", "foo", "bar", "-", "a"))
  +   globals <- cleanup(globals)
  +   str(globals)
  +   assert_identical_sets(names(globals), c("foo", "bar", "a"))
  + 
  +   globals <- globalsOf({ foo(3) }, substitute = TRUE,
  +                          recursive = TRUE, mustExist = FALSE)
  +   assert_identical_sets(names(globals), c("{", "foo", "bar", "-", "a"))
  +   globals <- cleanup(globals)
  +   str(globals)
  +   assert_identical_sets(names(globals), c("foo", "bar", "a"))
  + }
  List of 1
   $ foo:function (x)  
   - attr(*, "where")=List of 1
    ..$ foo:<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  List of 3
   $ foo:function (x)  
   $ bar:function (x)  
   $ a  : num 1
   - attr(*, "where")=List of 3
    ..$ foo:<environment: R_GlobalEnv> 
    ..$ bar:<environment: R_GlobalEnv> 
    ..$ a  :<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  List of 3
   $ foo:function (x)  
   $ bar:function (x)  
   $ a  : num 1
   - attr(*, "where")=List of 3
    ..$ foo:<environment: R_GlobalEnv> 
    ..$ bar:<environment: R_GlobalEnv> 
    ..$ a  :<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  List of 1
   $ foo:function (x)  
   - attr(*, "where")=List of 1
    ..$ foo:<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  List of 3
   $ foo:function (x)  
   $ bar:function (x)  
   $ a  : num 1
   - attr(*, "where")=List of 3
    ..$ foo:<environment: R_GlobalEnv> 
    ..$ bar:<environment: R_GlobalEnv> 
    ..$ a  :<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  List of 3
   $ foo:function (x)  
   $ bar:function (x)  
   $ a  : num 1
   - attr(*, "where")=List of 3
    ..$ foo:<environment: R_GlobalEnv> 
    ..$ bar:<environment: R_GlobalEnv> 
    ..$ a  :<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  List of 1
   $ foo:function (x)  
   - attr(*, "where")=List of 1
    ..$ foo:<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  List of 3
   $ foo:function (x)  
   $ bar:function (x)  
   $ a  : num 1
   - attr(*, "where")=List of 3
    ..$ foo:<environment: R_GlobalEnv> 
    ..$ bar:<environment: R_GlobalEnv> 
    ..$ a  :<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  List of 3
   $ foo:function (x)  
   $ bar:function (x)  
   $ a  : num 1
   - attr(*, "where")=List of 3
    ..$ foo:<environment: R_GlobalEnv> 
    ..$ bar:<environment: R_GlobalEnv> 
    ..$ a  :<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > 
  > 
  > message(" ** globalsOf() w/ recursive functions:")
   ** globalsOf() w/ recursive functions:
  > 
  > ## "Easy"
  > f <- function() Recall()
  > globals <- globalsOf(f)
  > str(globals)
  List of 1
   $ Recall:function (...)  
   - attr(*, "where")=List of 1
    ..$ Recall:<environment: base> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > 
  > ## Direct recursive call
  > f <- function() f()
  > globals <- globalsOf(f)
  > str(globals)
  List of 1
   $ f:function ()  
   - attr(*, "where")=List of 1
    ..$ f:<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > 
  > ## Indirect recursive call
  > f <- function() g()
  > g <- function() f()
  > globals_f <- globalsOf(f)
  > str(globals_f)
  List of 2
   $ g:function ()  
   $ f:function ()  
   - attr(*, "where")=List of 2
    ..$ g:<environment: R_GlobalEnv> 
    ..$ f:<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > globals_g <- globalsOf(g)
  > str(globals_g)
  List of 2
   $ f:function ()  
   $ g:function ()  
   - attr(*, "where")=List of 2
    ..$ f:<environment: R_GlobalEnv> 
    ..$ g:<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > globals_f <- globals_f[order(names(globals_f))]
  > globals_g <- globals_g[order(names(globals_g))]
  > stopifnot(identical(globals_g, globals_f))
  > 
  > 
  > message("*** globalsOf() ... DONE")
  *** globalsOf() ... DONE
  > 
  > 
  > message("*** Subsetting of Globals:")
  *** Subsetting of Globals:
  > expr <- exprs$A
  > globals_l <- globalsOf(expr, method = "liberal")
  > globals_s <- globals_l[-1]
  > stopifnot(length(globals_s) == length(globals_l) - 1L)
  > stopifnot(identical(class(globals_s), class(globals_l)))
  > where_l <- attr(globals_l, "where")
  > where_s <- attr(globals_s, "where")
  > stopifnot(length(where_s) == length(where_l) - 1L)
  > stopifnot(identical(where_s, where_l[-1]))
  > 
  > 
  > message("*** cleanup() & packagesOf():")
  *** cleanup() & packagesOf():
  > expr <- exprs$A
  > globals <- globalsOf(expr, method = "conservative")
  > str(globals)
  List of 5
   $ { :.Primitive("{") 
   $ <-:.Primitive("<-") 
   $ c : num 3
   $ d : NULL
   $ + :function (e1, e2)  
   - attr(*, "where")=List of 5
    ..$ { :<environment: base> 
    ..$ <-:<environment: base> 
    ..$ c :<environment: R_GlobalEnv> 
    ..$ d :<environment: R_GlobalEnv> 
    ..$ + :<environment: base> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > assert_identical_sets(names(globals), c("{", "<-", "c", "d", "+"))
  > 
  > globals <- as.Globals(globals)
  > str(globals)
  List of 5
   $ { :.Primitive("{") 
   $ <-:.Primitive("<-") 
   $ c : num 3
   $ d : NULL
   $ + :function (e1, e2)  
   - attr(*, "where")=List of 5
    ..$ { :<environment: base> 
    ..$ <-:<environment: base> 
    ..$ c :<environment: R_GlobalEnv> 
    ..$ d :<environment: R_GlobalEnv> 
    ..$ + :<environment: base> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > assert_identical_sets(names(globals), c("{", "<-", "c", "d", "+"))
  > 
  > globals <- as.Globals(unclass(globals))
  > str(globals)
  List of 5
   $ { :.Primitive("{") 
   $ <-:.Primitive("<-") 
   $ c : num 3
   $ d : NULL
   $ + :function (e1, e2)  
   - attr(*, "where")=List of 5
    ..$ { :<environment: base> 
    ..$ <-:<environment: base> 
    ..$ c :<environment: R_GlobalEnv> 
    ..$ d :<environment: R_GlobalEnv> 
    ..$ + :<environment: base> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > assert_identical_sets(names(globals), c("{", "<-", "c", "d", "+"))
  > 
  > pkgs <- packagesOf(globals)
  > print(pkgs)
  [1] "base"
  > stopifnot(
  +   length(pkgs) == 1L,
  +   identical(pkgs, c("base"))
  + )
  > 
  > globals <- cleanup(globals)
  > str(globals)
  List of 2
   $ c: num 3
   $ d: NULL
   - attr(*, "where")=List of 2
    ..$ c:<environment: R_GlobalEnv> 
    ..$ d:<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > assert_identical_sets(names(globals), c("c", "d"))
  > 
  > pkgs <- packagesOf(globals)
  > print(pkgs)
  character(0)
  > stopifnot(length(pkgs) == 0L)
  > 
  > globals <- globalsOf(quote(pi))
  > stopifnot(
  +   length(globals) == 1L,
  +   identical(names(globals), "pi")
  + )
  > pkgs <- packagesOf(globals)
  > print(pkgs)
  [1] "base"
  > stopifnot(
  +   length(pkgs) == 1L,
  +   identical(pkgs, c("base"))
  + )
  > 
  > message("*** globalsOf() and package functions:")
  *** globalsOf() and package functions:
  > foo <- globals::Globals
  > expr <- exprs$C
  > globals <- globalsOf(expr, recursive = FALSE)
  > str(globals)
  List of 3
   $ {   :.Primitive("{") 
   $ foo :function (object = list(), ...)  
   $ list:function (...)  
   - attr(*, "where")=List of 3
    ..$ {   :<environment: base> 
    ..$ foo :<environment: R_GlobalEnv> 
    ..$ list:<environment: base> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > assert_identical_sets(names(globals), c("{", "foo", "list"))
  > where <- attr(globals, "where")
  > stopifnot(length(where) == length(globals))
  > if (!covr) stopifnot(
  +   identical(where$`{`, baseenv()),
  +   identical(where$foo, globalenv()),
  +   identical(where$list, baseenv())
  + )
  > 
  > globals <- cleanup(globals)
  > str(globals)
  List of 1
   $ foo:function (object = list(), ...)  
   - attr(*, "where")=List of 1
    ..$ foo:<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > assert_identical_sets(names(globals), c("foo"))
  > pkgs <- packagesOf(globals)
  > stopifnot(pkgs == "globals")
  > 
  > 
  > message("*** globalsOf() and core-package functions:")
  *** globalsOf() and core-package functions:
  > sample2 <- base::sample
  > sum2 <- base::sum
  > expr <- exprs$D
  > globals <- globalsOf(expr, recursive = FALSE)
  > str(globals)
  List of 8
   $ {                :.Primitive("{") 
   $ <-               :.Primitive("<-") 
   $ sample           :function (x, size, replace = FALSE, prob = NULL)  
   $ sum              :function (..., na.rm = FALSE)  
   $ sample2          :function (x, size, replace = FALSE, prob = NULL)  
   $ sum2             :function (..., na.rm = FALSE)  
   $ sessionInfo      :function (package = NULL)  
   $ isNamespaceLoaded:function (name)  
   - attr(*, "where")=List of 8
    ..$ {                :<environment: base> 
    ..$ <-               :<environment: base> 
    ..$ sample           :<environment: base> 
    ..$ sum              :<environment: base> 
    ..$ sample2          :<environment: R_GlobalEnv> 
    ..$ sum2             :<environment: R_GlobalEnv> 
    ..$ sessionInfo      :<environment: package:utils> 
    .. ..- attr(*, "name")= chr "package:utils"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/utils"
    ..$ isNamespaceLoaded:<environment: base> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > assert_identical_sets(names(globals), c("{", "<-", "sample", "sample2", "sessionInfo", "sum", "sum2", "isNamespaceLoaded"))
  > where <- attr(globals, "where")
  > stopifnot(length(where) == length(globals))
  > if (!covr) stopifnot(
  +   identical(where$`<-`, baseenv()),
  +   identical(where$sample, baseenv()),
  +   identical(where$sample2, globalenv())
  + )
  > 
  > globals <- cleanup(globals, drop = "primitives")
  > str(globals)
  List of 5
   $ sample           :function (x, size, replace = FALSE, prob = NULL)  
   $ sample2          :function (x, size, replace = FALSE, prob = NULL)  
   $ sum2             :function (..., na.rm = FALSE)  
   $ sessionInfo      :function (package = NULL)  
   $ isNamespaceLoaded:function (name)  
   - attr(*, "where")=List of 5
    ..$ sample           :<environment: base> 
    ..$ sample2          :<environment: R_GlobalEnv> 
    ..$ sum2             :<environment: R_GlobalEnv> 
    ..$ sessionInfo      :<environment: package:utils> 
    .. ..- attr(*, "name")= chr "package:utils"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/utils"
    ..$ isNamespaceLoaded:<environment: base> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > assert_identical_sets(names(globals), c("sample", "sample2", "sum2", "sessionInfo", "isNamespaceLoaded"))
  > 
  > globals <- cleanup(globals, drop = "internals")
  > str(globals)
  List of 4
   $ sample     :function (x, size, replace = FALSE, prob = NULL)  
   $ sample2    :function (x, size, replace = FALSE, prob = NULL)  
   $ sum2       :function (..., na.rm = FALSE)  
   $ sessionInfo:function (package = NULL)  
   - attr(*, "where")=List of 4
    ..$ sample     :<environment: base> 
    ..$ sample2    :<environment: R_GlobalEnv> 
    ..$ sum2       :<environment: R_GlobalEnv> 
    ..$ sessionInfo:<environment: package:utils> 
    .. ..- attr(*, "name")= chr "package:utils"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/utils"
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > assert_identical_sets(names(globals), c("sample", "sample2", "sum2", "sessionInfo"))
  > 
  > globals <- cleanup(globals)
  > str(globals)
  List of 2
   $ sample2:function (x, size, replace = FALSE, prob = NULL)  
   $ sum2   :function (..., na.rm = FALSE)  
   - attr(*, "where")=List of 2
    ..$ sample2:<environment: R_GlobalEnv> 
    ..$ sum2   :<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  > assert_identical_sets(names(globals), c("sample2", "sum2"))
  > where <- attr(globals, "where")
  > stopifnot(length(where) == length(globals))
  > if (!covr) stopifnot(identical(where$sample2, globalenv()))
  > 
  > 
  > message("*** globalsOf() - exceptions ...")
  *** globalsOf() - exceptions ...
  > 
  > rm(list = "a")
  > res <- try({
  +   globals <- globalsOf({ x <- a }, substitute = TRUE, mustExist = TRUE)
  + }, silent = TRUE)
  > stopifnot(inherits(res, "try-error"))
  > 
  > message("*** globalsOf() - exceptions ... DONE")
  *** globalsOf() - exceptions ... DONE
  > 
  > source("incl/end.R")
  > 
  > proc.time()
     user  system elapsed 
     0.53    0.04    0.56 
Running the tests in 'tests/liberal.R' failed.
Complete output:
  > source("incl/start.R")
  > 
  > ## WORKAROUND: Avoid problem reported in testthat Issue #229, which
  > ## causes covr::package_coverage() to given an error. /HB 2015-02-16
  > suppressWarnings({
  +   rm(list = c("a", "b", "c", "x", "y", "z", "square",
  +             "pathname", "url", "filename"))
  + })
  > 
  > 
  > message("Setting up expressions")
  Setting up expressions
  > exprs <- list(
  +   A = quote({
  +     Sys.sleep(1)
  +     x <- 0.1
  +   }),
  +   B = quote({ y <- 0.2 }),
  +   C = quote({ z <- a + 0.3 }),
  +   D = quote({ pathname <- file.path(dirname(url), filename) }),
  +   E = quote({ b <- c }),
  +   F = quote({
  +     a <- { runif(1) }
  +     b <- { rnorm(1) }
  +     x <- a * b
  +     abs(x)
  +   }),
  +   G = quote({
  +     y <- square(a)
  +   }),
  +   H = quote({
  +     b <- a
  +     a <- 1
  +   })
  + )
  > 
  > atleast <- list(
  +   A = c(),
  +   B = c(),
  +   C = c("a"),
  +   D = c("filename"),
  +   E = c("c"),
  +   F = c(),
  +   G = c("a", "square"),
  +   H = c() ## FIXME: Should be c("a"), cf. Issue #5.
  + )
  > 
  > not <- list(
  +   A = c("x"),
  +   B = c("y"),
  +   C = c("z"),
  +   D = c("pathname"),
  +   E = c("b"),
  +   F = c(),
  +   G = c(),
  +   H = c()
  + )
  > 
  > 
  > ## Define globals
  > a <- 3.14
  > c <- 2.71
  > square <- function(x) x ^ 2
  > filename <- "index.html"
  > # Yes, pretend we forget 'url'
  > 
  > message("Find globals")
  Find globals
  > for (kk in seq_along(exprs)) {
  +   key <- names(exprs)[kk]
  +   expr <- exprs[[key]]
  +   cat(sprintf("Expression #%d ('%s'):\n", kk, key))
  +   print(expr)
  + 
  +   names <- findGlobals(expr, method = "liberal")
  +   cat(sprintf("Globals: %s\n", paste(sQuote(names), collapse = ", ")))
  +   stopifnot(all(atleast[[key]] %in% names))
  +   stopifnot(!any(names %in% not[[key]]))
  + 
  +   globals <- globalsOf(expr, method = "liberal", mustExist = FALSE)
  +   cat(sprintf("Globals: %s\n", paste(sQuote(names(globals)), collapse = ", ")))
  +   stopifnot(all(atleast[[key]] %in% names(globals)))
  +   stopifnot(!any(names(globals) %in% not[[key]]))
  +   str(globals)
  + 
  +   cat("\n")
  + }
  Expression #1 ('A'):
  {
      Sys.sleep(1)
      x <- 0.1
  }
  Globals: '{', 'Sys.sleep', '<-'
  Globals: '{', 'Sys.sleep', '<-'
  List of 3
   $ {        :.Primitive("{") 
   $ Sys.sleep:function (time)  
   $ <-       :.Primitive("<-") 
   - attr(*, "where")=List of 3
    ..$ {        :<environment: base> 
    ..$ Sys.sleep:<environment: base> 
    ..$ <-       :<environment: base> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  
  Expression #2 ('B'):
  {
      y <- 0.2
  }
  Globals: '{', '<-'
  Globals: '{', '<-'
  List of 2
   $ { :.Primitive("{") 
   $ <-:.Primitive("<-") 
   - attr(*, "where")=List of 2
    ..$ { :<environment: base> 
    ..$ <-:<environment: base> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  
  Expression #3 ('C'):
  {
      z <- a + 0.3
  }
  Globals: '{', '<-', '+', 'a'
  Globals: '{', '<-', '+', 'a'
  List of 4
   $ { :.Primitive("{") 
   $ <-:.Primitive("<-") 
   $ + :function (e1, e2)  
   $ a : num 3.14
   - attr(*, "where")=List of 4
    ..$ { :<environment: base> 
    ..$ <-:<environment: base> 
    ..$ + :<environment: base> 
    ..$ a :<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  
  Expression #4 ('D'):
  {
      pathname <- file.path(dirname(url), filename)
  }
  Globals: '{', '<-', 'file.path', 'dirname', 'url', 'filename'
  Globals: '{', '<-', 'file.path', 'dirname', 'url', 'filename'
  List of 6
   $ {        :.Primitive("{") 
   $ <-       :.Primitive("<-") 
   $ file.path:function (..., fsep = .Platform$file.sep)  
   $ dirname  :function (path)  
   $ url      :function (description, open = "", blocking = TRUE, encoding = getOption("encoding"), 
      method = getOption("url.method", "default"), headers = NULL)  
   $ filename : chr "index.html"
   - attr(*, "where")=List of 6
    ..$ {        :<environment: base> 
    ..$ <-       :<environment: base> 
    ..$ file.path:<environment: base> 
    ..$ dirname  :<environment: base> 
    ..$ url      :<environment: base> 
    ..$ filename :<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  
  Expression #5 ('E'):
  {
      b <- c
  }
  Globals: '{', '<-', 'c'
  Globals: '{', '<-', 'c'
  List of 3
   $ { :.Primitive("{") 
   $ <-:.Primitive("<-") 
   $ c : num 2.71
   - attr(*, "where")=List of 3
    ..$ { :<environment: base> 
    ..$ <-:<environment: base> 
    ..$ c :<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  
  Expression #6 ('F'):
  {
      a <- {
          runif(1)
      }
      b <- {
          rnorm(1)
      }
      x <- a * b
      abs(x)
  }
  Globals: '{', '<-', 'runif', 'rnorm', '*', 'a', 'b', 'abs', 'x'
  Globals: '{', '<-', 'runif', 'rnorm', '*', 'a', 'b', 'abs', 'x'
  List of 9
   $ {    :.Primitive("{") 
   $ <-   :.Primitive("<-") 
   $ runif:function (n, min = 0, max = 1)  
   $ rnorm:function (n, mean = 0, sd = 1)  
   $ *    :function (e1, e2)  
   $ a    : num 3.14
   $ b    : NULL
   $ abs  :function (x)  
   $ x    : NULL
   - attr(*, "where")=List of 9
    ..$ {    :<environment: base> 
    ..$ <-   :<environment: base> 
    ..$ runif:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
    ..$ rnorm:<environment: package:stats> 
    .. ..- attr(*, "name")= chr "package:stats"
    .. ..- attr(*, "path")= chr "D:/RCompile/recent/R/library/stats"
    ..$ *    :<environment: base> 
    ..$ a    :<environment: R_GlobalEnv> 
    ..$ b    : NULL
    ..$ abs  :<environment: base> 
    ..$ x    : NULL
   - attr(*, "class")= chr [1:2] "Globals" "list"
  
  Expression #7 ('G'):
  {
      y <- square(a)
  }
  Globals: '{', '<-', 'square', 'a'
  Globals: '{', '<-', 'square', 'a', '^'
  List of 5
   $ {     :.Primitive("{") 
   $ <-    :.Primitive("<-") 
   $ square:function (x)  
   $ a     : num 3.14
   $ ^     :function (e1, e2)  
   - attr(*, "where")=List of 5
    ..$ {     :<environment: base> 
    ..$ <-    :<environment: base> 
    ..$ square:<environment: R_GlobalEnv> 
    ..$ a     :<environment: R_GlobalEnv> 
    ..$ ^     :<environment: base> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  
  Expression #8 ('H'):
  {
      b <- a
      a <- 1
  }
  Globals: '{', '<-', 'a'
  Globals: '{', '<-', 'a'
  List of 3
   $ { :.Primitive("{") 
   $ <-:.Primitive("<-") 
   $ a : num 3.14
   - attr(*, "where")=List of 3
    ..$ { :<environment: base> 
    ..$ <-:<environment: base> 
    ..$ a :<environment: R_GlobalEnv> 
   - attr(*, "class")= chr [1:2] "Globals" "list"
  
  > 
  > names <- findGlobals(exprs, method = "liberal", unlist = TRUE)
  > cat(sprintf("Globals: %s\n", paste(sQuote(names), collapse = ", ")))
  Globals: '{', 'Sys.sleep', '<-', '+', 'a', 'file.path', 'dirname', 'url', 'filename', 'c', 'runif', 'rnorm', '*', 'b', 'abs', 'x', 'square'
  > 
  > 
  > ## Cleanup
  > source("incl/end.R")
  > 
  > proc.time()
     user  system elapsed 
     0.37    0.06    0.42