Running 't-browser.R' [167s]
  Running 't-capture.R' [169s]
  Running 't-change.R' [1s]
  Comparing 't-change.Rout' to 't-change.Rout.save' ... OK
  Running 't-demo.R' [185s]
  Running 't-error.R' [1s]
  Comparing 't-error.Rout' to 't-error.Rout.save' ... OK
  Running 't-exec.R' [1s]
  Comparing 't-exec.Rout' to 't-exec.Rout.save' ... OK
  Running 't-get.R' [176s]
  Running 't-global.R' [1s]
  Comparing 't-global.Rout' to 't-global.Rout.save' ... OK
  Running 't-handledruns.R' [156s]
  Running 't-ischecks.R' [168s]
  Running 't-item.R' [147s]
  Running 't-list.R' [161s]
  Running 't-misc.R' [1s]
  Comparing 't-misc.Rout' to 't-misc.Rout.save' ... OK
  Running 't-nav.R' [172s]
  Running 't-parse.R' [177s]
  Running 't-prompt.R' [147s]
  Running 't-random.R' [2s]
  Comparing 't-random.Rout' to 't-random.Rout.save' ... OK
  Running 't-rename.R' [1s]
  Comparing 't-rename.Rout' to 't-rename.Rout.save' ... OK
  Running 't-repairenvs.R' [161s]
  Running 't-search.R' [8s]
  Comparing 't-search.Rout' to 't-search.Rout.save' ... OK
  Running 't-section.R' [173s]
  Running 't-shim.R' [7s]
  Comparing 't-shim.Rout' to 't-shim.Rout.save' ... OK
  Running 't-state.R' [165s]
  Running 't-text.R' [1s]
  Comparing 't-text.Rout' to 't-text.Rout.save' ... OK
  Running 't-translate.R' [3s]
  Comparing 't-translate.Rout' to 't-translate.Rout.save' ... OK
  Running 't-upgrade.R' [135s]
  Running 't-utz1.R' [26s]
  Comparing 't-utz1.Rout' to 't-utz1.Rout.save' ... OK
  Running 't-utz2.R' [137s]
  Running 'zz-check.R' [0s]
Running the tests in 'tests/t-browser.R' failed.
Complete output:
  > source(file.path("_helper", "init.R"))
  > source(file.path("aammrtf", "ref.R")); make_ref_obj_funs("refobjs")
  > 
  > options(unitizer.color = FALSE)
  > zero.env <- parent.env(.GlobalEnv)
  > obj.item <- new("unitizerItem", call = quote(1 + 1), env = new.env())
  > obj.item@data@value <- list(2)
  > obj.item@data@output <- c("two", "dos", "due")
  > obj.item@data@conditions <- new("conditionList", .items = list(simpleError("hello"),
  +     simpleWarning("What a warning")))
  > obj.item@data@message <- vapply(unitizer:::as.list(obj.item@data@conditions),
  +     conditionMessage, character(1L))
  > obj.item@data@aborted <- TRUE
  > 
  > # - "unitizerItem accessor functions work" -------------------------------------
  > 
  > obj.item$value
  [1] 2
  > obj.item$output
  [1] "two" "dos" "due"
  > obj.item$conditions
  Condition list with 2 conditions:
  1. Error: hello
  2. Warning: What a warning
  > 
  > # Create a bunch of expressions for testing
  > 
  > exps1 <- expression(
  +   library(stats),
  +   unitizer_sect("Section 1", {
  +     1 + 1
  +     runif(20)
  +     stop("woohoo")
  +     "I'll be removed"
  +     "I too will be removed"
  +   }),
  +   unitizer_sect("Section 2", {
  +     "I three will be removed"
  +     sample(20)
  + }))
  > exps2 <- expression(
  +   library(stats),
  +   unitizer_sect("Section 1", {
  +     1 + 1
  +     runif(20)
  +     stop("woohoo")
  +     var <- 200
  +     matrix(1:9, 3)
  +     }),
  +   unitizer_sect("Section 2", {
  +     1 + 20
  +     var1 <- list(1, 2, 3)
  +     sample(20)
  +     matrix(1:9, ncol = 3)
  +     lm(x ~ y, data.frame(x = 1:10, y = c(5, 3, 3, 2, 1, 8, 2,
  +         1, 4, 1.5)))
  + }))
  > my.unitizer <- new("unitizer", id = 1, zero.env = zero.env)
  > coi(my.unitizer <- my.unitizer + exps1)
  > my.unitizer2 <- new("unitizer", id = 2, zero.env = zero.env)
  > # make previous items into reference items
  > my.unitizer2 <- my.unitizer2 + my.unitizer@items.new
  > # now add back items to compare
  > coi(my.unitizer2 <- my.unitizer2 + exps2)
  > unitizer.prepped <- unitizer:::browsePrep(my.unitizer2, mode = "unitize")
  > 
  > # NOTE: for some reason, changes in between revisions d9619db and a46e941
  > # should have caused the tests to fail, but didn't.  We did not notice
  > # failures until we ran tests quite a bit later at ca9f540364.  Not sure why
  > # this happened.  The failures were due to the order of tests changing because
  > # we moved ignored tests to be in the same sub-section as the subsequent non-
  > # ignored tests
  > 
  > # - "Can convert to data.frame" ------------------------------------------------
  > 
  > all.equal(unitizer:::as.data.frame(unitizer.prepped), rds("browse_df1"))
  [1] TRUE
  > 
  > # - "unitizerBrowse correctly processes unitizer for display" ------------------
  > 
  > # force all tests to be reviewed so they will be shown
  > unitizer.prepped@mapping@reviewed <-
  +   rep(TRUE, length(unitizer.prepped@mapping@reviewed))
  > unitizer.prepped@mapping@review.val <-
  +   rep("Y", length(unitizer.prepped@mapping@reviewed))
  > all.equal(as.character(unitizer.prepped, 60), rds("browse_aschar1"))
  [1] TRUE
  > 
  > # Alternating tests
  > unitizer.prepped@mapping@reviewed <-
  +   as.logical(seq(length(unitizer.prepped@mapping@reviewed))%%2)
  > all.equal(as.character(unitizer.prepped, 60), rds("browse_aschar2"))
  [1] TRUE
  > 
  > # Errors / warnings
  > try(as.character(unitizer.prepped, -1))           # positive
  Error in .local(x, ...) : 
    Argument `width` must be a positive scalar numeric.
  > prep.narrow <- as.character(unitizer.prepped, 5)  # too small
  Warning in .local(x, ...) :
    Selected display width too small, will be ignored
  > 
  > all.equal(prep.narrow, rds("browse_ascharnarrow"))
  [1] TRUE
  > 
  > # Colors work (should be last in this section) since the reference @global
  > 
  > unitizer.prepped@global$unitizer.opts[["unitizer.color"]] <- TRUE
  > old.opt <- options(crayon.enabled = TRUE)
  > prep.color <- as.character(unitizer.prepped, 60)
  > all.equal(prep.color, rds("browse_aschar3"))
  [1] TRUE
  > unitizer.prepped@global$unitizer.opts[["unitizer.color"]] <- FALSE
  > options(old.opt)
  > 
  > # - "processInput generates Correct Item Structure" ----------------------------
  > 
  > # Here we just test that the calls of each item are what we expect, making
  > # sure that different behavior for Y or N depending on sub-section type is
  > # observed correctly (e.g. a Y for new test means keep it, where as for
  > # removed test means don't keep it)
  > # For debugging:
  > # cbind(substr(unitizer:::deparseCalls(unitizer.prepped), 1, 15), as.character(unitizer.prepped@mapping@review.type), unitizer.prepped@mapping@review.val, unitizer.prepped@mapping@reviewed)
  > # cat(deparse(width=500,
  > #   lapply(
  > #     unitizer:::as.list(unitizer:::processInput(unitizer.prepped)),
  > #     function(x) call("quote", slot(x, "call")))
  > # ) )
  > unitizer.prepped@mapping@reviewed <-
  +   rep(TRUE, length(unitizer.prepped@mapping@reviewed))
  > unitizer.prepped@mapping@review.val <-
  +   rep("Y", length(unitizer.prepped@mapping@reviewed))
  > 
  > # Assume user accepted all tests
  > 
  > lapply(
  +   unitizer:::as.list(unitizer:::processInput(unitizer.prepped)), slot, "call"
  + )
  [[1]]
  library(stats)
  
  [[2]]
  runif(20)
  
  [[3]]
  var <- 200
  
  [[4]]
  matrix(1:9, 3)
  
  [[5]]
  1 + 1
  
  [[6]]
  stop("woohoo")
  
  [[7]]
  var1 <- list(1, 2, 3)
  
  [[8]]
  sample(20)
  
  [[9]]
  1 + 20
  
  [[10]]
  matrix(1:9, ncol = 3)
  
  [[11]]
  lm(x ~ y, data.frame(x = 1:10, y = c(5, 3, 3, 2, 1, 8, 2, 1, 
      4, 1.5)))
  
  > # Assume user accepted all but 1, 4, 6 and 11, note it isn't completely
  > # obvious what should be kept since an N for anything but a new and passed
  > # test will result in some object remaining in the list (typically the
  > # reference copy thereof)
  > unitizer.prepped@mapping@review.val[] <- "N"
  > unitizer.prepped@mapping@review.val[c(2, 6, 8, 12)] <- "Y"
  > lapply(
  +   unitizer:::as.list(unitizer:::processInput(unitizer.prepped)), slot, "call"
  + )
  [[1]]
  runif(20)
  
  [[2]]
  stop("woohoo")
  
  [[3]]
  [1] "I'll be removed"
  
  [[4]]
  sample(20)
  
  [[5]]
  matrix(1:9, ncol = 3)
  
  [[6]]
  [1] "I three will be removed"
  
  > # - "unitizerBrowse subsetting works" ------------------------------------------
  > 
  > # note single bracket subsetting for `unitizerBrowse` overrides the `unitizerList`
  > # subsetting
  > unitizer:::deparseCalls(unitizer:::extractItems(unitizer.prepped[c(4, 8, 10)]))
  [1] "matrix(1:9, 3)"            "\"I too will be removed\""
  [3] "sample(20)"               
  > unitizer:::deparseCalls(unitizer:::extractItems(unitizer.prepped[c(2, 3, 11)]))
  [1] "runif(20)"  "var <- 200" "1 + 20"    
  > 
  > # - "Reference section mapping works" ------------------------------------------
  > 
  > # Copy over just two sections
  > my.unitizer3 <- new("unitizer", id = 3, zero.env = zero.env) +
  +     my.unitizer2@items.new[-(2:6)]
  > # Exclude section two tests
  > # sections should copy over
  > my.unitizer3 <- unitizer:::refSections(my.unitizer3, my.unitizer2)
  > # just copy over 1st and 3rd sections
  > identical(my.unitizer3@sections.ref, my.unitizer2@sections[-2])
  [1] TRUE
  > my.unitizer3@section.ref.map
  [1] 1 2 2 2 2 2
  > 
  > # Make sure "removed" sections are NA when kept
  > unitizer.prepped@mapping@reviewed <-
  +   rep(TRUE, length(unitizer.prepped@mapping@reviewed))
  > # don't delete removed
  > unitizer.prepped@mapping@review.val <-
  +   ifelse(unitizer.prepped@mapping@review.type %in% c("Removed"), "N", "Y")
  > items.processed <- unitizer:::processInput(unitizer.prepped)
  > vapply(unitizer:::as.list(items.processed), slot, 1L, "section.id")
   [1]  1  2  2  2  2  2 NA NA  3  3  3  3  3 NA
  > 
  > # Now try to re-establish sections with removed tests
  > my.unitizer4 <-
  +   new("unitizer", id = 4, zero.env = zero.env) + items.processed
  > # sections should copy over
  > my.unitizer4 <- unitizer:::refSections(my.unitizer4, my.unitizer2)
  > is(my.unitizer4@sections.ref[[4L]], "unitizerSectionNA")
  [1] TRUE
  > my.unitizer4@section.ref.map
   [1] 1 2 2 2 2 2 4 4 3 3 3 3 3 4
  > 
  > # - "Item Extraction" ----------------------------------------------------------
  > 
  > items <- unitizer:::extractItems(unitizer.prepped)
  > item.calls <- vapply(
  +   unitizer:::as.list(items),
  +   function(x)
  +     paste0(deparse(x@call, width.cutoff = 500), collapse = ""), character(1L)
  + )
  > item.types <- vapply(unitizer:::as.list(items), slot, FALSE, "reference")
  > item.ids <- vapply(unitizer:::as.list(items), slot, 1L, "id")
  > item.df <- data.frame(item.calls, item.types, item.ids, stringsAsFactors = FALSE)
  > 
  > all.equal(item.df[order(item.types, item.ids),], rds("browse_itemord"))
  [1] TRUE
  > 
  > proc.time()
     user  system elapsed 
     1.07    0.06    1.14 
Running the tests in 'tests/t-capture.R' failed.
Complete output:
  > source(file.path("_helper", "init.R"))
  > source(file.path("aammrtf", "ref.R")); make_ref_obj_funs("capture")
  > 
  > # # Messing around trying to understand seek...
  > # f <- tempfile()
  > # con <- file(f, "w+b")
  > # writeChar(paste(letters, LETTERS, collapse=" "), con)
  > # readChar(con, 20)
  > # pos <- seek(con, origin="current")
  > # seek(con, pos, rw="write")
  > # writeChar("xxxxxxxxx", con)
  > # readChar(con, 3)
  > # pos <- seek(con, origin="current")
  > # seek(con, pos, rw="write")
  > # writeChar("yyyyy", con)
  > # close(con)
  > # readLines(f)
  > # unlink(f)
  > 
  > # - "get_capture" --------------------------------------------------------------
  > 
  > old.max <- options(unitizer.max.capture.chars = 100L)
  > cons <- new("unitizerCaptCons")
  > base.char <- paste(rep(letters, 10), collapse = " ")
  > writeChar(base.char, cons@out.c)
  > 
  > # Error "Argument `chrs.max`"
  > try(unitizer:::get_text_capture(cons, "output", TRUE, chrs.max = "howdy"))
  Error in unitizer:::get_text_capture(cons, "output", TRUE, chrs.max = "howdy") : 
    Argument `chrs.max` must be integer(1L) and greater than 100L; using 200000L for nowTRUE
  > # Warn max capt
  > cpt0 <- unitizer:::get_text_capture(cons, "output", TRUE)
  Warning in get_text(slot(cons, if (type == "message") "err.c" else "out.c")) :
    Reached maximum text capture characters 100; see `getOption("unitizer.max.capture.chars")`
  > nchar(cpt0)
  [1] 100
  > base.char.2 <- paste(rev(rep(letters, 10)), collapse = " ")
  > writeChar(base.char.2, cons@err.c)
  > sink(cons@err.c, type = "message")
  > 
  > cpt0.err <- unitizer:::get_text_capture(cons, "message", FALSE)
  Warning in get_text(slot(cons, if (type == "message") "err.c" else "out.c")) :
    Reached maximum text capture characters 100; see `getOption("unitizer.max.capture.chars")`
  > sink(type = "message")
  > all.equal(cpt0.err, substr(base.char.2, 1, 100))
  [1] TRUE
  > 
  > ## for some reason this test stopped working; not sure why, need to look into
  > ## it; seemingly it messes up the pointer for the next read
  > # writeChar("xxxxxx", cons@out.c)
  > # cpt2 <- unitizer:::get_text_capture(cons, "output", TRUE)
  > # expect_equal("xxxxxx", cpt2)
  > writeChar(paste0(rep("yyyyyyy", 20L), collapse = ""), cons@out.c)
  > # warn max capt
  > cpt1 <- unitizer:::get_text_capture(cons, "output", TRUE)
  Warning in get_text(slot(cons, if (type == "message") "err.c" else "out.c")) :
    Reached maximum text capture characters 100; see `getOption("unitizer.max.capture.chars")`
  > all.equal(cpt1, paste0(rep("y", 100), collapse = ""))
  [1] TRUE
  > unitizer:::close_and_clear(cons)
  > options(old.max)
  > 
  > # - "get_text" -----------------------------------------------------------------
  > 
  > old.max <- options(unitizer.max.capture.chars = 100L)
  > f <- tempfile()
  > con <- file(f, "w+b")
  > base.char <- paste(letters, collapse = " ")
  > sink(con, type = "message")
  > cat(base.char, file = stderr())
  > # this needs to temporarily switch the sink to be able to issue the warning
  > # Warn: "Reached maximum"
  > unitizer:::get_text(con, 10)
  Warning in unitizer:::get_text(con, 10) :
    Reached maximum text capture characters 10; see `getOption("unitizer.max.capture.chars")`
  [1] "a b c d e "
  > # should still be to writing to our file, 10 chars in
  > cat("boogiewoogy", file = stderr())
  > sink(type = "message")
  > suppressWarnings(readLines(f))  # incomplete final line...
  [1] "a b c d e boogiewoogy l m n o p q r s t u v w x y z"
  > 
  > options(old.max)
  > unlink(f)
  > 
  > # - "connection capture works" -------------------------------------------------
  > 
  > out.num <- as.integer(stdout())
  > err.num <- as.integer(stderr())
  > err.con <- getConnection(sink.number(type = "message"))
  > cons <- new("unitizerCaptCons")
  > cons <- unitizer:::set_capture(cons)
  > cat("hello there\n")
  > cat("goodbye there\n", file = stderr())
  > capt <- unitizer:::get_capture(cons)
  > cons <- unitizer:::unsink_cons(cons)
  > capt
  $output
  [1] "hello there\n"
  
  $message
  [1] "goodbye there\n"
  
  > # expect_identical(as.integer(stdout()), out.num)
  > identical(as.integer(stdout()), out.num)
  [1] TRUE
  > identical(as.integer(stderr()), err.num)
  [1] TRUE
  > unitizer:::close_and_clear(cons)
  > 
  > # Now, here we add an extra stdout sink. In both cases unsink_cons will not
  > # touch the sinks since we're not in an expected state, leaving
  > # close_and_clear to cleanup
  > err.con <- getConnection(sink.number(type = "message"))
  > cons <- new("unitizerCaptCons")
  > cons <- unitizer:::set_capture(cons)
  > cat("there hello\n")
  > # message does not work with testthat
  > cat("there goodbye\n", file = stderr())
  > f1 <- tempfile()
  > f2 <- tempfile()
  > c2 <- file(f2, "w")
  > sink(f1)
  > sink(c2, type = "message")
  > cat("12 there hello\n")
  > # message does not work with testthat
  > cat("12 there goodbye\n", file = stderr())
  > capt <- unitizer:::get_capture(cons)
  > cons <- unitizer:::unsink_cons(cons)
  > unitizer:::close_and_clear(cons)
  > attr(cons@out.c, "waive")
  [1] TRUE
  > attr(cons@err.c, "waive")
  [1] TRUE
  > capt
  $output
  [1] "there hello\n"
  
  $message
  [1] "there goodbye\n"
  
  > readLines(f1)
  [1] "12 there hello"
  > readLines(f2)
  [1] "12 there goodbye"
  > close(c2)
  > unlink(c(f1, f2))
  > 
  > # Same, but this time close the sinks properly, so the connections should not
  > # be waived
  > err.con <- getConnection(sink.number(type = "message"))
  > cons <- new("unitizerCaptCons")
  > cons <- unitizer:::set_capture(cons)
  > cat("there hello\n")
  > # message does not work with testthat
  > cat("there goodbye\n", file = stderr())
  > f1 <- tempfile()
  > f2 <- tempfile()
  > c2 <- file(f2, "w")
  > sink(f1)
  > sink(c2, type = "message")
  > cat("12 there hello\n")
  > # message does not work with testthat
  > cat("12 there goodbye\n", file = stderr())
  > sink()
  > sink(cons@err.c, type = "message")
  > capt <- unitizer:::get_capture(cons)
  > cons <- unitizer:::unsink_cons(cons)
  > attr(cons@out.c, "waive")  # NULL
  NULL
  > attr(cons@err.c, "waive")  # NULL
  NULL
  > capt
  $output
  [1] "there hello\n"
  
  $message
  [1] "there goodbye\n"
  
  > unitizer:::close_and_clear(cons)
  > readLines(f1)
  [1] "12 there hello"
  > readLines(f2)
  [1] "12 there goodbye"
  > close(c2)
  > unlink(c(f1, f2))
  > # Try to mess up sink counter by replacing the real sink with a fake sink
  > # should lead to a waived connection
  > cons <- new("unitizerCaptCons")
  > cons <- unitizer:::set_capture(cons)
  > f1 <- tempfile()
  > sink()
  > sink(f1)
  > capt <- unitizer:::get_capture(cons)
  > cons <- unitizer:::unsink_cons(cons)
  > attr(cons@out.c, "waive")
  > attr(cons@err.c, "waive")
  > capt
  > # Try to fix so that we don't get a full stack release error
  > sink()
  > sink(cons@out.c)
  > unitizer:::close_and_clear(cons)
  > unlink(f1)
  > # helper function
  > f1 <- tempfile()
  > f2 <- tempfile()
  > c1 <- file(f1, "w+b")
  > c2 <- file(f2, "w+b")
  > sink(c2)
  > unitizer:::is_stdout_sink(f1)
  > sink()
  > sink(c1)
  > unitizer:::is_stdout_sink(f1)
  > sink()
  > close(c1)
  > close(c2)
  > unlink(c(f1, f2))
  > 
  > # - "connection breaking tests" ------------------------------------------------
  > 
  > # # These tests cannot be run as they blow away the entire sink stack which can
  > # # mess up any testing done under capture
  > #
  > # test_that("connection breaking tests", {
  > #   # Test the more pernicious error where we substitute the stdout sink
  > #
  > #   cons <- new("unitizerCaptCons")
  > #   cons <- unitizer:::set_capture(cons)
  > #   cat("woohoo\n")
  > #   cat("yohooo\n", file=stderr())
  > #   f1 <- tempfile()
  > #   sink()
  > #   sink(f1)
  > #   capt <- unitizer:::get_capture(cons)
  > #   cons <- unitizer:::unsink_cons(cons)
  > #   sink()
  > #   unlink(f1)
  > #   expect_true(attr(cons@out.c, "waive"))
  > #   expect_null(attr(cons@err.c, "waive"))
  > #   expect_identical(
  > #     capt, list(output = "woohoo\n", message = "yohooo\n")
  > #   )
  > #   expect_identical(
  > #     unitizer:::close_and_clear(cons),
  > #     structure(c(FALSE, TRUE), .Names = c("output", "message"))
  > #   )
  > # })
  > 
  > # - "close_and_clear" ----------------------------------------------------------
  > 
  > # need some careful handling to make sure we don't mess up the testthat's
  > # sinking (legacy behavior)
  > cons <- new("unitizerCaptCons")
  > err.con <- cons@stderr.con
  > on.exit(sink(err.con, type = "message"))
  > # intended to cause an error
  > cons@stderr.con <- list()
  > # msg:  "Unable to restore original "
  > cons.txt <- capture.output(status <- unitizer:::close_and_clear(cons), 
  +     type = "message")
  | Unable to restore original message sink, setting back to normal stderr
  
  > any(grepl("connection", cons.txt))
  [1] TRUE
  > sink(err.con, type = "message")
  > status["message"]
  message 
    FALSE 
  > 
  > # - "eval with capt" -----------------------------------------------------------
  > 
  > suppressWarnings(glob <- unitizer:::unitizerGlobal$new())
  > all.equal(
  +   (capt <- unitizer:::eval_with_capture(quote(1 + 1), global = glob))[1:8],
  +   rds(100)
  + )
  [1] TRUE
  > is(capt[[9]], "unitizerCaptCons")
  [1] TRUE
  > all.equal(
  +   (
  +     capt <- unitizer:::eval_with_capture(
  +       cat("wow\n", file = stderr()), global = glob)
  +   )[1:8],
  +   rds(200)
  + )
  [1] TRUE
  > is(capt[[9]], "unitizerCaptCons")
  [1] TRUE
  > 
  > proc.time()
     user  system elapsed 
     0.62    0.12    0.73 
Running the tests in 'tests/t-demo.R' failed.
Complete output:
  > source(file.path("aammrtf", "mock.R"))
  > source(file.path("_helper", "init.R"))
  > source(file.path("_helper", "pkgs.R"))
  Install Packages
  Setup Demos
  > 
  > # Mostly makes sure the demo steps work, but since it is a convenient way of
  > # generating a unitizer with actual errors and so forth, we use it to test a few
  > # other things as well in the context of those unitizers
  > 
  > # - "in_pkg" -------------------------------------------------------------------
  > 
  > base.dir <- file.path(FLM, "tests", "extra")
  > in.pkg.file <- file.path(base.dir, "inpkg.R")
  > 
  > unitizer:::read_line_set_vals(c("Q"))
  > txt1 <- unitizer:::capture_output(unitize(in.pkg.file, interactive.mode = TRUE))
  > # `sub` needed due to inconsistencies in R 3.4 and 3.3 for top level error
  > # messages
  > txt1$message <- sub("^Error.*:", "", txt1$message)
  > txt1
  - Output -----------------------------------------------------------------------
  
  
  +------------------------------------------------------------------------------+
  | unitizer for: extra/inpkg.R                                                  |
  +------------------------------------------------------------------------------+
  
               Pass Fail  New
   <untitled>     -    -    1
  ...........................
                  -    -    1
  
  - New --------------------------------------------------------------------------
  
  | The following test is new. Add test to store ([Y]es, [N]o, [P]rev, [B]rowse, 
  | [R]erun, [Q]uit, [H]elp)?
  
  # should fail normally, but return TRUE if run in fastlm
  
  > library(utzflm, lib.loc = getOption("unitizer.tmp.lib.loc"))
  > hidden_fun()
  
  unitizer> Q
  
  | unitizer unchanged.
  
  - Message ----------------------------------------------------------------------
  
   could not find function "hidden_fun"
  | No changes recorded.
  > unitizer:::read_line_set_vals(c("Q"))
  > unitize(in.pkg.file, state = in_pkg(), interactive.mode = TRUE)
  
  +------------------------------------------------------------------------------+
  | unitizer for: extra/inpkg.R                                                  |
  +------------------------------------------------------------------------------+
  
               Pass Fail  New
   <untitled>     -    -    1
  ...........................
                  -    -    1
  
  - New --------------------------------------------------------------------------
  
  | The following test is new. Add test to store ([Y]es, [N]o, [P]rev, [B]rowse, 
  | [R]erun, [Q]uit, [H]elp)?
  
  # should fail normally, but return TRUE if run in fastlm
  
  > library(utzflm, lib.loc = getOption("unitizer.tmp.lib.loc"))
  > hidden_fun()
  [1] TRUE
  
  unitizer> Q
  
  | No changes recorded.
  | unitizer unchanged.
  
  > unitizer:::read_line_set_vals(c("Q"))
  > try(unitize(in.pkg.file, state = in_pkg("ASDFASDFA"), interactive.mode = TRUE))
  
  Error in loadNamespace(name) : there is no package called 'ASDFASDFA'
  Error in in_pkg_to_env(x.raw@par.env, test.files) : 
    Unable to load "ASDFASDFA" namespace to use as parent environment; see `?
  unitizerState` for instructions on how to specify a package namespace as a 
  parent environment for tests.
  Error in as.state(state, test.files) : 
    Unable to convert `par.env` value to a namespace environment
  Error in unitize_core(test.file.inf, list(store.id.inf), state = state,  : 
    Argument `state` could not be evaluated.
  > 
  > # - "copy fastlm dir works" ----------------------------------------------------
  > 
  > sort(tolower(list.files(".")))
  [1] "description"   "man"           "namespace"     "r"            
  [5] "tests"         "utzflm.rcheck"
  > readLines(file.path(".", "DESCRIPTION"))[[5L]]  # v0.1.0
  [1] "Version: 0.1.0"
  > update_fastlm(".", version = "0.1.1")
  > readLines(file.path(".", "DESCRIPTION"))[[5L]]
  [1] "Version: 0.1.1"
  > update_fastlm(".", version = "0.1.2")
  > readLines(file.path(".", "DESCRIPTION"))[[5L]]
  [1] "Version: 0.1.2"
  > 
  > # - "show_file" ----------------------------------------------------------------
  > 
  > f <- tempfile()
  > cat("this is a\ntest code\nfile\n", file = f)
  > file.show <- capture.output(show_file(f))
  > file.show[[1L]]
  [1] "+---------------+"
  > start.file <- grep("+---+-----------+", file.show, fixed = TRUE)
  > length(start.file)  # 2
  [1] 2
  > writeLines(file.show[start.file[[1L]]:start.file[[2L]]])
  +---+-----------+
  | 1 | this is a |
  | 2 | test code |
  | 3 | file      |
  +---+-----------+
  > unlink(f)
  > 
  > # Run actual demo bits; note we want to force `interactive.mode=TRUE` so that
  > # `read_line_vals` values are used as user input; note that until we fix
  > # / rationalize how sinking behaves within unitizer when the standard streams
  > # come in sunk, we won't be able to fully test everything, since for example
  > # the display of the captured stdout just won't happen.
  > 
  > # - "demo create worked" -------------------------------------------------------
  > 
  > # In tests, initial version of package should be 0.1.0; the test store
  > # does not exist so it doesn't get overwritten with subsequent updates
  > # Note the initial install happens in the test running script
  > 
  > unitizer:::update_fastlm(".", version = "0.1.0")
  > inst_pak(".")
  > unitizer:::read_line_set_vals(c("Y", "Y", "Y", "Y", "Y"))
  > untz <- unitize(FLM.TEST.FILE, interactive.mode = TRUE)
  
  +------------------------------------------------------------------------------+
  | unitizer for: unitizer/fastlm1.R                                             |
  +------------------------------------------------------------------------------+
  
               Pass Fail  New
   <untitled>     -    -    4
  ...........................
                  -    -    4
  
  - New --------------------------------------------------------------------------
  
  | The 4 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, 
  | [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  # Assignments and calls to `library` are not considered tests by
  # `unitizer` so you will not need to review them
  
  > library(utzflm, lib.loc = getOption("unitizer.tmp.lib.loc"))
  > dat <- data.frame(x = 1:100, y = (1:100)^2)
  > res <- fastlm(dat$x, dat$y)
  
  # The `unitizer>` prompt is like the standard R prompt. You may
  # enter expressions such as `lm(y ~ x, dat)$coefficients`, or
  # `str(res)`.
  #
  # Once you are done reviewing, you need to tell `unitizer` you
  # accept the test by typing 'Y' at the prompt.  Enter 'H' for help.
  
  > res
  intercept     slope       rsq 
  -1717.000   101.000     0.939 
  attr(,"class")
  [1] "fastlm"
  
  unitizer> Y
  
  # There are three more tests to review; accept them with 'Y'
  
  > get_slope(res)
  [1] 101
  
  unitizer> Y
  
  > get_rsq(res)
  [1] 0.939
  
  unitizer> Y
  
  # This last test is expected to cause an error; press 'Y' to
  # accept it so future checks can confirm the same error persists
  
  > fastlm(1:100, 1:10)
  Error in fastlm(1:100, 1:10) : 
    Arguments `x` and `y` must be the same length.
  
  unitizer> Y
  
  = Finalize Unitizer ============================================================
  
  | You will IRREVERSIBLY modify 'unitizer/fastlm1.unitizer' by:
  | - Adding 4 out of 4 new tests
  
  | Update unitizer ([Y]es, [N]o, [P]rev, [B]rowse, [R]erun)?
  
  unitizer> Y
  
  | unitizer updated.
  
  > is(untz, "unitizer_result")
  [1] TRUE
  > print(untz)
  Test File: tests/unitizer/fastlm1.R
  Store ID: tests/unitizer/fastlm1.unitizer
  
    id                           call ignored status user reviewed
  1  1 library(utzflm, lib.loc = g...       *    New    N    FALSE
  2  2 dat <- data.frame(x = 1:100...       *    New    N    FALSE
  3  3    res <- fastlm(dat$x, dat$y)       *    New    N    FALSE
  4  4                            res            New    Y     TRUE
  5  5                 get_slope(res)            New    Y     TRUE
  6  6                   get_rsq(res)            New    Y     TRUE
  7  7            fastlm(1:100, 1:10)            New    Y     TRUE
  > # Re-running doesn't change unitizer
  > untz2 <- unitize(FLM.TEST.FILE, interactive.mode = TRUE)
  
  | 4/4 tests passed; nothing to review.
  
  > print(untz2)
  Test File: tests/unitizer/fastlm1.R
  Store ID: tests/unitizer/fastlm1.unitizer
  
    id                           call ignored status user reviewed
  1  1 library(utzflm, lib.loc = g...       * Passed    Y    FALSE
  2  2 dat <- data.frame(x = 1:100...       * Passed    Y    FALSE
  3  3    res <- fastlm(dat$x, dat$y)       * Passed    Y    FALSE
  4  4                            res         Passed    Y    FALSE
  5  5                 get_slope(res)         Passed    Y    FALSE
  6  6                   get_rsq(res)         Passed    Y    FALSE
  7  7            fastlm(1:100, 1:10)         Passed    Y    FALSE
  
  You chose NOT to save these changes to the unitizer store
  > # Rejecting failed tests does not change unitizer
  > update_fastlm(".", version = "0.1.1")
  > inst_pak(".")
  > 
  > unitizer:::read_line_set_vals(c("N", "N", "Y"))
  > unitizer:::capture_output(
  +   untz3 <- unitize(FLM.TEST.FILE, interactive.mode = TRUE)
  + )
  > print(untz3)
  Test File: tests/unitizer/fastlm1.R
  Store ID: tests/unitizer/fastlm1.unitizer
  
    id                           call ignored status user reviewed
  1  1 library(utzflm, lib.loc = g...       * Failed    N    FALSE
  2  2 dat <- data.frame(x = 1:100...       * Failed    N    FALSE
  3  3    res <- fastlm(dat$x, dat$y)       * Failed    N    FALSE
  4  4                            res         Failed    N     TRUE
  5  5                 get_slope(res)         Failed    N     TRUE
  6  6                   get_rsq(res)         Passed    Y    FALSE
  7  7            fastlm(1:100, 1:10)         Passed    Y    FALSE
  
  You chose NOT to save these changes to the unitizer store
  > 
  > # - "demo review" --------------------------------------------------------------
  > 
  > # review is always in interactive mode
  > unitizer:::read_line_set_vals(c("5", "Q"))
  > review(FLM.TEST.STORE)
  
  +------------------------------------------------------------------------------+
  | unitizer for: tests/unitizer/fastlm1.unitizer                                |
  +------------------------------------------------------------------------------+
  
    *1. library(utzflm, lib.loc = getOption("unitizer.tmp.lib.loc")) .        -:-
    *2. dat <- data.frame(x = 1:100, y = (1:100)^2)   .  .  .  .  .  .        -:-
    *3. res <- fastlm(dat$x, dat$y) .  .  .  .  .  .  .  .  .  .  .  .        -:-
     4. res .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .   Passed:-
     5. get_slope(res)  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .   Passed:-
     6. get_rsq(res) .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .   Passed:-
     7. fastlm(1:100, 1:10)   .  .  .  .  .  .  .  .  .  .  .  .  .  .   Passed:-
  
  | What test do you wish to review (input a test number, [U]nreviewed)?
  
  unitizer> 5
  - Passed -----------------------------------------------------------------------
  
  | The 4 tests in this section passed. Keep tests in store ([Y]es, [N]o, [P]rev, 
  | [B]rowse, [Q]uit, [H]elp)?
  
  # There are three more tests to review; accept them with 'Y'
  
  > get_slope(res)
  [1] 101
  
  unitizer> Q
  
  | No changes recorded.
  | unitizer unchanged.
  
  > 
  > # - "use.diff" -----------------------------------------------------------------
  > 
  > # Use this opportunity to make sure `use.diff=FALSE` works as intended
  > unitizer:::read_line_set_vals("Q")
  > unitize(FLM.TEST.FILE, interactive.mode = TRUE, use.diff = FALSE)
  
  +------------------------------------------------------------------------------+
  | unitizer for: unitizer/fastlm1.R                                             |
  +------------------------------------------------------------------------------+
  
               Pass Fail
   <untitled>     2    2
  ......................
                  2    2
  
  - Failed -----------------------------------------------------------------------
  
  | The 2 tests in this section failed because the new evaluations do not match 
  | the reference values from the store. Overwrite with new results ([Y]es, [N]o, 
  | [P]rev, [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  > library(utzflm, lib.loc = getOption("unitizer.tmp.lib.loc"))
  > dat <- data.frame(x = 1:100, y = (1:100)^2)
  > res <- fastlm(dat$x, dat$y)
  
  # Our fast computations do not produce the same results as our
  # original tests so they fail.  If you need more detail than the
  # provided diff you may use `.new`/`.NEW` or `.ref`/`.REF`.
  #
  # You should reject these tests by typing 'N' at the prompt since
  # they are incorrect.
  
  > res
  intercept     slope       rsq 
  -3.54e+13  7.01e+11  9.39e-01 
  attr(,"class")
  [1] "fastlm"
  
  | Value mismatch: 
  
  [1] "Mean relative difference: 1.99e+10"
  
  | State mismatch; see `.NEW$state` and `.REF$state`.
  
  unitizer> Q
  
  | No changes recorded.
  | unitizer unchanged.
  
  > unitizer:::read_line_set_vals(c(".DIFF$state", "Q"))
  > 
  > unitize(FLM.TEST.FILE, interactive.mode = TRUE, use.diff = FALSE)
  
  +------------------------------------------------------------------------------+
  | unitizer for: unitizer/fastlm1.R                                             |
  +------------------------------------------------------------------------------+
  
               Pass Fail
   <untitled>     2    2
  ......................
                  2    2
  
  - Failed -----------------------------------------------------------------------
  
  | The 2 tests in this section failed because the new evaluations do not match 
  | the reference values from the store. Overwrite with new results ([Y]es, [N]o, 
  | [P]rev, [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  > library(utzflm, lib.loc = getOption("unitizer.tmp.lib.loc"))
  > dat <- data.frame(x = 1:100, y = (1:100)^2)
  > res <- fastlm(dat$x, dat$y)
  
  # Our fast computations do not produce the same results as our
  # original tests so they fail.  If you need more detail than the
  # provided diff you may use `.new`/`.NEW` or `.ref`/`.REF`.
  #
  # You should reject these tests by typing 'N' at the prompt since
  # they are incorrect.
  
  > res
  intercept     slope       rsq 
  -3.54e+13  7.01e+11  9.39e-01 
  attr(,"class")
  [1] "fastlm"
  
  | Value mismatch: 
  
  [1] "Mean relative difference: 1.99e+10"
  
  | State mismatch; see `.NEW$state` and `.REF$state`.
  
  unitizer> .DIFF$state
  | State mismatch:
  
  Attributes: < Component "search.path": 1 string mismatch >
  
  unitizer> Q
  
  | No changes recorded.
  | unitizer unchanged.
  
  > 
  > # - "failing diff" -------------------------------------------------------------
  > 
  > unitizer:::read_line_set_vals("Q")
  > mock(diffobj::diffObj, quote(stop("A failing diff.")))
  > unitize(FLM.TEST.FILE, interactive.mode = TRUE)
  
  +------------------------------------------------------------------------------+
  | unitizer for: unitizer/fastlm1.R                                             |
  +------------------------------------------------------------------------------+
  
               Pass Fail
   <untitled>     2    2
  ......................
                  2    2
  
  - Failed -----------------------------------------------------------------------
  
  | The 2 tests in this section failed because the new evaluations do not match 
  | the reference values from the store. Overwrite with new results ([Y]es, [N]o, 
  | [P]rev, [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  > library(utzflm, lib.loc = getOption("unitizer.tmp.lib.loc"))
  > dat <- data.frame(x = 1:100, y = (1:100)^2)
  > res <- fastlm(dat$x, dat$y)
  
  # Our fast computations do not produce the same results as our
  # original tests so they fail.  If you need more detail than the
  # provided diff you may use `.new`/`.NEW` or `.ref`/`.REF`.
  #
  # You should reject these tests by typing 'N' at the prompt since
  # they are incorrect.
  
  > res
  intercept     slope       rsq 
  -3.54e+13  7.01e+11  9.39e-01 
  attr(,"class")
  [1] "fastlm"
  
  Error in diffObj(curr.err@.ref, curr.err@.new, tar.banner = make_cont(".ref"),  : 
    A failing diff.
  | Value: <diff failed>
  
  | State mismatch; see `.DIFF$state` for details.
  
  unitizer> Q
  
  | No changes recorded.
  | unitizer unchanged.
  
  > unmock(diffobj::diffObj)
  > 
  > # - "multi-accept" -------------------------------------------------------------
  > 
  > # Test what happens if we back out of a multi-accept
  > 
  > unitizer:::read_line_set_vals(c("YY", "N", "Q"))
  > unitize(FLM.TEST.FILE, interactive.mode = TRUE)
  
  +------------------------------------------------------------------------------+
  | unitizer for: unitizer/fastlm1.R                                             |
  +------------------------------------------------------------------------------+
  
               Pass Fail
   <untitled>     2    2
  ......................
                  2    2
  
  - Failed -----------------------------------------------------------------------
  
  | The 2 tests in this section failed because the new evaluations do not match 
  | the reference values from the store. Overwrite with new results ([Y]es, [N]o, 
  | [P]rev, [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  > library(utzflm, lib.loc = getOption("unitizer.tmp.lib.loc"))
  > dat <- data.frame(x = 1:100, y = (1:100)^2)
  > res <- fastlm(dat$x, dat$y)
  
  # Our fast computations do not produce the same results as our
  # original tests so they fail.  If you need more detail than the
  # provided diff you may use `.new`/`.NEW` or `.ref`/`.REF`.
  #
  # You should reject these tests by typing 'N' at the prompt since
  # they are incorrect.
  
  > res
  intercept     slope       rsq 
  -3.54e+13  7.01e+11  9.39e-01 
  attr(,"class")
  [1] "fastlm"
  
  | Value mismatch: 
  
  < .ref                            > .new                          
  @@ 1,4 @@                         @@ 1,4 @@                       
    intercept     slope       rsq     intercept     slope       rsq 
  < -1717.000   101.000     0.939   > -3.54e+13  7.01e+11  9.39e-01 
    attr(,"class")                    attr(,"class")                
    [1] "fastlm"                      [1] "fastlm"                  
  
  | State mismatch; see `.DIFF$state` for details.
  
  unitizer> YY
  
    4. res .  .  .  .  .  Failed:-
    5. get_slope(res)  .  Failed:-
  
  Choose 'Y' for the 2 tests shown above ([Y]es, [N]o)?
  unitizer> N
  
  
  # Our fast computations do not produce the same results as our
  # original tests so they fail.  If you need more detail than the
  # provided diff you may use `.new`/`.NEW` or `.ref`/`.REF`.
  #
  # You should reject these tests by typing 'N' at the prompt since
  # they are incorrect.
  
  > res
  intercept     slope       rsq 
  -3.54e+13  7.01e+11  9.39e-01 
  attr(,"class")
  [1] "fastlm"
  
  | Value mismatch: 
  
  < .ref                            > .new                          
  @@ 1,4 @@                         @@ 1,4 @@                       
    intercept     slope       rsq     intercept     slope       rsq 
  < -1717.000   101.000     0.939   > -3.54e+13  7.01e+11  9.39e-01 
    attr(,"class")                    attr(,"class")                
    [1] "fastlm"                      [1] "fastlm"                  
  
  | State mismatch; see `.DIFF$state` for details.
  
  unitizer> Q
  
  | No changes recorded.
  | unitizer unchanged.
  
  > 
  > # - "multi-input" --------------------------------------------------------------
  > 
  > # Or if we request to go to unreviewed when there are none
  > unitizer:::read_line_set_vals(c("YY", "Y", "B", "U", "Q"))
  > unitize(FLM.TEST.FILE, interactive.mode = TRUE)
  
  +------------------------------------------------------------------------------+
  | unitizer for: unitizer/fastlm1.R                                             |
  +------------------------------------------------------------------------------+
  
               Pass Fail
   <untitled>     2    2
  ......................
                  2    2
  
  - Failed -----------------------------------------------------------------------
  
  | The 2 tests in this section failed because the new evaluations do not match 
  | the reference values from the store. Overwrite with new results ([Y]es, [N]o, 
  | [P]rev, [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  > library(utzflm, lib.loc = getOption("unitizer.tmp.lib.loc"))
  > dat <- data.frame(x = 1:100, y = (1:100)^2)
  > res <- fastlm(dat$x, dat$y)
  
  # Our fast computations do not produce the same results as our
  # original tests so they fail.  If you need more detail than the
  # provided diff you may use `.new`/`.NEW` or `.ref`/`.REF`.
  #
  # You should reject these tests by typing 'N' at the prompt since
  # they are incorrect.
  
  > res
  intercept     slope       rsq 
  -3.54e+13  7.01e+11  9.39e-01 
  attr(,"class")
  [1] "fastlm"
  
  | Value mismatch: 
  
  < .ref                            > .new                          
  @@ 1,4 @@                         @@ 1,4 @@                       
    intercept     slope       rsq     intercept     slope       rsq 
  < -1717.000   101.000     0.939   > -3.54e+13  7.01e+11  9.39e-01 
    attr(,"class")                    attr(,"class")                
    [1] "fastlm"                      [1] "fastlm"                  
  
  | State mismatch; see `.DIFF$state` for details.
  
  unitizer> YY
  
    4. res .  .  .  .  .  Failed:-
    5. get_slope(res)  .  Failed:-
  
  Choose 'Y' for the 2 tests shown above ([Y]es, [N]o)?
  unitizer> Y
  
  = Finalize Unitizer ============================================================
  
  | You will IRREVERSIBLY modify 'unitizer/fastlm1.unitizer' by:
  | - Replacing 2 out of 2 failed tests
  
  | Update unitizer ([Y]es, [N]o, [P]rev, [B]rowse, [R]erun)?
  
  unitizer> B
  
    *1. library(utzflm, lib.loc = getOption("unitizer.tmp.lib.loc")) .        -:-
    *2. dat <- data.frame(x = 1:100, y = (1:100)^2)   .  .  .  .  .  .        -:-
    *3. res <- fastlm(dat$x, dat$y) .  .  .  .  .  .  .  .  .  .  .  .        -:-
     4. res .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .   Failed:Y
     5. get_slope(res)  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .   Failed:Y
     6. get_rsq(res) .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .   Passed:-
     7. fastlm(1:100, 1:10)   .  .  .  .  .  .  .  .  .  .  .  .  .  .   Passed:-
  
  | What test do you wish to review (input a test number, [U]nreviewed)?
  
  unitizer> U
  
  | No unreviewed tests.
  
  = Finalize Unitizer ============================================================
  
  | You will IRREVERSIBLY modify 'unitizer/fastlm1.unitizer' by:
  | - Replacing 2 out of 2 failed tests
  
  | Update unitizer ([Y]es, [N]o, [P]rev, [B]rowse, [R]erun)?
  
  unitizer> Q
  
  | Changes discarded.
  | unitizer unchanged.
  
  > 
  > # - "warn in parse" ------------------------------------------------------------
  > 
  > # Make sure parse warnings are issued
  > unitizer:::read_line_set_vals(c("-2147483648L", "Q"))
  > txt8 <- unitizer:::capture_output(unitize(FLM.TEST.FILE,
  +     interactive.mode = TRUE))
  > 
  > any(grepl("qualified with L", txt8$message))
  [1] TRUE
  > 
  > # - "demo changes" -------------------------------------------------------------
  > #
  > # Now actually accept the changes
  > unitizer:::read_line_set_vals(c("Y", "Y", "Y"))
  > untz5 <- unitize(FLM.TEST.FILE, interactive.mode = TRUE)
  
  +------------------------------------------------------------------------------+
  | unitizer for: unitizer/fastlm1.R                                             |
  +------------------------------------------------------------------------------+
  
               Pass Fail
   <untitled>     2    2
  ......................
                  2    2
  
  - Failed -----------------------------------------------------------------------
  
  | The 2 tests in this section failed because the new evaluations do not match 
  | the reference values from the store. Overwrite with new results ([Y]es, [N]o, 
  | [P]rev, [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  > library(utzflm, lib.loc = getOption("unitizer.tmp.lib.loc"))
  > dat <- data.frame(x = 1:100, y = (1:100)^2)
  > res <- fastlm(dat$x, dat$y)
  
  # Our fast computations do not produce the same results as our
  # original tests so they fail.  If you need more detail than the
  # provided diff you may use `.new`/`.NEW` or `.ref`/`.REF`.
  #
  # You should reject these tests by typing 'N' at the prompt since
  # they are incorrect.
  
  > res
  intercept     slope       rsq 
  -3.54e+13  7.01e+11  9.39e-01 
  attr(,"class")
  [1] "fastlm"
  
  | Value mismatch: 
  
  < .ref                            > .new                          
  @@ 1,4 @@                         @@ 1,4 @@                       
    intercept     slope       rsq     intercept     slope       rsq 
  < -1717.000   101.000     0.939   > -3.54e+13  7.01e+11  9.39e-01 
    attr(,"class")                    attr(,"class")                
    [1] "fastlm"                      [1] "fastlm"                  
  
  | State mismatch; see `.DIFF$state` for details.
  
  unitizer> Y
  
  # This one is also incorrect; reject with 'N'
  
  > get_slope(res)
  [1] 7.01e+11
  
  | Value mismatch: 
  
  < .ref          > .new        
  @@ 1 @@         @@ 1 @@       
  < [1] 101       > [1] 7.01e+11
  
  | State mismatch; see `.DIFF$state` for details.
  
  unitizer> Y
  
  = Finalize Unitizer ============================================================
  
  | You will IRREVERSIBLY modify 'unitizer/fastlm1.unitizer' by:
  | - Replacing 2 out of 2 failed tests
  
  | Update unitizer ([Y]es, [N]o, [P]rev, [B]rowse, [R]erun)?
  
  unitizer> Y
  
  | unitizer updated.
  
  > unitizer:::read_line_set_vals(NULL)
  > 
  > # - "get_package_dir" ----------------------------------------------------------
  > 
  > # These were in t-get but we moved them here to avoid re-loading pkgs.R
  > 
  > unitizer:::get_package_dir(f)  # empty
  character(0)
  > test.dir.1 <- file.path(".", "utzflm.Rcheck", "utzflm", "R")
  > identical(
  +   unitizer:::get_package_dir(test.dir.1),
  +   normalizePath(dirname(test.dir.1), winslash = "/")
  + )
  [1] TRUE
  > test.dir.2 <- file.path(".", "utzflm.Rcheck")
  > identical(
  +   unitizer:::get_package_dir(file.path(test.dir.2, "tests", "tests.R")),
  +   normalizePath(file.path(test.dir.2, "utzflm"), winslash = "/")
  + )
  [1] TRUE
  > 
  > proc.time()
     user  system elapsed 
     5.82    0.56   15.61 
Running the tests in 'tests/t-get.R' failed.
Complete output:
  > source(file.path("_helper", "init.R"))
  > source(file.path("aammrtf", "mock.R"))
  > 
  > toy.path <- file.path("_helper", "unitizers", "misc.unitizer")
  > toy.stor <- readRDS(file.path(toy.path, "data.rds"))
  > 
  > # - "Error Cases" --------------------------------------------------------------
  > 
  > try(get_unitizer(1))
  Error in get_unitizer.default(1) : 
    No method defined for object of class "numeric"; make sure that the specified `store.id` is a reference to a valid unitizer store and had defined `get_unitizer` and `set_unitizer` methods.
  > try(get_unitizer(letters))
  Error in get_unitizer.character(letters) : 
    Argument `store.id` must be a 1 length character vector
  > try(get_unitizer("_helper"))
  Error in get_unitizer.character("_helper") : 
    Argument `store.id` does not appear to refer to a unitizer directory
  > try(get_unitizer("t-get.R"))
  Error in get_unitizer.character("t-get.R") : 
    Argument `store.id` does not appear to refer to a unitizer directory
  > try(set_unitizer(1))
  Error in set_unitizer.default(1) : 
    No method defined for object of class "numeric"; make sure that the specified `store.id` is a reference to a valid unitizer store and had defined `get_unitizer` and `set_unitizer` methods.
  > try(set_unitizer(letters))
  Error in set_unitizer.character(letters) : 
    Argument `store.id` must be a 1 length character vector
  > # 4.3 changed reporting of missing argument errors
  > tryCatch(set_unitizer("a"), error=function(e) conditionMessage(e))
  [1] "argument \"unitizer\" is missing, with no default"
  > try(set_unitizer("a", "blergh"))
  Error in set_unitizer.character("a", "blergh") : 
    Argument `unitizer` must be a unitizer
  > !file.exists("a") # TRUE
  [1] TRUE
  > try(suppressWarnings(set_unitizer("tests/# ;!./# \\/", toy.stor)))
  Error in set_unitizer.character("tests/# ;!./# \\/", toy.stor) : 
    Could not create `store.id`; make sure it is a valid file name; see warning for details
  > 
  > # - "Get works as expected" ----------------------------------------------------
  > 
  > tmp.dir <- tempfile()
  > dir.create(tmp.dir)
  > tmp.sub.dir <- paste0(tmp.dir, "/get.test.dir")
  > tmp.fake.utz <- paste0(tmp.dir, "/fake.unitizer")
  > 
  > # expect_false(get_unitizer("asldkfjskfa"))
  > get_unitizer("asldkfjskfa") # FALSE
  [1] FALSE
  > all.equal(get_unitizer(toy.path), toy.stor)
  [1] TRUE
  > is(toy.stor, "unitizer")
  [1] TRUE
  > dir.create(tmp.fake.utz)
  > fake.utz <- file.path(tmp.fake.utz, "data.rds")
  > cat("# this is not an RDS\n", file = fake.utz)
  > # expect_error(capture.output(get_unitizer(tmp.fake.utz), type = "message"),
  > #     "Failed loading unitizer")
  > try(capture.output(get_unitizer(tmp.fake.utz), type = "message"))
  Error in get_unitizer.character(tmp.fake.utz) : 
    Failed loading unitizer; see prior error messages for details
  > 
  > tmp.sub.dir <- paste0(tmp.dir, "/get.test.dir")
  > tmp.sub.dir2 <- paste0(tmp.dir, "/get.test.dir2")
  > tmp.sub.dir3 <- paste0(tmp.dir, "/load.dirs")
  > 
  > # - "Set works as expected" ----------------------------------------------------
  > 
  > dir.create(tmp.sub.dir)
  > set_unitizer(tmp.sub.dir, toy.stor)
  [1] TRUE
  > all.equal(readRDS(paste0(tmp.sub.dir, "/data.rds")), toy.stor)
  [1] TRUE
  > just.a.file <- tempfile()
  > on.exit(unlink(just.a.file))
  > cat("just a file\n", file = just.a.file)
  > err <- capture.output(try(set_unitizer(just.a.file, toy.stor)), type='message')
  > any(grepl('not a directory', err))
  [1] TRUE
  > 
  > # - "load/store_unitizer" ------------------------------------------------------
  > 
  > # Several different stores in different states (i.e. requiring upgrade,
  > # not unitizers, etc.)
  > dir.create(tmp.sub.dir3)
  > make.path <- lapply(file.path(tmp.sub.dir3, dir("_helper/ref-objs/load/")),
  +     dir.create)
  > if (!all(unlist(make.path))) stop("Failed making paths")
  > file.copy(list.files("_helper/ref-objs/load", full.names = TRUE), tmp.sub.dir3,
  +     recursive = TRUE)
  [1] TRUE TRUE TRUE TRUE TRUE TRUE
  > par.frame <- new.env()
  > store.ids <- as.list(list.files(tmp.sub.dir3, full.names = TRUE))
  > 
  > # must be upgraded, but cannot
  > load.try <- unitizer:::capture_output(
  +   try(
  +     unitizer:::load_unitizers(store.ids, rep(NA_character_,
  +       length(store.ids)), par.frame = par.frame, interactive.mode = FALSE,
  +       mode = "unitize", force.upgrade = FALSE, show.progress=0L, transcript=FALSE
  + ) ) )
  > any(grepl('could not be loaded', load.try$message))
  [1] TRUE
  > any(grepl('could not be upgraded', load.try$message))
  [1] TRUE
  > any(grepl('Cannot proceed', load.try$message))
  [1] TRUE
  > 
  > # handle failure in store_unitizer, we just try this on one of the store ids
  > 
  > out <- unitizer:::capture_output(
  +   unitizer:::load_unitizers(
  +     store.ids[4], rep(NA_character_, length(store.ids))[4],
  +     par.frame = par.frame, interactive.mode = FALSE, mode = "unitize",
  +     force.upgrade = TRUE, show.progress=0L, transcript=FALSE
  +   )
  + )
  > any(grepl('Upgraded test file does not match original', out$message))
  [1] TRUE
  > 
  > # try weird store ids
  > out <- unitizer:::capture_output(
  +   invalid.store <- try(
  +     unitizer:::load_unitizers(
  +       list(structure("hello", class = "unitizer_error_store")),
  +       NA_character_, par.frame = par.frame,
  +       interactive.mode = FALSE, mode = "unitize", force.upgrade = FALSE,
  +       show.progress=0L, transcript=FALSE
  +   ) )
  + )
  > inherits(invalid.store, "try-error")
  [1] TRUE
  > any(grepl("returned something other than", out$message))
  [1] TRUE
  > 
  > # Load mix of loadable and not loadable objects
  > glob <- suppressWarnings(unitizer:::unitizerGlobal$new())
  > # with warning: "does not exist|test file does not")
  > out <- unitizer:::capture_output(
  +   untzs <- try(
  +     unitizer:::load_unitizers(
  +       store.ids, rep(NA_character_, length(store.ids)), par.frame = par.frame,
  +       interactive.mode = FALSE, mode = "unitize", force.upgrade = TRUE,
  +       global = glob, show.progress=0L, transcript=FALSE
  + ) ) )
  > inherits(untzs, "try-error")
  [1] TRUE
  > any(grepl('could not be loaded', out$message))
  [1] TRUE
  > any(grepl('could not be upgraded', out$message))
  [1] TRUE
  > any(grepl('Cannot proceed', out$message))
  [1] TRUE
  > 
  > # Test failure of storage of a loaded and upgraded unitizers
  > 
  > untzs <- unitizer:::load_unitizers(
  +   store.ids[4], NA_character_, par.frame = par.frame,
  +   interactive.mode = FALSE, mode = "unitize", force.upgrade = TRUE,
  +   global = glob, show.progress=0L, transcript=FALSE
  + )
  Warning in addSlot(object, "cons", NULL) :
    Slot `cons` does not exist in current version of `unitizer` so not added to object.
  Warning in addSlot(object, "jump.to.test", 0L) :
    Slot `jump.to.test` does not exist in current version of `unitizer` so not added to object.
  Warning in unitizer:::load_unitizers(store.ids[4], NA_character_, par.frame = par.frame,  :
    Upgraded test file does not match original test file ('internals.R' vs 'NA').
  > mock(unitizer:::set_unitizer, quote(stop("set fail")))
  > try(unitizer:::store_unitizer(untzs[[1]]))
  Error in set_unitizer(unitizer@id, unitizer) : set fail
  Error in unitizer:::store_unitizer(untzs[[1]]) : 
    Error attempting to save unitizer, see previous messages.
  > unmock(unitizer:::set_unitizer)
  > 
  > # Try reloading already loaded unitisers
  > reload <- unitizer:::as.list(untzs)
  > # this creates a global object, hence warning
  > untzs1a <- unitizer:::load_unitizers(
  +   reload, rep(NA_character_, length(reload)), par.frame = par.frame,
  +   interactive.mode = FALSE, mode = "unitize", force.upgrade = FALSE,
  +   show.progress=0L, transcript=FALSE
  + )
  Warning in .Object$initialize(...) :
    Instantiated global object without global namespace registry; you should only see this warning you are using `repair_environments`.
  > all(vapply(unitizer:::as.list(untzs1a), is, logical(1L), "unitizer"))
  [1] TRUE
  > 
  > # misc tests
  > # warning Instantiated global object without
  > 
  > untzs2 <- unitizer:::load_unitizers(
  +   list(tmp.sub.dir2), NA_character_, par.frame, interactive.mode = FALSE,
  +   mode = "unitize", force.upgrade = FALSE, show.progress=0L, transcript=FALSE
  + )
  Warning in .Object$initialize(...) :
    Instantiated global object without global namespace registry; you should only see this warning you are using `repair_environments`.
  > is(untzs2[[1L]], "unitizer")
  [1] TRUE
  > identical(parent.env(untzs2[[1L]]@zero.env), par.frame)
  [1] TRUE
  > 
  > # something that won't get reset on load so we can check our re-load
  > untzs2[[1L]]@eval.time <- 33
  > unitizer:::store_unitizer(untzs2[[1L]])
  | unitizer updated.
  
  > 
  > # warning Instantiated global object without
  > untzs2.1 <- unitizer:::load_unitizers(
  +   list(tmp.sub.dir2), NA_character_, par.frame, interactive.mode = FALSE,
  +   mode = "unitize", force.upgrade = FALSE, show.progress=0L, transcript=FALSE
  + )
  Warning in .Object$initialize(...) :
    Instantiated global object without global namespace registry; you should only see this warning you are using `repair_environments`.
  > untzs2.1[[1L]]@eval.time # 33
  [1] 33
  > unlink(c(tmp.sub.dir2, tmp.sub.dir3, tmp.sub.dir), recursive = TRUE)
  > 
  > # - "is_package" ---------------------------------------------------------------
  > 
  > unitizer:::is_package_dir(system.file(package = "stats"))
  [1] TRUE
  > unitizer:::is_package_dir(system.file(package = "methods"))
  [1] TRUE
  > 
  > ## Seems like some change now tests no longer installed by default with
  > ## packages, at least in the unix distros, so can't easily test with
  > ## has.tests==TRUE
  > 
  > unitizer:::pretty_path(file.path(system.file(package = "stats"),
  +     "DESCRIPTION"))
  [1] "package:stats/DESCRIPTION"
  > old.wd <- getwd()
  > setwd(system.file(package = "stats"))
  > unitizer:::pretty_path(file.path(system.file(package = "stats"), "DESCRIPTION"))
  [1] "DESCRIPTION"
  > unitizer:::pretty_path(file.path(system.file(package = "stats")))
  [1] "."
  > setwd(old.wd)
  > 
  > # just picked some folder we know will not work (No Desc)
  > unitizer:::is_package_dir(file.path(system.file(package = "stats"), "R"))
  [1] "No DESCRIPTION file"
  > unitizer:::is_package_dir("ASDFASDF")
  [1] "not an existing directory"
  > unitizer:::is_package_dir(file.path(system.file(package = "unitizer"),
  +     "expkg", "baddescription1"))
  [1] "DESCRIPTION file did not have a package name entry"
  > # *get_*package_dir
  > pkg.f <- file.path(system.file(package = "unitizer"), "tests",
  +     "interactive", "run.R")
  > length(unitizer:::get_package_dir(pkg.f)) == 1L
  [1] TRUE
  > length(unitizer:::get_package_dir(dirname(pkg.f))) == 1L
  [1] TRUE
  > f <- tempfile()
  > cat("helloworld", file = f)
  > length(unitizer:::get_package_dir(f)) == 0L
  [1] TRUE
  > unlink(f)
  > 
  > # some more tests moved to t-demo.R to avoid reloading pkgs
  > 
  > # - "is_unitizer_dir" ----------------------------------------------------------
  > 
  > base.dir <- file.path(system.file(package = "unitizer"), "expkg", "infer")
  > unitizer:::is_unitizer_dir(base.dir) # FALSE
  [1] FALSE
  > unitizer:::is_unitizer_dir(
  +   file.path(base.dir, "tests", "unitizer", "infer.unitizer")
  + )
  [1] TRUE
  > # - "infer_unitizer_location" --------------------------------------------------
  > 
  > infer <- function(...) infer_unitizer_location(..., interactive.mode = FALSE)
  > base.dir <- file.path(system.file(package = "unitizer"), "expkg", "infer")
  > 
  > # Verify package is still in state we built tests on; need to sort b/c
  > # different platforms have different lexical sorts
  > identical(
  +   sort(c("aaa.R", "aaa.unitizer", "abc.R", "abc.unitizer", "inf.R",
  +       "inf.unitizer", "infer.R", "infer.unitizer", "zzz.R", "zzz.unitizer")),
  +   list.files(file.path(base.dir, "tests", "unitizer"))
  + )
  [1] TRUE
  > # Package dir
  > unitizer:::capture_output(inf <- infer(base.dir))
  > basename(inf)
  [1] "infer.R"
  > unitizer:::capture_output(inf <- infer(base.dir, type = "d"))
  > basename(inf)
  [1] "unitizer"
  > unitizer:::capture_output(inf <- infer(base.dir, type = "u"))
  > basename(inf)
  [1] "infer.unitizer"
  > 
  > inf.dir <- infer(file.path(base.dir, "*")) # warn
  Warning in infer_unitizer_location.character(..., interactive.mode = FALSE) :
    5 possible targets; too many to unambiguously infer desired file
  > identical(file.path(base.dir, "*"), inf.dir)
  [1] TRUE
  > 
  > unitizer:::capture_output(inf <- infer(file.path(base.dir, "z")))
  > basename(inf)
  [1] "zzz.R"
  > unitizer:::capture_output(inf <- infer(file.path(base.dir, "z"), type = "u"))
  > basename(inf)
  [1] "zzz.unitizer"
  > 
  > # Normal dir
  > base.dir2 <- file.path(base.dir, "tests", "unitizer")
  > # note don't need * to generate warning
  > out <- unitizer:::capture_output(inf.dir2 <- infer(base.dir2))  # warn
  > any(grepl("5 possible targets", out$message))
  [1] TRUE
  > identical(base.dir2, inf.dir2)
  [1] TRUE
  > out <- unitizer:::capture_output(infer(file.path(base.dir2, "a")))
  > any(grepl("2 possible targets", out$message))
  [1] TRUE
  > out <- unitizer:::capture_output(infer(file.path(base.dir2, "a"), type = "u"))
  > any(grepl("2 possible targets", out$message))
  [1] TRUE
  > out <-
  +   unitizer:::capture_output(fname <- basename(infer(file.path(base.dir2, "z"))))
  > fname
  [1] "zzz.R"
  > any(grepl('Inferred test file location:', out))
  [1] TRUE
  > out <- unitizer:::capture_output(
  +   fname <- basename(infer(file.path(base.dir2, "z"), type="u"))
  + )
  > fname
  [1] "zzz.unitizer"
  > any(grepl('Inferred unitizer location:', out))
  [1] TRUE
  > 
  > # Random file without setting working dir first, in order for this to work
  > # non-interactivel we need it to work with the R CMD check dir structure,
  > # and possibly with the covr dir structure
  > if (interactive())  infer("tests2")
  > 
  > # Interactive mode
  > unitizer:::read_line_set_vals(c("26", "Q"))
  > # warn/output
  > select <- unitizer:::infer_unitizer_location(
  +   file.path(base.dir, "*"), type = "f", interactive.mode = TRUE
  + )
  Possible matching files from "tests/unitizer":
    1: aaa.R
    2: abc.R
    3: inf.R
    4: infer.R
    5: zzz.R
  unitizer> 26
  | Type a number in `1:5` at the prompt
  [1] 26
  unitizer> Q
  
  No file selected
  Warning in infer_unitizer_location.character(file.path(base.dir, "*"), type = "f",  :
    Invalid user selection
  > identical(select, file.path(base.dir, "*"))
  [1] TRUE
  > 
  > unitizer:::read_line_set_vals(c("5"))
  > # output
  > sel.loc <- unitizer:::infer_unitizer_location(file.path(base.dir,
  +     "*"), type = "f", interactive.mode = TRUE)
  Possible matching files from "tests/unitizer":
    1: aaa.R
    2: abc.R
    3: inf.R
    4: infer.R
    5: zzz.R
  unitizer> 5
  Selected file: zzz.R
  > basename(sel.loc)
  [1] "zzz.R"
  > unitizer:::read_line_set_vals(NULL)
  > 
  > # Non standard inferences
  > # warn
  > out <- unitizer:::capture_output(
  +   unitizer:::infer_unitizer_location(NULL, interactive = FALSE)
  + )
  > any(grepl("too many to unambiguously", out$message))
  [1] TRUE
  > 
  > fake.class <- structure(list(), class = "thisclassdoesn'texist")
  > identical(infer(fake.class), fake.class)
  [1] TRUE
  > 
  > # no match since file can't exist (warn)
  > f <- tempfile()
  > out <- capture.output(
  +   invisible(unitizer:::infer_unitizer_location(f)), type='message'
  + )
  > any(grepl("No possible matching files", out))
  [1] TRUE
  > 
  > 
  > unlink(tmp.dir, recursive = TRUE)
  > 
  > 
  > proc.time()
     user  system elapsed 
     1.75    0.20    1.93 
Running the tests in 'tests/t-handledruns.R' failed.
Complete output:
  > source(file.path("_helper", "init.R"))
  > 
  > # - "Ensure we get warning if we try to run in handlers" -----------------------
  > 
  > try(unitize("_helper/unitizers/trivial.R"))
  
  Warning in check_call_stack() :
    It appears you are running unitizer inside an error handling function such as 
  `withCallingHanlders`, `tryCatch`, or `withRestarts`.  This is strongly dis-
  couraged as it may cause unpredictable behavior from unitizer in the event tests
  produce conditions / errors.  We strongly recommend you re-run your tests 
  outside of such handling functions.
  Warning in history_capt(history, interactive.mode) :
    Unable to capture history in non-interactive mode.
  | 4/4 tests passed; nothing to review.
  
  > tryCatch(unitize("_helper/unitizers/trivial.R"))
  
  Warning in check_call_stack() :
    It appears you are running unitizer inside an error handling function such as 
  `withCallingHanlders`, `tryCatch`, or `withRestarts`.  This is strongly dis-
  couraged as it may cause unpredictable behavior from unitizer in the event tests
  produce conditions / errors.  We strongly recommend you re-run your tests 
  outside of such handling functions.
  Warning in history_capt(history, interactive.mode) :
    Unable to capture history in non-interactive mode.
  | 4/4 tests passed; nothing to review.
  
  > withRestarts(unitize("_helper/unitizers/trivial.R"))
  
  Warning in check_call_stack() :
    It appears you are running unitizer inside an error handling function such as 
  `withCallingHanlders`, `tryCatch`, or `withRestarts`.  This is strongly dis-
  couraged as it may cause unpredictable behavior from unitizer in the event tests
  produce conditions / errors.  We strongly recommend you re-run your tests 
  outside of such handling functions.
  Warning in history_capt(history, interactive.mode) :
    Unable to capture history in non-interactive mode.
  | 4/4 tests passed; nothing to review.
  
  > 
  > # need to figure out why running this without `try` in covr causes cover to
  > # fail with
  > # Error in aggregate.data.frame(mf[1L], mf[-1L], FUN = FUN, ...) :
  > #   no rows to aggregate
  > 
  > # - "Ensure we get error if we try to do something stupid..." ------------------
  > 
  > try(
  +   withRestarts(
  +     unitize("_helper/unitizers/trivial.R"), 
  +     unitizerInteractiveFail = function() NULL
  +   )
  + )
  
  Warning in check_call_stack() :
    It appears you are running unitizer inside an error handling function such as 
  `withCallingHanlders`, `tryCatch`, or `withRestarts`.  This is strongly dis-
  couraged as it may cause unpredictable behavior from unitizer in the event tests
  produce conditions / errors.  We strongly recommend you re-run your tests 
  outside of such handling functions.
  Error in check_call_stack() : 
    "unitizerInteractiveFail" restart is already defined; unitizer relies on this 
  restart to manage evaluation so unitizer will not run if it is defined outside 
  of `unitize`.  If you did not define this restart contact maintainer.
  > 
  > 
  > proc.time()
     user  system elapsed 
     1.65    0.15    1.81 
Running the tests in 'tests/t-ischecks.R' failed.
Complete output:
  > source(file.path("_helper", "init.R"))
  > # - "int.pos" ------------------------------------------------------------------
  > 
  > unitizer:::is.int.pos.1L(c(1, 2, 3))  # FALSE
  [1] FALSE
  > unitizer:::is.int.pos.1L(1)
  [1] TRUE
  > unitizer:::is.int.pos.1L(1)
  [1] TRUE
  > unitizer:::is.int.pos.1L(-1)           # FALSE
  [1] FALSE
  > unitizer:::is.int.pos.1L(NA_integer_)  # FALSE
  [1] FALSE
  > unitizer:::is.int.pos.2L(1:2)
  [1] TRUE
  > unitizer:::is.int.pos.2L(c(1, 2))
  [1] TRUE
  > 
  > # - "is.valid_two_arg" ---------------------------------------------------------
  > 
  > f1 <- function(x, y) NULL
  > f2 <- function(...) NULL
  > f3 <- function(x, ...) NULL
  > f4 <- function(x, y, z) NULL
  > f5 <- function(x, y, z = 3) NULL
  > f6 <- function(x) NULL
  > unitizer:::is.two_arg_fun(f1)
  [1] TRUE
  > unitizer:::is.two_arg_fun(f2)
  [1] TRUE
  > unitizer:::is.two_arg_fun(f3)
  [1] TRUE
  > unitizer:::is.two_arg_fun(f4)
  [1] "cannot have any non-optional arguments other than first two"
  > unitizer:::is.two_arg_fun(f5)
  [1] TRUE
  > unitizer:::is.two_arg_fun(f6)
  [1] "does not have at least two arguments"
  > unitizer:::is.two_arg_fun(1)
  [1] "is not a function"
  > 
  > # - "is.valid_capt_setting" ----------------------------------------------------
  > 
  > capt.test <- unitizer:::is.valid_capt_setting(c(T, T))
  | value must be logical(2L) containing TRUE 
  | / FALSE and with names `c("output", "message")
  
  > capt.test
  [1] FALSE
  > 
  > proc.time()
     user  system elapsed 
     0.51    0.10    0.60 
Running the tests in 'tests/t-item.R' failed.
Complete output:
  > source(file.path("_helper", "init.R"))
  > source(file.path("aammrtf", "ref.R")); make_ref_obj_funs("item")
  > 
  > options(unitizer.color = FALSE)
  > 
  > # These tests are intended to cover all the functions/classes/methods in:
  > # - item.R
  > # - item.sub.R
  > # - test_eval.R     # indirectly
  > # - heal.R
  > # - unitizer.R
  > # Basically everything that can be tested non-interactively
  > # Helper funs
  > 
  > callDep <- function(x) paste0(deparse(x@call, width.cutoff = 500),
  +     collapse = "")
  > lsObjs <- function(x) paste0(x@ls$names, x@ls$status, collapse = ", ")
  > lsStat <- function(x) x@ls$status
  > lsInv <- function(x) isTRUE(attr(x@ls, "invalid"))
  > # Get started
  > 
  > new.exps <- expression(
  +   1 + 1,
  +   a <- 54,     # keep
  +   b <- 38,     # keep
  +   a + b,
  +   e <- 5 * a,  # keep
  +   a ^ 2,       # Keep
  +   f <- e * a,
  +   matrix(rep(f, 20))  # keep
  + )
  > ref.exps <- expression(
  +   1 + 1,
  +   a <- 54,
  +   b <- 38,
  +   a + b,
  +   e <- 5 * a,
  +   e ^ 3
  + )
  > 
  > Sys.sleep(0.2)
  > my.unitizer <- new("unitizer", id = 1, zero.env = new.env())
  > # add ref.exps as new items
  > coi(my.unitizer <- my.unitizer + ref.exps)
  > my.unitizer2 <- new("unitizer", id = 2, zero.env = new.env())
  > # now convert them to reference items
  > coi(my.unitizer2 <- my.unitizer2 + my.unitizer@items.new)
  > # now test against new.exps
  > coi(my.unitizer2 <- my.unitizer2 + new.exps)
  > 
  > # - "item funs" ----------------------------------------------------------------
  > 
  > item <- my.unitizer@items.new[[1L]]
  > unitizer:::itemType(item)
  [1] "new"
  > try(unitizer:::itemType(item) <- "asdfasd")
  Error in unitizer:::`itemType<-`(`*tmp*`, value = "asdfasd") : 
    Argument `value` must be in c("new", "reference")
  > unitizer:::itemType(item) <- "reference"
  > unitizer:::itemType(item)
  [1] "reference"
  > try(unitizer:::itemsType(my.unitizer@items.new) <- as.character(1:1000))
  Error in unitizer:::`itemsType<-`(`*tmp*`, value = c("1", "2", "3", "4",  : 
    Argument `value` must be length 1L or have same length as argument `x`
  > try(item$booboo)
  Error in .local(x, i, j, ...) : 
    Argument `name` must be in c("call", "state", "value", "conditions", "output", "message", "aborted")
  > 
  > # - "unitizer creation worked as expected" -------------------------------------
  > 
  > validObject(my.unitizer, complete = TRUE)
  [1] TRUE
  > all.equal(capture.output(show(my.unitizer@items.new[[1L]])), rds(100))
  [1] TRUE
  > identical(length(my.unitizer2), length(new.exps))
  [1] TRUE
  > identical(length(my.unitizer2@items.new), length(new.exps))
  [1] TRUE
  > identical(length(my.unitizer2@items.ref), length(ref.exps))
  [1] TRUE
  > all.equal(
  +   as.expression(
  +     lapply(unitizer:::as.list(my.unitizer2@items.new), slot, "call")
  +   ),
  +   new.exps
  + )
  [1] TRUE
  > all.equal(
  +   as.expression(
  +     lapply(unitizer:::as.list(my.unitizer2@items.ref), slot, "call")
  +   ),
  +   ref.exps
  + )
  [1] TRUE
  > vals <- lapply(
  +   unitizer:::as.list(my.unitizer2@items.new), function(x) x@data@value[[1L]]
  + )
  > vals.ign <- unitizer:::ignored(my.unitizer2@items.new)
  > all.equal(vals[!vals.ign], lapply(new.exps, eval)[!vals.ign])
  [1] TRUE
  > all(vapply(vals[vals.ign], is, logical(1L), "unitizerDummy"))
  [1] TRUE
  > 
  > vals <- lapply(
  +   unitizer:::as.list(my.unitizer2@items.ref), function(x) x@data@value[[1L]]
  + )
  > vals.ign <- unitizer:::ignored(my.unitizer2@items.ref)
  > all.equal(vals[!vals.ign], lapply(ref.exps, eval)[!vals.ign])
  [1] TRUE
  > all(vapply(vals[vals.ign], is, logical(1L), "unitizerDummy"))
  [1] TRUE
  > my.unitizer2@items.new.map
  [1]  1  2  3  4  5 NA NA NA
  > my.unitizer2@items.ref.map
  [1]  1  2  3  4  5 NA
  > my.unitizer2@tests.fail
  [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
  > my.unitizer2@tests.status
  [1] Pass Pass Pass Pass Pass New  New  New 
  Levels: Pass Fail New Deleted Error
  > my.unitizer2@section.map
  [1] 1 1 1 1 1 1 1 1
  > unitizer:::ignored(my.unitizer2@items.new)
  [1] FALSE  TRUE  TRUE FALSE  TRUE FALSE  TRUE FALSE
  > unitizer:::ignored(my.unitizer2@items.ref)
  [1] FALSE  TRUE  TRUE FALSE  TRUE FALSE
  > 
  > # - "Size Measurement works" ---------------------------------------------------
  > 
  > # Used to produce warnings because the same base.env was used for every
  > # unitizer because it was created on package load as part of the S4 class
  > # definition instead of in "initialize", so any time we instantiated more
  > # than one object they all shared the same environment, causing issues with
  > # saveRDS
  > x <- unitizer:::sizeUntz(my.unitizer2)
  > is.matrix(x) && is.numeric(x)
  [1] TRUE
  > colnames(x)
  [1] "size" "rds" 
  > 
  > # - "Environment healing works" ------------------------------------------------
  > 
  > items.mixed <- my.unitizer2@items.new[4:5] + my.unitizer2@items.ref[[1]] +
  +     my.unitizer2@items.new[c(2, 6, 8)]
  > items.sorted <- unitizer:::healEnvs(items.mixed, my.unitizer2)
  > env.anc <- lapply(unitizer:::as.list(items.sorted), function(x) rev(unitizer:::env_ancestry(x@env,
  +     my.unitizer2@base.env)))
  > max.len <- max(vapply(env.anc, length, 1L))
  > env.anc.2 <- lapply(env.anc, function(x) {
  +     length(x) <- max.len
  +     x
  + })
  > env.anc.df <- as.data.frame(env.anc.2, stringsAsFactors = FALSE)
  > # Here only the first item is reference, all others
  > length(unique(unlist(env.anc.df[2, ])))
  [1] 1
  > all(
  +   apply(
  +     env.anc.df[-(1:2), -1], 1,
  +     function(x) length(unique(Filter(Negate(is.na), x)))
  +   ) == 1L
  + )
  [1] TRUE
  > # First item is reference, all others are new
  > unitizer:::itemsType(items.sorted)
  [1] "reference" "new"       "new"       "new"       "new"       "new"      
  [7] "new"       "new"      
  > # Expected order of ids
  > vapply(unitizer:::as.list(items.sorted), function(x) x@id, integer(1L))
  [1] 1 2 3 4 5 6 7 8
  > lapply(unitizer:::as.list(items.sorted), function(x) x@ls$names)
  [[1]]
  character(0)
  
  [[2]]
  character(0)
  
  [[3]]
  character(0)
  
  [[4]]
  [1] "a" "b"
  
  [[5]]
  character(0)
  
  [[6]]
  [1] "a" "b" "e"
  
  [[7]]
  character(0)
  
  [[8]]
  [1] "a" "b" "e" "f"
  
  > unique(unlist(lapply(unitizer:::as.list(items.sorted), function(x) x@ls$status)))
  [1] ""
  > # Tests with conditions
  > 
  > # - "Items with conditions" ----------------------------------------------------
  > 
  > my_fun <- function() {
  +     warning("hello")
  +     25
  + }
  > ref.exps1a <- expression(stop("boom"), my_fun())
  > my.unitizer1a <- new("unitizer", id = 100, zero.env = new.env())
  > # add ref.exps as new items
  > coi(my.unitizer1a <- my.unitizer1a + ref.exps1a)
  > 
  > all.equal(capture.output(show(my.unitizer1a@items.new[[1L]])), rds(200))
  [1] TRUE
  > all.equal(capture.output(show(my.unitizer1a@items.new[[2L]])), rds(300))
  [1] TRUE
  > all.equal(
  +   capture.output(show(my.unitizer1a@items.new[[1L]]@data@conditions)), rds(400)
  + )
  [1] TRUE
  > # - "Environment healing works 2" ----------------------------------------------
  > 
  > # Stars highlight items we are selecting, but keep in mind that unitizer only
  > # cares about non ignored tests, and that the selection status of ignored test
  > # has nothing to do with what we end up with wrt to ignored tests
  > 
  > new.exps2 <- expression(
  +   1 + 1,                   #  1 *
  +   a <- 54,                 #  2
  +   b <- runif(5),           #  3
  +   howdy <- "yowser",       #  4 *
  +   a + b,                   #  5 *
  +   e <- 5 * a,              #  6
  +   a ^ 2,                   #  7
  +   f <- e * a,              #  8
  +   matrix(rep(f, 20))       #  9 *
  + )
  > ref.exps2 <- expression(
  +   1 + 1,                   #  1
  +   a <- 54,                 #  2
  +   b <- runif(5),           #  3 *
  +   25 + 3,                  #  4
  +   q <- b ^ 2 / a,          #  5 *
  +   a + b,                   #  6
  +   z <- w <- list(1, 2, 3), #  7
  +   Reduce(`+`, z),          #  8 * Doesn't exist, should connect back to `a + b`
  +   e <- 5 * a,              #  9
  +   e ^ 3,                   # 10 *
  +   e * a                    # 11 *
  + )
  > 
  > # Note that healEnvs modifies objects that contain environments, and as such
  > # you won't get the same result if you run this function twice, so don't be
  > # surprised if tests fail in those circumstances
  > my.unitizer3 <- new("unitizer", id = 1, zero.env = new.env())
  > # add ref.exps as new items
  > coi(my.unitizer3 <- my.unitizer3 + ref.exps2)
  > my.unitizer4 <- new("unitizer", id = 2, zero.env = new.env())
  > # now convert them to reference items
  > coi(my.unitizer4 <- my.unitizer4 + my.unitizer3@items.new)
  > # now test against new.exps
  > coi(my.unitizer4 <- my.unitizer4 + new.exps2)
  > coi(
  +   items.mixed2 <- my.unitizer4@items.ref[c(8, 10, 3, 5, 11)] +
  +     my.unitizer4@items.new[c(1, 4, 5, 9)]
  + )
  > items.sorted2 <- unitizer:::healEnvs(items.mixed2, my.unitizer4)
  > 
  > env.anc <- lapply(unitizer:::as.list(items.sorted2), function(x) rev(unitizer:::env_ancestry(x@env,
  +     my.unitizer4@base.env)))
  > max.len <- max(vapply(env.anc, length, 1L))
  > env.anc.2 <- lapply(env.anc, function(x) {
  +     length(x) <- max.len
  +     x
  + })
  > # oldest ancestor the same
  > env.anc.df <- as.data.frame(env.anc.2, stringsAsFactors = FALSE)
  > length(unique(unname(unlist(env.anc.df[1, ]))))  # 1
  [1] 1
  > # "base.env should be unitizer env")
  > identical(
  +   env.anc.df[1, 1], unitizer:::env_name(my.unitizer4@base.env)
  + )
  [1] TRUE
  > # "all tests should also have another sub base.env")
  > length(unique(unlist(env.anc.df[2, ]))) == 1L
  [1] TRUE
  > # "and it should be the items.ref here")
  > identical(
  +   env.anc.df[2, 1], unitizer:::env_name(my.unitizer4@items.ref@base.env)
  + )
  [1] TRUE
  > items <- items.sorted2
  > items.lst <- unitizer:::as.list(items)
  > # "new items should all have normal status",
  > heal.info <- cbind(
  +   type = unitizer:::itemsType(items), ignored = unitizer:::ignored(items),
  +   id = vapply(items.lst, slot, 1L, "id"),
  +   call = vapply(items.lst, callDep, ""),
  +   ls = vapply(items.lst, lsObjs, ""),
  +   ls.invalid = vapply(items.lst, lsInv, TRUE)
  + )
  > # ""
  > unique(unlist(lapply(items.lst[unitizer:::itemsType(items) == "new"], lsStat)))
  [1] ""
  > # "Reference tests should have no ls data",
  > unique(vapply(items.lst[unitizer:::ignored(items)], lsObjs, ""))
  [1] ""
  > all(vapply(items.lst[unitizer:::ignored(items)], lsInv, logical(1L)))
  [1] TRUE
  > 
  > # - "ls works" -----------------------------------------------------------------
  > 
  > my.unitizer5 <- new("unitizer", id = 2, zero.env = new.env())
  > # now add back our composite elements as references
  > coi(my.unitizer5 <- my.unitizer5 + items.sorted2)
  > # and new items
  > coi(my.unitizer5 <- my.unitizer5 + new.exps2)
  > 
  > # This is an ignored test, so there will be some problems
  > env.val <- new.env(parent = my.unitizer5@items.new[[3]]@env)
  > env.eval <- new.env(parent = env.val)
  > assign(".NEW", my.unitizer5@items.new[[3]], env.val)
  > assign(".new", my.unitizer5@items.new[[3]]@data@value[[1L]],
  +     env.val)
  > assign(".REF", my.unitizer5@items.ref[[my.unitizer5@items.new.map[[3]]]],
  +     env.val)
  > assign(".ref", my.unitizer5@items.ref[[my.unitizer5@items.new.map[[3]]]]@data@value[[1L]],
  +     env.val)
  > ls.res <- evalq(unitizer:::unitizer_ls(), env.eval)  # warn
  Warning in unitizer:::unitizer_ls() :
    The ls output for `.ref` is invalid.  This may be because you had corrupted environment chains that had to be repaired. Re-generating the `unitizer` with `unitize(..., force.update=TRUE)` should fix the problem.  If it persists, please contact maintainer.
  > # Reference tests won't show up since they were nuked by `healEnvs`
  > all.equal(ls.res, rds(500))
  [1] TRUE
  > # These are normal tests so should work
  > env.val <- new.env(parent = my.unitizer5@items.new[[9]]@env)
  > env.eval <- new.env(parent = env.val)
  > assign(".NEW", my.unitizer5@items.new[[9]], env.val)
  > assign(".new", my.unitizer5@items.new[[9]]@data@value[[1L]],
  +     env.val)
  > assign(".REF", my.unitizer5@items.ref[[my.unitizer5@items.new.map[[9]]]],
  +     env.val)
  > assign(".ref", my.unitizer5@items.ref[[my.unitizer5@items.new.map[[9]]]]@data@value[[1L]],
  +     env.val)
  > all.equal(evalq(unitizer:::unitizer_ls(), env.eval),
  +     rds(600))
  [1] TRUE
  > all.equal(capture.output(print(evalq(unitizer:::unitizer_ls(),
  +     env.eval))), rds(700))
  [1] TRUE
  > 
  > # - "Environment Healing Works #3" ---------------------------------------------
  > #
  > # Main difference to previous versions is that we're testing that moving the
  > # order of tests around between ref and new still works
  > #
  > # Test that reference tests moving around doesn't cause major issues
  > 
  > new.exps6 <- expression(
  +   1 + 1,                #  1   *
  +   a <- 54,              #  2
  +   b <- runif(5),        #  3
  +   howdy <- "yowser",    #  4
  +   a + b,                #  5
  +   e <- 5 * a,           #  6
  +   a ^ 2,                #  7   *
  +   f <- 25,              #  8   *
  +   matrix(rep(f, 20))    #  9
  + )
  > ref.exps6 <- expression(
  +   1 + 1,                #  1
  +   a <- 54,              #  2
  +   f <- 25,              #  3
  +   matrix(rep(f, 20)),   #  4   *
  +   b <- runif(5),        #  5
  +   boomboom <- "boo",    #  6
  +   a + b,                #  7   *
  +   a + b + f,            #  8
  +   e <- 5 * a,           #  9
  +   a ^ 2                 # 10
  + )
  > my.unitizer10 <- new("unitizer", id = 1, zero.env = new.env())
  > # add ref.exps as new items
  > coi(my.unitizer10 <- my.unitizer10 + ref.exps6)
  > my.unitizer11 <- new("unitizer", id = 2, zero.env = new.env())
  > # now convert them to reference items
  > coi(my.unitizer11 <- my.unitizer11 + my.unitizer10@items.new)
  > # now test against new.exps
  > coi(my.unitizer11 <- my.unitizer11 + new.exps6)
  > items.mixed3 <- my.unitizer11@items.ref[c(4, 7)] +
  +   my.unitizer11@items.new[c(1, 7, 8)]
  > items.sorted3 <- unitizer:::healEnvs(items.mixed3, my.unitizer11)
  > 
  > # Both reference tests get appended to item #1, which means among other things
  > # that for the second refernce test, the `a` object is absent (but `b` is
  > # present because it gets sucked in by virtue of being an ignored test just
  > # ahead of it)
  > items <- items.sorted3
  > items.lst <- unitizer:::as.list(items)
  > cbind(
  +   type = unitizer:::itemsType(items), ignored = unitizer:::ignored(items),
  +   id = vapply(items.lst, slot, 1L, "id"),
  +   call = vapply(items.lst, callDep, ""),
  +   ls = vapply(items.lst, lsObjs, ""),
  +   ls.invalid = vapply(items.lst, lsInv, TRUE)
  + )
        type        ignored id  call                  ls                   
   [1,] "new"       "FALSE" "1" "1 + 1"               ""                   
   [2,] "reference" "TRUE"  "2" "a <- 54"             ""                   
   [3,] "reference" "TRUE"  "3" "f <- 25"             ""                   
   [4,] "reference" "FALSE" "4" "matrix(rep(f, 20))"  "a, f"               
   [5,] "reference" "TRUE"  "5" "b <- runif(5)"       ""                   
   [6,] "reference" "TRUE"  "6" "boomboom <- \"boo\"" ""                   
   [7,] "reference" "FALSE" "7" "a + b"               "a*, b, boomboom, f*"
   [8,] "new"       "TRUE"  "6" "e <- 5 * a"          ""                   
   [9,] "new"       "FALSE" "7" "a^2"                 "a, b, e, howdy"     
        ls.invalid
   [1,] "FALSE"   
   [2,] "TRUE"    
   [3,] "TRUE"    
   [4,] "FALSE"   
   [5,] "TRUE"    
   [6,] "TRUE"    
   [7,] "FALSE"   
   [8,] "TRUE"    
   [9,] "FALSE"   
  > # - "No circular environment references" ---------------------------------------
  > 
  > # This is to test for issue #2, which resulted in a self referential environment
  > # in the stored items.  The following code used to fail:
  > new.exps3 <- expression(1 + 1, a <- 54, b <- 5, 2 + 2, runif(1))
  > ref.exps3 <- expression(1 + 1, a <- 54, 2 + 2, runif(1))
  > my.unitizer6 <- new("unitizer", id = 1, zero.env = new.env())
  > # add ref.exps as new items
  > coi(my.unitizer6 <- my.unitizer6 + ref.exps3)
  > my.unitizer7 <- new("unitizer", id = 2, zero.env = new.env())
  > # now convert them to reference items
  > coi(my.unitizer7 <- my.unitizer7 + my.unitizer6@items.new)
  > # now test against new.exps
  > coi(my.unitizer7 <- my.unitizer7 + new.exps3)
  > # Note this doesn't test that there are no circular references, only that what
  > # used to fail no longer fails.
  > 
  > cbind(my.unitizer7@tests.new, my.unitizer7@tests.result)
             value conditions output message aborted
  [1,] FALSE  TRUE       TRUE   TRUE    TRUE    TRUE
  [2,] FALSE  TRUE       TRUE   TRUE    TRUE    TRUE
  [3,]  TRUE FALSE      FALSE  FALSE   FALSE   FALSE
  [4,] FALSE  TRUE       TRUE   TRUE    TRUE    TRUE
  [5,] FALSE FALSE       TRUE   TRUE    TRUE    TRUE
  > 
  > # - "testFuns" -----------------------------------------------------------------
  > 
  > # Error objects
  > 
  > # these two should just work fine
  > is(new("testFuns", output = all.equal, value = function(x, y) TRUE), "testFuns")
  [1] TRUE
  > is(new("testFuns"), "testFuns")
  [1] TRUE
  > try(new("testFuns", output = all.equal, value = function(x, y, z) TRUE))
  Error in validObject(.Object) : 
    invalid class "unitizerItemTestFun" object: Slot `@fun` must be a function with the first two parameters non-optional and all others optional (cannot have any non-optional arguments other than first two).
  > # this should work too now, since technically has two args
  > is(
  +   new("testFuns", output = all.equal, value = function(x, y = 1, z = 1) TRUE),
  +   "testFuns"
  + )
  [1] TRUE
  > try(new("testFuns", cabbage = all.equal))
  Error in initialize(value, ...) : 
    Can't initialize invalid slots "cabbage"
  > 
  > # - "Misc" ---------------------------------------------------------------------
  > 
  > new.exps4 <- expression(a <- function() b(), b <- function() TRUE, a())
  > my.unitizer8 <- new("unitizer", id = 3, zero.env = new.env())
  > new.exps5 <- expression(a <- function() b(), NULL, b <- function() TRUE, a())
  > my.unitizer9 <- new("unitizer", id = 4, zero.env = new.env())
  > coi(x <- my.unitizer9 + new.exps5)
  > 
  > local({
  +   fun <- function() quote(stop("This error should not be thrown"))
  +   is(
  +     new(
  +       "unitizerItem", value = fun(), call = quote(fun()),
  +       env = sys.frame(sys.parent() + 1L)
  +     ),
  +     "unitizerItem"
  +   )
  + })
  [1] TRUE
  > # Nested environment hand waving can break down under certain circumstances
  > # this first one should work because there are no tests until after all
  > # the pieces necessary to run `a()` are defined:
  > coi(res <- my.unitizer8 + new.exps4)
  > is(res, "unitizer")
  [1] TRUE
  > # this should break because the NULL forces `b` to be stored in a different
  > # environment to `a`; note: funky error message matching because in
  > # at least some versions of rdevel reported fun name seems to change
  > # (possibly related to level 3 bytecode)
  > # could not find fun
  > x@items.new[[4]]@data@message[[1]]
  [1] "Error in b() : could not find function \"b\"\n"
  > 
  > # - "Comparison Function Errors" -----------------------------------------------
  > 
  > exps <- expression(fun <- function(x, y) warning("not gonna work"),
  +     unitizer_sect(compare = fun, expr = {
  +         1 + 1
  +     }))
  > my.unitizer <- new("unitizer", id = 25, zero.env = new.env())
  > # add ref.exps as new items
  > coi(my.unitizer <- my.unitizer + exps)
  > coi(my.unitizer2 <- new("unitizer", id = 26, zero.env = new.env()) +
  +     my.unitizer@items.new)
  > # warn: not gonna work
  > coi(my.unitizer2 <- my.unitizer2 + exps)
  Warning in close_and_clear(e1@global$cons) :
    Test comparison functions appear to have produced output, which should not happen (see `?unitizer_sect` for more details).  If you did not provide custom testing functions, contact maintainer.  First 50 lines follow:
  Warning in fun(2, 2) : not gonna work
  
  > as.character(my.unitizer2@tests.status)
  [1] "Pass"  "Error"
  > my.unitizer2@tests.errorDetails[[2]]@value@value
  [1] "comparison function `fun` signaled a condition of class `c(\"simpleWarning\", \"warning\", \"condition\")`, with message \"not gonna work\" and call `fun(2, 2)`."
  > 
  > # - "Language Objects Tested Properly" -----------------------------------------
  > 
  > exps <- expression(quote(x), quote(x + y), quote(identity(x)),
  +     expression(1 + y), quote(expression(1 + y)))
  > my.unitizer <- new("unitizer", id = 27, zero.env = new.env())
  > # add ref.exps as new items
  > coi(my.unitizer <- my.unitizer + exps)
  > coi(my.unitizer2 <- new("unitizer", id = 28, zero.env = new.env()) +
  +     my.unitizer@items.new)
  > coi(my.unitizer2 <- my.unitizer2 + exps)
  > # This used to error b/c expressions returning unevaluated calls/symbols were
  > # not compared as such (they were evaluated)
  > as.character(my.unitizer2@tests.status)
  [1] "Pass" "Pass" "Pass" "Pass" "Pass"
  > 
  > # - "Test Fun Captured Properly" -----------------------------------------------
  > 
  > new("unitizerItemTestFun", fun = identical)@fun.name
  [1] "identical"
  > 
  > 
  > proc.time()
     user  system elapsed 
     1.46    0.15    1.82 
Running the tests in 'tests/t-list.R' failed.
Complete output:
  > source(file.path("_helper", "init.R"))
  > 
  > lst <- new("unitizerList")
  > 
  > # - "unitizerList basic tests" -------------------------------------------------
  > 
  > length(lst) == 0L
  [1] TRUE
  > is(lst <- unitizer:::append(lst, 5), "unitizerList")
  [1] TRUE
  > length(lst) == 1L
  [1] TRUE
  > is(
  +   lst <- unitizer:::append(
  +     lst, list("booyah", list(1:3), matrix(1:9, nrow = 3))
  +   ), "unitizerList"
  + )
  [1] TRUE
  > length(lst) == 4L
  [1] TRUE
  > is(lst[3L], "unitizerList")
  [1] TRUE
  > is(lst[[3L]], "list")
  [1] TRUE
  > lst <- unitizer:::append(lst, list(data.frame(a = letters[1:3])), 2L)
  > is(lst[[3L]], "data.frame")
  [1] TRUE
  > length(lst[1:4]) == 4L
  [1] TRUE
  > lst[[4L]] <- "boo"
  > is(lst[[4L]], "character")
  [1] TRUE
  > lst[4L:5L] <- letters[1:2]
  > 
  > c(lst[[4L]], lst[[5L]])
  [1] "a" "b"
  > lst[[4L]]
  [1] "a"
  > 
  > is(unitizer:::as.list(lst), "list")
  [1] TRUE
  > length(unitizer:::as.list(lst)) == 5L
  [1] TRUE
  > is(unitizer:::as.expression(lst), "expression")
  [1] TRUE
  > 
  > try(unitizer:::getItem(lst))  # error
  Error in .local(x, ...) : 
    Internal pointer for `x` not initialized; initialize with `nextItem`
  > lst <- unitizer:::nextItem(lst)
  > unitizer:::getItem(lst)
  [1] 5
  > lst <- unitizer:::nextItem(lst)
  > unitizer:::getItem(lst)
  [1] "booyah"
  > lst <- unitizer:::prevItem(lst)
  > unitizer:::getItem(lst)
  [1] 5
  > lst <<- lst  # leftover from testthat testing?
  > 
  > # - "unitizerList pointer seeking" ---------------------------------------------
  > 
  > for (i in 1:10) lst <- unitizer:::nextItem(lst)
  > try(unitizer:::getItem(lst))
  Error in .local(x, ...) : Internal pointer for `x` is corrupted
  > unitizer:::done(lst)
  [1] TRUE
  > is(lst <- unitizer:::reset(lst, "back"), "unitizerList")
  [1] TRUE
  > try(unitizer:::reset(lst, letters))
  Error in .local(x, ...) : 
    Argument `position` must be `NULL`, or "front" or "back"
  > try(unitizer:::reset(lst, NA_character_))
  Error in .local(x, ...) : 
    Argument `position` must be `NULL`, or "front" or "back"
  > try(unitizer:::getItem(lst))
  Error in .local(x, ...) : 
    Internal pointer for `x` not initialized; initialize with `prevItem`
  > lst <- unitizer:::prevItem(lst)
  > unitizer:::getItem(lst) == "b"
  [1] TRUE
  > while (!unitizer:::done(lst)) {
  +     item <- unitizer:::getItem(lst)
  +     lst <- unitizer:::prevItem(lst)
  + }
  > item == 5L
  [1] TRUE
  > try(unitizer:::getItem(lst))
  Error in .local(x, ...) : 
    Internal pointer for `x` outside of range for `x`; test for this condition with `done`, or reset with `reset`
  > withCallingHandlers(
  +   lst[[4]] <- "new value",
  +   warning = function() stop("A Warning!")
  + )
  > 
  > for (i in 1:5) lst <- unitizer:::nextItem(lst)
  > lst@.pointer
  [1] 5
  > 
  > # - "unitizerList value replacement and pointer adjustments" -------------------
  > 
  > lst[[4]] <- NULL
  > lst@.pointer
  [1] 4
  > unitizer:::reset(lst, "back")
  An object of class "unitizerList"
  Slot ".items":
  [[1]]
  [1] 5
  
  [[2]]
  [1] "booyah"
  
  [[3]]
    a
  1 a
  2 b
  3 c
  
  [[4]]
  [1] "b"
  
  
  Slot ".pointer":
  [1] 5
  
  Slot ".seek.fwd":
  [1] FALSE
  
  > lst.len <- length(lst)
  > identical(lst@.pointer, lst.len)
  [1] TRUE
  > lst[2:3] <- letters[1:2]
  > identical(lst@.pointer, lst.len)
  [1] TRUE
  > lst[2:3] <- list(NULL, NULL)
  > identical(lst@.pointer, lst.len)
  [1] TRUE
  > lst[2:3] <- NULL
  > identical(lst@.pointer, lst.len - 2L)
  [1] TRUE
  > 
  > lst <- unitizer:::reset(lst, "front")
  > for (i in 1:2) lst <- unitizer:::nextItem(lst)
  > curr.point <- lst@.pointer
  > lst[[3]] <- NULL
  > identical(curr.point, lst@.pointer)
  [1] TRUE
  > lst <- unitizer:::append(lst, list(5, 6, "blaskdjf"), 1L)
  > identical(curr.point + 3L, lst@.pointer)
  [1] TRUE
  > lst <- unitizer:::append(lst, list(matrix(1:9, nrow = 3)), 5L)
  > identical(curr.point + 3L, lst@.pointer)
  [1] TRUE
  > 
  > # - "Append Factors Works" -----------------------------------------------------
  > 
  > vec <- factor(letters[1:3], levels = letters)
  > vec2 <- factor(letters[10:15], levels = letters)
  > 
  > all.equal(structure(c(1L, 2L, 3L, 10L, 11L, 12L, 13L, 14L,
  +   15L), .Label = c("a", "b", "c", "d", "e", "f", "g", "h",
  +   "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
  +   "u", "v", "w", "x", "y", "z"), class = "factor"), append(vec,
  +   vec2))
  [1] TRUE
  > all.equal(structure(c(1L, 2L, 10L, 11L, 12L, 13L, 14L, 15L,
  +   3L), .Label = c("a", "b", "c", "d", "e", "f", "g", "h", "i",
  +   "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u",
  +   "v", "w", "x", "y", "z"), class = "factor"), append(vec,
  +   vec2, 2))
  [1] TRUE
  > 
  > all.equal(structure(c(10L, 11L, 12L, 13L, 1L, 2L, 3L, 14L,
  +   15L), .Label = c("a", "b", "c", "d", "e", "f", "g", "h",
  +   "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
  +   "u", "v", "w", "x", "y", "z"), class = "factor"), append(vec2,
  +   vec, 4))
  [1] TRUE
  > try(append(vec2, vec, 20))
  Error in append(vec2, vec, 20) : 
    Argument after must be integer like between 0 and length(x)
  > try(append(vec2, vec, -5))
  Error in append(vec2, vec, -5) : 
    Argument after must be integer like between 0 and length(x)
  > 
  > # - "List coersion works even inside apply functions" --------------------------
  > 
  > ulist <- new("unitizerList", .items = list("a", 1, 2, "b"))
  > identical(lapply(ulist, identity), ulist@.items)
  [1] TRUE
  > 
  > # - "Errors" -------------------------------------------------------------------
  > 
  > setClass("uhtsdfoqiuerhzb", slots = c(a = "integer"))
  > dummy <- new("uhtsdfoqiuerhzb", a = 1L)
  > lst2 <- new("unitizerList", .items = list(1, 2, 3))
  > try(append(lst2, 5, after = -1))
  Error in append(lst2, 5, after = -1) : 
    Argument `after` must be a length 1 numeric greater than zero
  > try(append(lst2, dummy))
  Error in as.list.default(values) : 
    no method for coercing this S4 class to a vector
  Error in append(lst2, dummy) : 
    Unable to coerce argument `values` to appropriate type; see previous errors for details.
  > 
  > lst3 <- new("unitizerList", .items = expression(1, 2, 3))
  > try(append(lst3, dummy))
  Error in as.expression.default(values) : 
    no method for coercing this S4 class to a vector
  Error in append(lst3, dummy) : 
    Unable to coerce argument `values` to appropriate type; see previous errors for details.
  > 
  > # - "Set Names" ----------------------------------------------------------------
  > 
  > nlst <- new("unitizerList", .items = list(a = "a", b = "b"))
  > names(nlst) <- toupper(names(nlst))
  > as.list(nlst)
  $A
  [1] "a"
  
  $B
  [1] "b"
  
  > 
  > 
  > proc.time()
     user  system elapsed 
     0.68    0.09    0.76 
Running the tests in 'tests/t-nav.R' failed.
Complete output:
  > source(file.path("_helper", "init.R"))
  > nav <- file.path("_helper", "unitizers", "nav.R")
  > 
  > # Simple navigation tests that don't require complex unitizers
  > 
  > # - "Re-run bookmark" -----=----------------------------------------------------
  > 
  > # Relates to #278.  Tests both Review and Browse
  > 
  > unitizer:::read_line_set_vals(
  +   c("R", "Y", "B", "7", "R", "Y", "B", "9", "R", "Y", "Q")
  + )
  > unitize(nav, interactive.mode=TRUE)
  
  +------------------------------------------------------------------------------+
  | unitizer for: _helper/unitizers/nav.R                                        |
  +------------------------------------------------------------------------------+
  
      Pass Fail  New
   A     -    -    2
   B     -    -    2
  ..................
         -    -    4
  
  = A ============================================================================
  
  - New --------------------------------------------------------------------------
  
  | The 2 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, 
  | [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  > a <- 42
  > a + 1
  [1] 43
  
  unitizer> R
  
  | Toggling re-run mode ON for this unitizer
  
  = Finalize Unitizer ============================================================
  
  | You have 4 unreviewed tests; press `B` to browse tests, `U` to go to first 
  | unreviewed test.
  
  | You made no changes to the unitizer so there is no need to update it.  While 
  | unnecessary, you can force an update by typing O at the prompt.
  
  | Re-run unitizer ([Y]es, [P]rev, [B]rowse, [U]nreviewed, [R]erun, f[O]rce)?
  
  unitizer> Y
  
  | unitizer unchanged.
  
  +------------------------------------------------------------------------------+
  | unitizer for: _helper/unitizers/nav.R                                        |
  +------------------------------------------------------------------------------+
  
      Pass Fail  New
   A     -    -    2
   B     -    -    2
  ..................
         -    -    4
  
  = A ============================================================================
  
  - New --------------------------------------------------------------------------
  
  | The 2 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, 
  | [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  | Jumping to test #3 because that was the test under review when test re-run was
  | requested.
  
  > a <- 42
  > a + 1
  [1] 43
  
  unitizer> B
  
  = <untitled> ==============
    *1. z <- 24   .  .    -:-
  = A =======================
    *2. a <- 42   .  .    -:-
     3. a + 1  .  .  .  New:-
     4. a + 2  .  .  .  New:-
  = B =======================
    *5. b <- 25   .  .    -:-
    *6. bb <- 26  .  .    -:-
     7. b + 1  .  .  .  New:-
    *8. bbb <- 27 .  .    -:-
     9. b + 2  .  .  .  New:-
  
  | What test do you wish to review (input a test number, [U]nreviewed)?
  
  unitizer> 7
  = B ============================================================================
  
  - New --------------------------------------------------------------------------
  
  | The 2 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, 
  | [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  > b <- 25
  > bb <- 26
  > b + 1
  [1] 26
  
  unitizer> R
  
  | Toggling re-run mode ON for this unitizer
  
  = Finalize Unitizer ============================================================
  
  | You have 4 unreviewed tests; press `B` to browse tests, `U` to go to first 
  | unreviewed test.
  
  | You made no changes to the unitizer so there is no need to update it.  While 
  | unnecessary, you can force an update by typing O at the prompt.
  
  | Re-run unitizer ([Y]es, [P]rev, [B]rowse, [U]nreviewed, [R]erun, f[O]rce)?
  
  unitizer> Y
  
  | unitizer unchanged.
  
  +------------------------------------------------------------------------------+
  | unitizer for: _helper/unitizers/nav.R                                        |
  +------------------------------------------------------------------------------+
  
      Pass Fail  New
   A     -    -    2
   B     -    -    2
  ..................
         -    -    4
  
  = B ============================================================================
  
  - New --------------------------------------------------------------------------
  
  | The 2 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, 
  | [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  | Jumping to test #7 because that was the test under review when test re-run was
  | requested.
  
  > b <- 25
  > bb <- 26
  > b + 1
  [1] 26
  
  unitizer> B
  
  = <untitled> ==============
    *1. z <- 24   .  .    -:-
  = A =======================
    *2. a <- 42   .  .    -:-
     3. a + 1  .  .  .  New:-
     4. a + 2  .  .  .  New:-
  = B =======================
    *5. b <- 25   .  .    -:-
    *6. bb <- 26  .  .    -:-
     7. b + 1  .  .  .  New:-
    *8. bbb <- 27 .  .    -:-
     9. b + 2  .  .  .  New:-
  
  | What test do you wish to review (input a test number, [U]nreviewed)?
  
  unitizer> 9
  = B ============================================================================
  
  - New --------------------------------------------------------------------------
  
  | The 2 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, 
  | [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  > bbb <- 27
  > b + 2
  [1] 27
  
  unitizer> R
  
  | Toggling re-run mode ON for this unitizer
  
  = Finalize Unitizer ============================================================
  
  | You have 4 unreviewed tests; press `B` to browse tests, `U` to go to first 
  | unreviewed test.
  
  | You made no changes to the unitizer so there is no need to update it.  While 
  | unnecessary, you can force an update by typing O at the prompt.
  
  | Re-run unitizer ([Y]es, [P]rev, [B]rowse, [U]nreviewed, [R]erun, f[O]rce)?
  
  unitizer> Y
  
  | unitizer unchanged.
  
  +------------------------------------------------------------------------------+
  | unitizer for: _helper/unitizers/nav.R                                        |
  +------------------------------------------------------------------------------+
  
      Pass Fail  New
   A     -    -    2
   B     -    -    2
  ..................
         -    -    4
  
  = B ============================================================================
  
  - New --------------------------------------------------------------------------
  
  | The 2 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, 
  | [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  | Jumping to test #9 because that was the test under review when test re-run was
  | requested.
  
  > bbb <- 27
  > b + 2
  [1] 27
  
  unitizer> Q
  
  | No changes recorded.
  | unitizer unchanged.
  
  > 
  > 
  > proc.time()
     user  system elapsed 
     2.10    0.18    3.26 
Running the tests in 'tests/t-parse.R' failed.
Complete output:
  > source(file.path("_helper", "init.R"))
  > source(file.path("aammrtf", "ref.R")); make_ref_obj_funs("refobjs")
  > 
  > txt <- "# This is an early comment\n\n  hello <- 25\n\n  # multi\n  # line\n  # comment\n\n  matrix(1:9, 3)  # and another!\n\n  unitizer_sect(\"here is a section\", {\n    # test that were not crazy\n\n    1 + 1 == 2   # TRUE hopefully\n\n    # Still not crazy\n\n    2 * 2 == 2 ^ 2\n    # Tada\n  } )\n  sample(1:10)\n\n  # and this comment belongs to whom?\n\n  runif(20)\n  print(\"woo\")  # and I?\n  "
  > all <- unitizer:::parse_dat_get(text = txt)
  > prs <- all$expr
  > dat <- all$dat
  > dat$parent <- pmax(0L, dat$parent)
  > # With R4.0 some of the ids started changing
  > normalize_id <- function(dat) {
  +     idu <- sort(unique(dat[["id"]]))
  +     id <- with(dat, match(id, idu))
  +     parent <- with(dat, ifelse(parent == 0L, 0L, match(parent, 
  +         idu)))
  +     dat[["id"]] <- id
  +     dat[["parent"]] <- parent
  +     dat
  + }
  > dat <- normalize_id(dat)
  > dat.split <- dat.split.2 <- par.ids.3 <- NULL
  > if.text <- "if # IFFY\n(x > 3 # ifcond\n){ hello\n #whome to attach?\n} else #final\ngoodbye"
  > 
  > # - "Top Level Parents Identified Correctly" -----------------------------------
  > 
  > # "Identified top level parents?"
  > par.ids <- with(dat, unitizer:::top_level_parse_parents(id, parent))
  > par.ids
   [1]  0  0  7  7  7  7  7  0  0  0  0 24 24 24 24 24 24 24 24 24 24 24 24 24  0
  [26]  0 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64 64
  [51] 64 64 64 64 64 64 64 64 64 64 64 64 64 64  0 75 75 75 75 75 75 75 75 75 75
  [76]  0  0 83 83 83 83 83 83  0 90 90 90 90 90 90  0
  > dat.split <- split(dat, par.ids)
  > 
  > # "Identified sub-level top level parents correctly"
  > par.ids.2 <- with(dat.split$`64`, unitizer:::top_level_parse_parents(id, 
  +     parent, 64L))
  > par.ids.2
   [1] 28 64 64 31 64 64 64 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62 62
  [26] 62 62 62 62 62 62 62 62 62 62 62 62 64
  > dat.split.2 <- split(dat.split$`64`, par.ids.2)
  > 
  > # "Parent relationships in `unitizer_sect` piece."
  > 
  > par.ids.3 <- with(dat.split.2$`62`, unitizer:::top_level_parse_parents(id, 
  +     parent, 62L))
  > par.ids.3
   [1] 62 62 62 44 44 44 44 44 44 44 44 44 62 62 62 59 59 59 59 59 59 59 59 59 59
  [26] 59 59 59 62 62
  > 
  > # - "Comments Are Assigned" ----------------------------------------------------
  > 
  > # "Did we assign comments correctly to topmost level?"
  > lapply(unitizer:::comments_assign(prs, dat.split$`0`), attr, "comment")
  [[1]]
  [1] "# This is an early comment"
  
  [[2]]
  [1] "# multi"        "# line"         "# comment"      "# and another!"
  
  [[3]]
  NULL
  
  [[4]]
  NULL
  
  [[5]]
  [1] "# and this comment belongs to whom?"
  
  [[6]]
  [1] "# and I?"
  
  > 
  > # "No comments here so no changes should occur"
  > all.equal(unitizer:::comments_assign(prs[[3]], dat.split.2$`64`), prs[[3]])
  [1] TRUE
  > 
  > # "Comments in `unitizer_sect` body assigned correctly"
  > lapply(unitizer:::comments_assign(prs[[3]][[3]], split(dat.split.2$`62`, 
  +     par.ids.3)$`62`), attr, "comment")
  [[1]]
  NULL
  
  [[2]]
  [1] "# test that were not crazy" "# TRUE hopefully"          
  
  [[3]]
  [1] "# Still not crazy"
  
  > 
  > # - "Ancestry Descend" ---------------------------------------------------------
  > 
  > x <- unitizer:::parse_dat_get(text = "1 + 1; fun(x, fun(y + z))")$dat
  > x <- normalize_id(x)
  > 
  > unitizer:::ancestry_descend(x$id, x$parent, 0)
        children level
   [1,]        7     0
   [2,]        6     0
   [3,]       26     0
   [4,]        2     1
   [5,]        3     1
   [6,]        5     1
   [7,]       10     1
   [8,]        9     1
   [9,]       13     1
  [10,]       12     1
  [11,]       24     1
  [12,]       25     1
  [13,]        1     2
  [14,]        4     2
  [15,]        8     2
  [16,]       11     2
  [17,]       16     2
  [18,]       15     2
  [19,]       23     2
  [20,]       21     2
  [21,]       14     3
  [22,]       19     3
  [23,]       18     3
  [24,]       22     3
  [25,]       17     4
  [26,]       20     4
  > 
  > # - "Clean up Parse Data" ------------------------------------------------------
  > 
  > dat <- unitizer:::parse_dat_get(text = "{function(x) NULL;; #comment\n}")$dat
  > # set negative ids to be top level parents
  > dat <- transform(dat, parent = ifelse(parent < 0, 0L, parent))
  > dat <- normalize_id(dat)
  > 
  > # "Ancestry Descend"
  > dat.anc <- unitizer:::ancestry_descend(dat$id, dat$parent, 0L)
  > dat.anc
        children level
   [1,]       15     0
   [2,]        1     1
   [3,]       13     1
   [4,]       12     1
   [5,]       14     1
   [6,]       11     2
   [7,]       10     2
   [8,]        9     3
   [9,]        8     3
  [10,]        2     4
  [11,]        3     4
  [12,]        4     4
  [13,]        5     4
  [14,]        7     4
  [15,]        6     5
  > 
  > # "Excise `exprlist`"
  > unitizer:::prsdat_fix_exprlist(dat, dat.anc)$token
   [1] "expr"           "'{'"            "expr"           "FUNCTION"      
   [5] "'('"            "SYMBOL_FORMALS" "')'"            "NULL_CONST"    
   [9] "expr"           "COMMENT"        "'}'"           
  > 
  > dat.1 <- unitizer:::parse_dat_get(text = "{1 ; ; ;2;}")$dat
  > # set negative ids to be top level parents
  > dat.1 <- transform(dat.1, parent = ifelse(parent < 0, 0L, parent))
  > dat.1 <- normalize_id(dat.1)
  > 
  > # "Another `exprlist` test"
  > unname(
  +   as.list(
  +     unitizer:::prsdat_fix_exprlist(
  +       dat.1, 
  +       unitizer:::ancestry_descend(dat.1$id, dat.1$parent, 0L)
  +     )[c("parent", "token")]
  + ) )
  [[1]]
  [1]  0 14  3 14 10 14 14
  
  [[2]]
  [1] "expr"      "'{'"       "NUM_CONST" "expr"      "NUM_CONST" "expr"     
  [7] "'}'"      
  
  > dat.2 <- unitizer:::parse_dat_get(text = "{NULL; yowza; #comment\nhello\n}")$dat
  > # set negative ids to be top level parents
  > dat.2 <- transform(dat.2, parent = ifelse(parent < 0, 0L, parent))
  > dat.2 <- normalize_id(dat.2)
  > 
  > # "Yet another `exprlist`"
  > unname(
  +   as.list(
  +     unitizer:::prsdat_fix_exprlist(
  +       dat.2, unitizer:::ancestry_descend(dat.2$id, dat.2$parent, 0L)
  +     )[c("parent", "token")]
  + ) )
  [[1]]
   [1]  0 13  3 13  7 13 13 11 13 13
  
  [[2]]
   [1] "expr"       "'{'"        "NULL_CONST" "expr"       "SYMBOL"    
   [6] "expr"       "COMMENT"    "SYMBOL"     "expr"       "'}'"       
  
  > 
  > dat.2a <- normalize_id(
  +   unitizer:::parse_dat_get(text = "for(i in x) {if(x) break else next}")$dat
  + )
  > # "`for` cleanup"
  > 
  > as.list(unitizer:::prsdat_fix_for(dat.2a[-1L, ]))
  $line1
   [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
  
  $col1
   [1]  1  5 10 10 13 13 14 14 16 17 17 18 20 20 26 31 31 35
  
  $line2
   [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
  
  $col2
   [1]  3  5 10 10 35 13 34 15 16 17 17 18 24 24 29 34 34 35
  
  $id
   [1]  1  3  5  7 22  9 21 10 11 12 14 13 15 16 17 18 19 20
  
  $parent
   [1] 23 23  7 23 23 22 22 21 21 14 21 21 16 21 21 19 21 22
  
  $token
   [1] "FOR"    "SYMBOL" "SYMBOL" "expr"   "expr"   "'{'"    "expr"   "IF"    
   [9] "'('"    "SYMBOL" "expr"   "')'"    "BREAK"  "expr"   "ELSE"   "NEXT"  
  [17] "expr"   "'}'"   
  
  $terminal
   [1]  TRUE  TRUE  TRUE FALSE FALSE  TRUE FALSE  TRUE  TRUE  TRUE FALSE  TRUE
  [13]  TRUE FALSE  TRUE  TRUE FALSE  TRUE
  
  $text
   [1] "for"   "i"     "x"     ""      ""      "{"     ""      "if"    "("    
  [10] "x"     ""      ")"     "break" ""      "else"  "next"  ""      "}"    
  
  > 
  > dat.3 <- normalize_id(unitizer:::parse_dat_get(text = if.text)$dat)
  > 
  > # "`if` cleanup"
  > 
  > unname(as.list(unitizer:::prsdat_fix_if(dat.3[-1, ])[c("id", "token")]))
  [[1]]
   [1]  1  2 11  4  6  5  7  8  9 17 12 13 14 15 16 19 20 21
  
  [[2]]
   [1] "IF"        "COMMENT"   "expr"      "SYMBOL"    "expr"      "GT"       
   [7] "NUM_CONST" "expr"      "COMMENT"   "expr"      "'{'"       "SYMBOL"   
  [13] "expr"      "COMMENT"   "'}'"       "COMMENT"   "SYMBOL"    "expr"     
  
  > 
  > # - "Full Parse Works Properly" ------------------------------------------------
  > 
  > # "Full Comment Parse"
  > unitizer:::comm_extract(unitizer:::parse_with_comments(text = txt))
  [[1]]
  NULL
  
  [[2]]
  [[2]][[1]]
  [1] "# This is an early comment"
  
  [[2]][[2]]
  [[2]][[2]][[1]]
  NULL
  
  
  [[2]][[3]]
  [[2]][[3]][[1]]
  NULL
  
  
  [[2]][[4]]
  [[2]][[4]][[1]]
  NULL
  
  
  
  [[3]]
  [[3]][[1]]
  [1] "# multi"        "# line"         "# comment"      "# and another!"
  
  [[3]][[2]]
  [[3]][[2]][[1]]
  NULL
  
  
  [[3]][[3]]
  [[3]][[3]][[1]]
  NULL
  
  [[3]][[3]][[2]]
  [[3]][[3]][[2]][[1]]
  NULL
  
  
  [[3]][[3]][[3]]
  [[3]][[3]][[3]][[1]]
  NULL
  
  
  [[3]][[3]][[4]]
  [[3]][[3]][[4]][[1]]
  NULL
  
  
  
  [[3]][[4]]
  [[3]][[4]][[1]]
  NULL
  
  
  
  [[4]]
  [[4]][[1]]
  NULL
  
  [[4]][[2]]
  [[4]][[2]][[1]]
  NULL
  
  
  [[4]][[3]]
  [[4]][[3]][[1]]
  NULL
  
  
  [[4]][[4]]
  [[4]][[4]][[1]]
  NULL
  
  [[4]][[4]][[2]]
  [[4]][[4]][[2]][[1]]
  NULL
  
  
  [[4]][[4]][[3]]
  [[4]][[4]][[3]][[1]]
  [1] "# test that were not crazy" "# TRUE hopefully"          
  
  [[4]][[4]][[3]][[2]]
  [[4]][[4]][[3]][[2]][[1]]
  NULL
  
  
  [[4]][[4]][[3]][[3]]
  [[4]][[4]][[3]][[3]][[1]]
  NULL
  
  [[4]][[4]][[3]][[3]][[2]]
  [[4]][[4]][[3]][[3]][[2]][[1]]
  NULL
  
  
  [[4]][[4]][[3]][[3]][[3]]
  [[4]][[4]][[3]][[3]][[3]][[1]]
  NULL
  
  
  [[4]][[4]][[3]][[3]][[4]]
  [[4]][[4]][[3]][[3]][[4]][[1]]
  NULL
  
  
  
  [[4]][[4]][[3]][[4]]
  [[4]][[4]][[3]][[4]][[1]]
  NULL
  
  
  
  [[4]][[4]][[4]]
  [[4]][[4]][[4]][[1]]
  [1] "# Still not crazy"
  
  [[4]][[4]][[4]][[2]]
  [[4]][[4]][[4]][[2]][[1]]
  NULL
  
  
  [[4]][[4]][[4]][[3]]
  [[4]][[4]][[4]][[3]][[1]]
  NULL
  
  [[4]][[4]][[4]][[3]][[2]]
  [[4]][[4]][[4]][[3]][[2]][[1]]
  NULL
  
  
  [[4]][[4]][[4]][[3]][[3]]
  [[4]][[4]][[4]][[3]][[3]][[1]]
  NULL
  
  
  [[4]][[4]][[4]][[3]][[4]]
  [[4]][[4]][[4]][[3]][[4]][[1]]
  NULL
  
  
  
  [[4]][[4]][[4]][[4]]
  [[4]][[4]][[4]][[4]][[1]]
  NULL
  
  [[4]][[4]][[4]][[4]][[2]]
  [[4]][[4]][[4]][[4]][[2]][[1]]
  NULL
  
  
  [[4]][[4]][[4]][[4]][[3]]
  [[4]][[4]][[4]][[4]][[3]][[1]]
  NULL
  
  
  [[4]][[4]][[4]][[4]][[4]]
  [[4]][[4]][[4]][[4]][[4]][[1]]
  NULL
  
  
  
  
  
  
  [[5]]
  [[5]][[1]]
  NULL
  
  [[5]][[2]]
  [[5]][[2]][[1]]
  NULL
  
  
  [[5]][[3]]
  [[5]][[3]][[1]]
  NULL
  
  [[5]][[3]][[2]]
  [[5]][[3]][[2]][[1]]
  NULL
  
  
  [[5]][[3]][[3]]
  [[5]][[3]][[3]][[1]]
  NULL
  
  
  [[5]][[3]][[4]]
  [[5]][[3]][[4]][[1]]
  NULL
  
  
  
  
  [[6]]
  [[6]][[1]]
  [1] "# and this comment belongs to whom?"
  
  [[6]][[2]]
  [[6]][[2]][[1]]
  NULL
  
  
  [[6]][[3]]
  [[6]][[3]][[1]]
  NULL
  
  
  
  [[7]]
  [[7]][[1]]
  [1] "# and I?"
  
  [[7]][[2]]
  [[7]][[2]][[1]]
  NULL
  
  
  [[7]][[3]]
  [[7]][[3]][[1]]
  NULL
  
  
  
  > 
  > # "EQ_SUB and SYMBOL_SUB test"
  > unitizer:::comm_extract(
  +   unitizer:::parse_with_comments(
  +     text = "structure(1:3, # the data\nclass # the label\n=#the equal sign\n'hello' # the class\n)"
  + ) )
  [[1]]
  NULL
  
  [[2]]
  [[2]][[1]]
  NULL
  
  [[2]][[2]]
  [[2]][[2]][[1]]
  NULL
  
  
  [[2]][[3]]
  [[2]][[3]][[1]]
  [1] "# the data"
  
  [[2]][[3]][[2]]
  [[2]][[3]][[2]][[1]]
  NULL
  
  
  [[2]][[3]][[3]]
  [[2]][[3]][[3]][[1]]
  NULL
  
  
  [[2]][[3]][[4]]
  [[2]][[3]][[4]][[1]]
  NULL
  
  
  
  [[2]]$class
  [[2]]$class[[1]]
  [1] "# the label"     "#the equal sign" "# the class"    
  
  
  
  > 
  > # "Function with `exprlist`"
  > 
  > unitizer:::comm_extract(
  +   unitizer:::parse_with_comments(
  +     text = "function(x #first arg\n, y=25 #second arg with default\n) {x + y; # first comment\n; yo #second comment\n x / y; #lastcomment \n;}"
  + ) )
  [[1]]
  NULL
  
  [[2]]
  [[2]][[1]]
  NULL
  
  [[2]][[2]]
  [[2]][[2]][[1]]
  [1] "#first arg"
  
  
  [[2]][[3]]
  [[2]][[3]][[1]]
  NULL
  
  [[2]][[3]]$x
  [[2]][[3]]$x[[1]]
  NULL
  
  
  [[2]][[3]]$y
  [[2]][[3]]$y[[1]]
  NULL
  
  
  
  [[2]][[4]]
  [[2]][[4]][[1]]
  [1] "#second arg with default"
  
  [[2]][[4]][[2]]
  [[2]][[4]][[2]][[1]]
  NULL
  
  
  [[2]][[4]][[3]]
  [[2]][[4]][[3]][[1]]
  [1] "# first comment"
  
  [[2]][[4]][[3]][[2]]
  [[2]][[4]][[3]][[2]][[1]]
  NULL
  
  
  [[2]][[4]][[3]][[3]]
  [[2]][[4]][[3]][[3]][[1]]
  NULL
  
  
  [[2]][[4]][[3]][[4]]
  [[2]][[4]][[3]][[4]][[1]]
  NULL
  
  
  
  [[2]][[4]][[4]]
  [[2]][[4]][[4]][[1]]
  [1] "#second comment"
  
  
  [[2]][[4]][[5]]
  [[2]][[4]][[5]][[1]]
  [1] "#lastcomment "
  
  [[2]][[4]][[5]][[2]]
  [[2]][[4]][[5]][[2]][[1]]
  NULL
  
  
  [[2]][[4]][[5]][[3]]
  [[2]][[4]][[5]][[3]][[1]]
  NULL
  
  
  [[2]][[4]][[5]][[4]]
  [[2]][[4]][[5]][[4]][[1]]
  NULL
  
  
  
  
  [[2]][[5]]
  [[2]][[5]][[1]]
  NULL
  
  [[2]][[5]][[2]]
  [[2]][[5]][[2]][[1]]
  NULL
  
  
  [[2]][[5]][[3]]
  [[2]][[5]][[3]][[1]]
  NULL
  
  
  [[2]][[5]][[4]]
  [[2]][[5]][[4]][[1]]
  NULL
  
  
  [[2]][[5]][[5]]
  [[2]][[5]][[5]][[1]]
  NULL
  
  
  [[2]][[5]][[6]]
  [[2]][[5]][[6]][[1]]
  NULL
  
  
  [[2]][[5]][[7]]
  [[2]][[5]][[7]][[1]]
  NULL
  
  
  [[2]][[5]][[8]]
  [[2]][[5]][[8]][[1]]
  NULL
  
  
  [[2]][[5]][[9]]
  [[2]][[5]][[9]][[1]]
  NULL
  
  
  
  
  > 
  > # "`for` loop"
  > unitizer:::comm_extract(
  +   unitizer:::parse_with_comments(
  +     text = "for(i #in counter\nin 1:10#incounter again\n) {x + y; # first comment\n; next; yo #second comment\n x / y; break; #lastcomment \n;}"
  + ) )
  [[1]]
  NULL
  
  [[2]]
  [[2]][[1]]
  NULL
  
  [[2]][[2]]
  [[2]][[2]][[1]]
  NULL
  
  
  [[2]][[3]]
  [[2]][[3]][[1]]
  [1] "#in counter"
  
  
  [[2]][[4]]
  [[2]][[4]][[1]]
  [1] "#incounter again"
  
  [[2]][[4]][[2]]
  [[2]][[4]][[2]][[1]]
  NULL
  
  
  [[2]][[4]][[3]]
  [[2]][[4]][[3]][[1]]
  NULL
  
  
  [[2]][[4]][[4]]
  [[2]][[4]][[4]][[1]]
  NULL
  
  
  
  [[2]][[5]]
  [[2]][[5]][[1]]
  NULL
  
  [[2]][[5]][[2]]
  [[2]][[5]][[2]][[1]]
  NULL
  
  
  [[2]][[5]][[3]]
  [[2]][[5]][[3]][[1]]
  [1] "# first comment"
  
  [[2]][[5]][[3]][[2]]
  [[2]][[5]][[3]][[2]][[1]]
  NULL
  
  
  [[2]][[5]][[3]][[3]]
  [[2]][[5]][[3]][[3]][[1]]
  NULL
  
  
  [[2]][[5]][[3]][[4]]
  [[2]][[5]][[3]][[4]][[1]]
  NULL
  
  
  
  [[2]][[5]][[4]]
  [[2]][[5]][[4]][[1]]
  NULL
  
  
  [[2]][[5]][[5]]
  [[2]][[5]][[5]][[1]]
  [1] "#second comment"
  
  
  [[2]][[5]][[6]]
  [[2]][[5]][[6]][[1]]
  NULL
  
  [[2]][[5]][[6]][[2]]
  [[2]][[5]][[6]][[2]][[1]]
  NULL
  
  
  [[2]][[5]][[6]][[3]]
  [[2]][[5]][[6]][[3]][[1]]
  NULL
  
  
  [[2]][[5]][[6]][[4]]
  [[2]][[5]][[6]][[4]][[1]]
  NULL
  
  
  
  [[2]][[5]][[7]]
  [[2]][[5]][[7]][[1]]
  [1] "#lastcomment "
  
  
  
  
  > 
  > # "`if` statement"
  > unitizer:::comm_extract(unitizer:::parse_with_comments(text = if.text))
  [[1]]
  NULL
  
  [[2]]
  [[2]][[1]]
  NULL
  
  [[2]][[2]]
  [[2]][[2]][[1]]
  [1] "# IFFY"
  
  
  [[2]][[3]]
  [[2]][[3]][[1]]
  [1] "# ifcond"
  
  [[2]][[3]][[2]]
  [[2]][[3]][[2]][[1]]
  NULL
  
  
  [[2]][[3]][[3]]
  [[2]][[3]][[3]][[1]]
  NULL
  
  
  [[2]][[3]][[4]]
  [[2]][[3]][[4]][[1]]
  NULL
  
  
  
  [[2]][[4]]
  [[2]][[4]][[1]]
  NULL
  
  [[2]][[4]][[2]]
  [[2]][[4]][[2]][[1]]
  NULL
  
  
  [[2]][[4]][[3]]
  [[2]][[4]][[3]][[1]]
  NULL
  
  
  
  [[2]][[5]]
  [[2]][[5]][[1]]
  [1] "#final"
  
  
  
  > 
  > # "formula"
  > unitizer:::comm_extract(
  +   unitizer:::parse_with_comments(
  +     text = ". + x # hello\n#yowza\n~#bust a move\ny"
  + ) )
  [[1]]
  NULL
  
  [[2]]
  [[2]][[1]]
  [1] "# hello"
  
  [[2]][[2]]
  [[2]][[2]][[1]]
  NULL
  
  
  [[2]][[3]]
  [[2]][[3]][[1]]
  NULL
  
  
  [[2]][[4]]
  [[2]][[4]][[1]]
  NULL
  
  
  
  [[3]]
  [[3]][[1]]
  [1] "#yowza"
  
  [[3]][[2]]
  [[3]][[2]][[1]]
  [1] "#bust a move"
  
  
  [[3]][[3]]
  [[3]][[3]][[1]]
  NULL
  
  
  
  > 
  > # "`repeat`"
  > unitizer:::comm_extract(
  +   unitizer:::parse_with_comments(
  +     text = "repeat #first\n{runif(10); #comm\nbreak;}"
  + ) )
  [[1]]
  NULL
  
  [[2]]
  [[2]][[1]]
  NULL
  
  [[2]][[2]]
  [[2]][[2]][[1]]
  [1] "#first"
  
  
  [[2]][[3]]
  [[2]][[3]][[1]]
  NULL
  
  [[2]][[3]][[2]]
  [[2]][[3]][[2]][[1]]
  NULL
  
  
  [[2]][[3]][[3]]
  [[2]][[3]][[3]][[1]]
  [1] "#comm"
  
  [[2]][[3]][[3]][[2]]
  [[2]][[3]][[3]][[2]][[1]]
  NULL
  
  
  [[2]][[3]][[3]][[3]]
  [[2]][[3]][[3]][[3]][[1]]
  NULL
  
  
  
  [[2]][[3]][[4]]
  [[2]][[3]][[4]][[1]]
  NULL
  
  
  
  
  > 
  > # "S4 slot"
  > unitizer:::comm_extract(
  +   unitizer:::parse_with_comments(text = "test@#comment\nhello <- 3")
  + )
  [[1]]
  NULL
  
  [[2]]
  [[2]][[1]]
  NULL
  
  [[2]][[2]]
  [[2]][[2]][[1]]
  NULL
  
  
  [[2]][[3]]
  [[2]][[3]][[1]]
  NULL
  
  [[2]][[3]][[2]]
  [[2]][[3]][[2]][[1]]
  [1] "#comment"
  
  
  [[2]][[3]][[3]]
  [[2]][[3]][[3]][[1]]
  NULL
  
  
  [[2]][[3]][[4]]
  [[2]][[3]][[4]][[1]]
  NULL
  
  
  
  [[2]][[4]]
  [[2]][[4]][[1]]
  NULL
  
  
  
  > 
  > #  "`while`"
  > unitizer:::comm_extract(
  +   unitizer:::parse_with_comments(
  +     text = "while(x > 5 # a comment\n) { hello; goodbye } #yay"
  + ) )
  [[1]]
  NULL
  
  [[2]]
  [[2]][[1]]
  NULL
  
  [[2]][[2]]
  [[2]][[2]][[1]]
  NULL
  
  
  [[2]][[3]]
  [[2]][[3]][[1]]
  [1] "# a comment"
  
  [[2]][[3]][[2]]
  [[2]][[3]][[2]][[1]]
  NULL
  
  
  [[2]][[3]][[3]]
  [[2]][[3]][[3]][[1]]
  NULL
  
  
  [[2]][[3]][[4]]
  [[2]][[3]][[4]][[1]]
  NULL
  
  
  
  [[2]][[4]]
  [[2]][[4]][[1]]
  NULL
  
  [[2]][[4]][[2]]
  [[2]][[4]][[2]][[1]]
  NULL
  
  
  [[2]][[4]][[3]]
  [[2]][[4]][[3]][[1]]
  NULL
  
  
  [[2]][[4]][[4]]
  [[2]][[4]][[4]][[1]]
  NULL
  
  
  
  
  > 
  > txt2 <- "library(functools)\n    fun <- function(a=1, bravo, card=25, ..., xar=list(\"aurochs\", 1), z) {}\n\n    # Need to add tests:\n    # - with complex objects? (did I mean in the definition? Or the call??)\n    (NULL)\n    # These should be identical to match.call()\n\n    body(fun) <- parse(text=\"{print(match_call()); print(match.call())}\")\n\n    calls <- c(\n      'fun(54, \"hello\", \"wowo\", \"blergh\", 8, 9)',\n      'fun(54, \"hello\", \"wowo\", \"blergh\", a=8, z=9)',\n      'fun(54, \"hello\", z=\"wowo\", \"blergh\", 8, 9)',\n      'fun(54, \"hello\", z=\"wowo\", x=\"blergh\", 8, 9)',\n      'fun(54, c=\"hello\", z=\"wowo\", xar=3, 8, 9)'\n    )\n    invisible(lapply(calls, function(x){cat(\"-- New Call --\", x, sep=\"\n\"); eval(parse(text=x))}))\n  "
  > test.comp <- unitizer:::comm_extract(unitizer:::parse_with_comments(text = txt2))
  > 
  > # "A more complex test"
  > lapply(test.comp[4:5], `[[`, 1)
  [[1]]
  [1] "# Need to add tests:"                                                   
  [2] "# - with complex objects? (did I mean in the definition? Or the call??)"
  
  [[2]]
  [1] "# These should be identical to match.call()"
  
  > 
  > # "Added SYMBOL_PACKAGE token"
  > unitizer:::comm_extract(
  +   unitizer:::parse_with_comments(
  +     text = "# a comment before\nunitizer:::browse()  #a comment after"
  + ) )
  [[1]]
  NULL
  
  [[2]]
  [[2]][[1]]
  [1] "# a comment before" "#a comment after"  
  
  
  > # "Added SYMBOL_PACKAGE token v2" 
  > unitizer:::comm_extract(
  +   unitizer:::parse_with_comments(
  +     text = "# a comment before\nunitizer::browse()  #a comment after"
  + ) )
  [[1]]
  NULL
  
  [[2]]
  [[2]][[1]]
  [1] "# a comment before" "#a comment after"  
  
  
  > # LBB used to break stuff
  > txt3 <- "# This is an early comment\n    hello <- 25\n    # multi\n    hello[[1]]  # and another!"
  > # "LBB test"
  > unitizer:::comm_extract(unitizer:::parse_with_comments(text = txt3))
  [[1]]
  NULL
  
  [[2]]
  [[2]][[1]]
  [1] "# This is an early comment"
  
  [[2]][[2]]
  [[2]][[2]][[1]]
  NULL
  
  
  [[2]][[3]]
  [[2]][[3]][[1]]
  NULL
  
  
  [[2]][[4]]
  [[2]][[4]][[1]]
  NULL
  
  
  
  [[3]]
  [[3]][[1]]
  [1] "# multi"        "# and another!"
  
  [[3]][[2]]
  [[3]][[2]][[1]]
  NULL
  
  
  [[3]][[3]]
  [[3]][[3]][[1]]
  NULL
  
  
  [[3]][[4]]
  [[3]][[4]][[1]]
  NULL
  
  
  
  > 
  > # - "Weird missing comment on `res` works" -------------------------------------
  > 
  > txt3 <- "# Calls to `library` and assignments are not normally considered tests, so\n# you will not be prompted to review them\n\nlibrary(utzflm)\nx <- 1:100\ny <- x ^ 2\nres <- fastlm(x, y)\n\nres                     # first reviewable expression\nget_slope(res)\nget_rsq(res)\n\nfastlm(x, head(y))      # This should cause an error; press Y to add to store"
  > expr <- unitizer:::parse_with_comments(text = txt3)
  > my.unitizer <- new("unitizer", id = 1, zero.env = new.env())
  > capture.output(my.unitizer <- my.unitizer + expr)
  character(0)
  > 
  > lapply(unitizer:::as.list(my.unitizer@items.new), slot, "comment")
  [[1]]
  [1] "# Calls to `library` and assignments are not normally considered tests, so"
  [2] "# you will not be prompted to review them"                                 
  
  [[2]]
  character(0)
  
  [[3]]
  character(0)
  
  [[4]]
  character(0)
  
  [[5]]
  [1] "# first reviewable expression"
  
  [[6]]
  character(0)
  
  [[7]]
  character(0)
  
  [[8]]
  [1] "# This should cause an error; press Y to add to store"
  
  > 
  > # - "exprlist excission with negative par ids" ---------------------------------
  > 
  > txt <- "# For random tests\n\nunitizer_sect(\"blah\", {\n  identity(1);\n})\n"
  > prs.dat <- unitizer:::parse_dat_get(text = txt)$dat
  > # set negative ids to be top level parents
  > prs.dat <- transform(prs.dat, parent = ifelse(parent < 0, 0L, 
  +     parent))
  > prs.dat <- normalize_id(prs.dat)
  > ancestry <- with(prs.dat, unitizer:::ancestry_descend(id, parent, 
  +     0L))
  > x <- unitizer:::prsdat_fix_exprlist(prs.dat, ancestry)
  > unname(as.matrix(x[, 5:6]))
        [,1] [,2]
   [1,]    1    0
   [2,]   21    0
   [3,]    2    4
   [4,]    4   21
   [5,]    3   21
   [6,]    5    7
   [7,]    7   21
   [8,]    6   21
   [9,]   19   21
  [10,]    8   19
  [11,]   15   19
  [12,]    9   11
  [13,]   11   15
  [14,]   10   15
  [15,]   12   13
  [16,]   13   15
  [17,]   14   15
  [18,]   18   19
  [19,]   20   21
  > 
  > # - "empty symbols handled okay" -----------------------------------------------
  > 
  > # the empty second argument to `[` caused problems before
  > txt <- "mtcars[1:10,]\n"
  > # shouldn't cause error
  > unitizer:::parse_with_comments(text = txt)
  expression(mtcars[1:10,])
  > 
  > # - "uncommenting works" -------------------------------------------------------
  > 
  > unitizer:::uncomment(expr[[1]])
  library(utzflm)
  > 
  > # "don't blow away function arg names"
  > unitizer:::uncomment(quote(function(a, b) NULL))
  function(a, b) NULL
  > #
  > # Recover comments and uncomment
  > txt <- ".alike(  # FALSE, match.call disabled\n  quote(fun(b=fun2(x, y), 1, 3)),  # first sub.call\n  quote(fun(NULL, fun2(a, b), 1)), # second sub.call\n  alike_settings(lang.mode=1))"
  > exp <- unitizer:::parse_with_comments(text = txt)
  > candc <- unitizer:::comm_and_call_extract(exp)
  > 
  > candc$call[[1L]]
  .alike(quote(fun(b = fun2(x, y), 1, 3)), quote(fun(NULL, fun2(a, 
      b), 1)), alike_settings(lang.mode = 1))
  > 
  > candc$comments
  [1] "# FALSE, match.call disabled" "# first sub.call"            
  [3] "# second sub.call"           
  > 
  > # - "failing parses produce proper errors" -------------------------------------
  > 
  > txt <- "this is a + syntax error that cannot be parsed"
  > try(capture.output(unitizer:::parse_tests(text = txt), type = "message"))
  Error in value[[3L]](cond) : 
    Unable to parse test file; see previous messages
  > f <- tempfile()
  > on.exit(unlink(f))
  > cat(txt, "\n", sep = "", file = f)
  > try(capture.output(unitizer:::parse_tests(f), type = "message"))
  Error in value[[3L]](cond) : 
    Unable to parse test file; see previous messages
  > # try in normal mode (just fall back to normal parse)
  > try(unitizer:::parse_tests(text = txt, comments = FALSE))
  Error in parse(text = text, keep.source = FALSE) : 
    <text>:1:6: unexpected symbol
  1: this is
           ^
  > 
  > any(
  +   grepl(
  +     "unexpected symbol",
  +     capture.output(try(unitizer:::parse_tests(f, comments = FALSE)), type='message'),
  + ) )
  [1] TRUE
  > 
  > # - "NULL, constants, and new tokens" ------------------------------------------
  > 
  > # These were added with 3.6.3?  Previously, it seems that the equal assign did
  > # not generate a master expression to wrap all the pieces, which means these
  > # tests just don't work because all the eq_assign at the top level end up with
  > # the same parent and the parser gets confused.
  > 
  > txt <- c("a = 2", "# ho how", "b = 3", "", "b + a  # oh here", 
  +     "", "b + # oh there", "a   # bear", "", "NULL")
  > if(getRversion() >= "3.6.3") {
  +   identical(
  +     unitizer:::comm_extract(unitizer:::parse_with_comments(text = txt)),
  +     rds('parse-eq')
  +   )
  + } else TRUE
  [1] TRUE
  > 
  > with.const <- unitizer:::parse_with_comments(text = "3 # comment on const")
  > unitizer:::symb_mark_rem(with.const[[1]])
  [1] 3
  > 
  > 
  > proc.time()
     user  system elapsed 
     0.93    0.10    1.03 
Running the tests in 'tests/t-prompt.R' failed.
Complete output:
  > source(file.path("_helper", "init.R"))
  > 
  > # - "read_line works" ----------------------------------------------------------
  > 
  > # read through prompt vals
  > 
  > unitizer:::read_line_set_vals(letters[1:3])
  > u.ns <- asNamespace("unitizer")
  > unitizer:::read_line()
  a
  [1] "a"
  > identical(u.ns$.global$prompt.vals, letters[2:3])
  [1] TRUE
  > unitizer:::read_line()
  b
  [1] "b"
  > u.ns$.global$prompt.vals
  [1] "c"
  > unitizer:::read_line()
  c
  [1] "c"
  > u.ns$.global$prompt.vals
  character(0)
  > 
  > try(unitizer:::read_line())
  Error : Internal Error: ran out of predefined readline input; contact maintainer.
  > 
  > # - "simple prompts" -----------------------------------------------------------
  > 
  > unitizer:::read_line_set_vals(c("y", "Y", "n", "N"))
  > try(unitizer:::simple_prompt(1:5))
  Error in unitizer:::simple_prompt(1:5) : 
    Argument `message` must be character
  > try(unitizer:::simple_prompt("hello", attempts = 1:5))
  Error in unitizer:::simple_prompt("hello", attempts = 1:5) : 
    Argument `attempts` must be numeric(1L), not NA, and one or greater
  > try(unitizer:::simple_prompt("hello", values = NA_character_))
  Error in unitizer:::simple_prompt("hello", values = NA_character_) : 
    Argument `values` must be character with no NAs
  > try(unitizer:::simple_prompt("hello", case.sensitive = 1))
  Error in unitizer:::simple_prompt("hello", case.sensitive = 1) : 
    Argument `case.sensitive` must be TRUE or FALSE
  > 
  > unitizer:::simple_prompt("hello")
  | hello
  
  unitizer> y
  [1] "Y"
  > unitizer:::simple_prompt("hello")#
  | hello
  
  unitizer> Y
  [1] "Y"
  > unitizer:::simple_prompt("hello")
  | hello
  
  unitizer> n
  [1] "N"
  > unitizer:::read_line_set_vals(c("y", "y", "n"))
  > try(unitizer:::simple_prompt("hello", attempts = 1L, case.sensitive = TRUE))
  | hello
  
  unitizer> y
  | Invalid input, please select one of: Y, N
  
  Error in unitizer:::simple_prompt("hello", attempts = 1L, case.sensitive = TRUE) : 
    Gave up trying to collect user input after 1 attempts.
  > try(unitizer:::simple_prompt("hello", attempts = 1L, case.sensitive = TRUE),
  +     silent = TRUE)
  | hello
  
  unitizer> y
  | Invalid input, please select one of: Y, N
  
  > try(unitizer:::simple_prompt("hello", attempts = 1L, case.sensitive = TRUE))
  | hello
  
  unitizer> n
  | Invalid input, please select one of: Y, N
  
  Error in unitizer:::simple_prompt("hello", attempts = 1L, case.sensitive = TRUE) : 
    Gave up trying to collect user input after 1 attempts.
  > 
  > # - "faux prompt" --------------------------------------------------------------
  > 
  > unitizer:::read_line_set_vals(c("1 +", "1"))
  > unitizer:::faux_prompt(prompt = "> ", continue = "+ ")[[1L]]
  > 1 +
  + 1
  1 + 1
  > unitizer:::read_line_set_vals(c("(})"))
  > try(unitizer:::faux_prompt(prompt = "> ", continue = "+ "))
  > (})
  Error in "(})" : <text>:1:2: unexpected '}'
  1: (}
       ^
  > 
  > ## Test the new readLines based read_line
  > ## This test will not work in interactive mode, requiring input
  > unitizer:::read_line_set_vals(c("1 +", "1"))
  > unitizer:::faux_prompt()
  > 1 +
  + 1
  expression(1 + 1)
  > 
  > ## This one embeds a CTRL+C to test interrupt, but we can't test this without
  > ## read_line_setvals
  > unitizer:::read_line_set_vals(c("1 +", "\x03", "2 + ", "1"))
  > unitizer:::faux_prompt()
  > 1 +
  + 
  
  > 2 + 
  + 1
  expression(2 + 1)
  > 
  > unitizer:::read_line_set_vals(c("\x03", "2 + ", "1"))
  > unitizer:::faux_prompt()
  > 
  
  
  | Type "Q" at the prompt to quit unitizer.
  
  > 2 + 
  + 1
  expression(2 + 1)
  > 
  > ## Test that changing language doesn't affect partial parsing
  > lang <- Sys.getenv("LANGUAGE", unset=NA)
  > Sys.setenv("LANGUAGE"="fr")
  > unitizer:::read_line_set_vals(c("1 +", "1"))
  > unitizer:::faux_prompt(prompt = "> ", continue = "+ ")
  > 1 +
  + 1
  expression(1 + 1)
  > if(is.na(lang)) Sys.unsetenv("LANGUAGE") else Sys.setenv("LANGUAGE"=lang)
  > 
  > # - "unitizer prompt" ----------------------------------------------------------
  > 
  > # Some of this needs to be done outside of testthat due to sinking
  > suppressWarnings(glob <- unitizer:::unitizerGlobal$new())
  > unitizer:::read_line_set_vals(c("1 +", "1", "H", "Y"))
  > unitizer:::unitizer_prompt(
  +   "hello", valid.opts = c(Y = "[Y]es", N = "[N]o"), global = glob
  + )
  unitizer> 1 +
  + 1
  [1] 2
  unitizer> H
  
  | No help available.
  | 
  | hello ([Y]es, [N]o, [Q]uit, [H]elp)?
  
  unitizer> Y
  
  [1] "Y"
  > 
  > unitizer:::read_line_set_vals(c("1 +", "1", "H", "Q"))
  > unitizer:::unitizer_prompt("hello",
  +     valid.opts = c(Y = "[Y]es", N = "[N]o"), help = "This is all the help you get",
  +     global = glob)
  unitizer> 1 +
  + 1
  [1] 2
  unitizer> H
  
  | This is all the help you get
  | 
  | hello ([Y]es, [N]o, [Q]uit, [H]elp)?
  
  unitizer> Q
  
  [1] "Q"
  > 
  > unitizer:::read_line_set_vals(c("hell())", "Q"))
  > txt3 <- unitizer:::capture_output(unitizer:::unitizer_prompt("hello",
  +     valid.opts = c(Y = "[Y]es", N = "[N]o"), global = glob))
  > txt3$message
  [1] "Error in \"hell())\": <text>:1:7: unexpected ')'"
  [2] "1: hell())"                                      
  [3] "          ^"                                     
  > 
  > # and multiline stuff (#242)
  > unitizer:::read_line_set_vals(c("{\n  1 + 1\n  2 + 1\n}", "N"))
  > unitizer:::unitizer_prompt(
  +   "hello", valid.opts = c(Y = "[Y]es", N = "[N]o"), global = glob
  + )
  unitizer> {
    1 + 1
    2 + 1
  }
  [1] 3
  unitizer> N
  
  [1] "N"
  > 
  > try(
  +   unitizer:::unitizer_prompt(
  +     "hello", valid.opts = c(Y = "[Y]es", N = "[N]o"),
  +     browse.env = "not an env", global = glob
  + ) )
  Error in unitizer:::unitizer_prompt("hello", valid.opts = c(Y = "[Y]es",  : 
    Argument `browse.env` must be an environment
  > 
  > unitizer:::read_line_set_vals(character())
  > try(
  +   unitizer:::unitizer_prompt(
  +     "hello", valid.opts = c(Y = "[Y]es", N = "[N]o"), global = glob
  + ) )
  Error : Internal Error: ran out of predefined readline input; contact maintainer.
  > unitizer:::read_line_set_vals("1L")
  > try(
  +   unitizer:::unitizer_prompt(
  +     "hello",
  +     valid.opts = c(Y = "[Y]es", N = "[N]o"),
  +     exit.condition = unitizer:::exit_fun,
  +     valid.vals = 2:3, global = glob
  + ) )
  unitizer> 1L
  | Type a number in `2:3` at the prompt
  [1] 1
  Error : Internal Error: ran out of predefined readline input; contact maintainer.
  > unitizer:::read_line_set_vals("2L")
  > unitizer:::unitizer_prompt("hello", valid.opts = c(Y = "[Y]es",
  +     N = "[N]o"), exit.condition = unitizer:::exit_fun, valid.vals = 2:3,
  +     global = glob)
  unitizer> 2L
  [1] 2
  > 
  > 
  > proc.time()
     user  system elapsed 
     0.54    0.14    0.67 
Running the tests in 'tests/t-repairenvs.R' failed.
Complete output:
  > source(file.path("_helper", "init.R"))
  > 
  > exps <- expression(1 + 1, a <- 54, b <- 38, a + b, e <- 5 * a,
  +     a^2, f <- e * a, matrix(rep(f, 20)))
  > my.unitizer <- new("unitizer", id = 1, zero.env = new.env())
  > # add ref.exps as new items
  > coi(my.unitizer <- my.unitizer + exps)
  > my.unitizer2 <- new("unitizer", id = 2, zero.env = new.env())
  > # now convert them to reference items
  > coi(my.unitizer2 <- my.unitizer2 + my.unitizer@items.new)
  > # - "messed up env ancestry repair works" --------------------------------------
  > 
  > # Purposefully mess up the environments
  > parent.env(my.unitizer2@items.ref[[2]]@env) <- baseenv()
  > x <- unitizer:::healEnvs(my.unitizer2@items.ref, my.unitizer2)
  Error in parent.env(env) : the empty environment has no parent
  Error in run_ls(env = x@env, stop.env = base.env, all.names = TRUE, store.env = ref.env.store) : 
    Specified `stop.env` does not appear to be in parent environments.
  Warning in repairEnvs(items.final) :
    Detected corrupted environment history; we will attempt to repair, but keep in mind that even when repaired the test environments may be missleading.  For example, the objects other than `.new` or `.ref` when reviewing tests at the `unitzer` prompt may not be those you expect or those reported by `ls`.  To fully restore environments re-unitize with `unitize(..., force.update=TRUE)`.  If errors persist after an attempt to repair, please contact maintainer.
  > old.opt <- options(unitizer.max.env.depth = 20)
  > res <- unitizer:::healEnvs(my.unitizer2@items.ref, my.unitizer2)
  Error in try(while (!identical(env, stop.env)) { : 
    Logic error: not finding `stop.env` after 20 iterations; contact package maintainer if this is an error.
  Error in run_ls(env = x@env, stop.env = base.env, all.names = TRUE, store.env = ref.env.store) : 
    Specified `stop.env` does not appear to be in parent environments.
  Warning in repairEnvs(items.final) :
    Detected corrupted environment history; we will attempt to repair, but keep in mind that even when repaired the test environments may be missleading.  For example, the objects other than `.new` or `.ref` when reviewing tests at the `unitzer` prompt may not be those you expect or those reported by `ls`.  To fully restore environments re-unitize with `unitize(..., force.update=TRUE)`.  If errors persist after an attempt to repair, please contact maintainer.
  > is(res, "unitizerItems")
  [1] TRUE
  > ref.anc <- unitizer:::env_ancestry(x@base.env)
  > itm.anc <- unitizer:::env_ancestry(x[[1L]]@env)
  > # Items should belong to base env for reference
  > identical(rev(ref.anc), head(rev(itm.anc), length(ref.anc)))
  [1] TRUE
  > options(old.opt)
  > 
  > # - "re-assigning to ignored environments handled properly" --------------------
  > 
  > # now `a + b` could try to re-assign to `a <- 54`, but that is same env as
  > # `a + b` b/c it is ignored
  > items.picked <- my.unitizer@items.new[-3L]
  > # expect_error(items.heal <- unitizer:::healEnvs(items.picked,
  > #     my.unitizer), NA)
  > # no error
  > items.heal <- unitizer:::healEnvs(items.picked, my.unitizer)
  > 
  > # - "full repair process works" ------------------------------------------------
  > 
  > # copy files and then try messing up environment for the object
  > file_test("-d", file.path("_helper"))
  [1] TRUE
  > store <- file.path("_helper", "unitizers", "trivial.unitizer")
  > store.new <- file.path(TMP.DIR, store)
  > dir.create(store.new, recursive = TRUE)
  > cpy.files <- c(
  +   list.files(store, full.names = TRUE),
  +   file.path("helper", "unitizers", "trivial.R")
  + )
  > file.copy(cpy.files, file.path(TMP.DIR, cpy.files), overwrite = TRUE)
  [1]  TRUE FALSE
  > 
  > untz <- unitizer:::load_unitizers(
  +   list(store.new), NA_character_,
  +   par.frame = .GlobalEnv, interactive.mode = TRUE, mode = "unitize",
  +   show.progress=0L, transcript=FALSE
  + )
  Warning in unitizer:::load_unitizers(list(store.new), NA_character_, par.frame = .GlobalEnv,  :
    Upgraded test file does not match original test file ('trivial.R' vs 'NA').
  Warning in .Object$initialize(...) :
    Instantiated global object without global namespace registry; you should only see this warning you are using `repair_environments`.
  > # Break env chain, store, and reload
  > untz[[1L]]@items.ref.calls.deparse[[5L]]
  [1] "y * x"
  > parent.env(untz[[1L]]@items.ref[[5L]]@env) <- baseenv()
  > # warning
  > unitizer:::store_unitizer(untz[[1L]])
  | unitizer updated.
  
  > untz.rep <- repair_environments(store.new)
  Warning in .Object$initialize(...) :
    Instantiated global object without global namespace registry; you should only see this warning you are using `repair_environments`.
  Warning in repairEnvs(x@items.ref) :
    Detected corrupted environment history; we will attempt to repair, but keep in mind that even when repaired the test environments may be missleading.  For example, the objects other than `.new` or `.ref` when reviewing tests at the `unitzer` prompt may not be those you expect or those reported by `ls`.  To fully restore environments re-unitize with `unitize(..., force.update=TRUE)`.  If errors persist after an attempt to repair, please contact maintainer.
  | unitizer updated.
  
  > # this should not give warnings
  > unitizer:::healEnvs(untz.rep@items.ref, untz.rep)
  An object of class "unitizerItems"
  Slot "base.env":
  <environment: 0x0000025d7b72af80>
  
  Slot ".items":
  [[1]]
  ~~~ Reference Test ~~~
  TRUE
  * value: logi[1]
  * output: 9 chars
  
  Access components with `$`, e.g. `.REF$value`; see `help("$", "unitizer")`
  
  [[2]]
  ~~~ Reference Test ~~~
  x <- 1 + 1
  * value: unitizerDummy
  
  Access components with `$`, e.g. `.REF$value`; see `help("$", "unitizer")`
  
  [[3]]
  ~~~ Reference Test ~~~
  x + 2
  * value: num[1]
  * output: 6 chars
  
  Access components with `$`, e.g. `.REF$value`; see `help("$", "unitizer")`
  
  [[4]]
  ~~~ Reference Test ~~~
  y <- x
  * value: unitizerDummy
  
  Access components with `$`, e.g. `.REF$value`; see `help("$", "unitizer")`
  
  [[5]]
  ~~~ Reference Test ~~~
  y * x
  * value: num[1]
  * output: 6 chars
  
  Access components with `$`, e.g. `.REF$value`; see `help("$", "unitizer")`
  
  [[6]]
  ~~~ Reference Test ~~~
  y/x + 2
  * value: num[1]
  * output: 6 chars
  
  Access components with `$`, e.g. `.REF$value`; see `help("$", "unitizer")`
  
  
  Slot ".pointer":
  [1] 0
  
  Slot ".seek.fwd":
  [1] TRUE
  
  > 
  > 
  > proc.time()
     user  system elapsed 
     1.00    0.15    1.14 
Running the tests in 'tests/t-section.R' failed.
Complete output:
  > source(file.path("_helper", "init.R"))
  > 
  > expr.1 <- expression(1 + 1, b <- 5, matrix(integer(), nrow = b,
  +     ncol = b))
  > expr.2 <- {
  +     1 + 1
  +     b <- 5
  +     matrix(integer(), nrow = b, ncol = b)
  + }
  > expr.3 <- quote(expression(1 + 1, b <- 5, matrix(integer(), nrow = b,
  +     ncol = b)))
  > expr.4 <- quote({
  +     1 + 1
  +     b <- 5
  +     matrix(integer(), nrow = b, ncol = b)
  + })
  > # - "simple tests" -------------------------------------------------------------
  > 
  > try(unitizer_sect(1:3))
  Error in unitizer_sect(1:3) : 
    Argument `title` must be a 1 length character vector.
  > try(unitizer_sect(letters))
  Error in unitizer_sect(letters) : 
    Argument `title` must be a 1 length character vector.
  > try(unitizer_sect("mytest", expr.1, 1:3))
  Error in unitizer_sect("mytest", expr.1, 1:3) : 
    Argument `details` must be character
  > # note the following two produce error messages, but it's not actually an error,
  > # it's just that there are multiple errors and `expect_error` only suppresses
  > # the last one, not the preceding ones.
  > try(unitizer_sect("mytest", expr.1, letters, letters))
  Error in unitizer_sect("mytest", expr.1, letters, letters) : 
    Argument `compare` must be "testFuns" or a function
  > try(unitizer_sect("mytest", expr.1, letters, identity))
  Error in unitizer_sect("mytest", expr.1, letters, identity) : 
    Argument `compare`, if a function, must accept two arguments and require no more than two (does not have at least two arguments)
  > try(unitizer_sect("mytest", expr.2))
  Error in unitizer_sect("mytest", expr.2) : 
    Argument `expr` must be an expression, or an unevaluated call that evaluates to an expression or `{`.
  > try(unitizer_sect("mytest", matrix(1:9, nrow = 3)))
  Error in unitizer_sect("mytest", matrix(1:9, nrow = 3)) : 
    Argument `expr` must be an expression, or an unevaluated call that evaluates to an expression or `{`.
  > is(sect.1 <- unitizer_sect("mytest", expr.1), "unitizerSectionExpression")
  [1] TRUE
  > identical(unitizer:::as.expression(sect.1), expr.1)
  [1] TRUE
  > 
  > is(sect.2 <- unitizer_sect("mytest", {
  +     1 + 1
  +     b <- 5
  +     matrix(integer(), nrow = b, ncol = b)
  + }), "unitizerSectionExpression")
  [1] TRUE
  > identical(sect.1, sect.2)
  [1] TRUE
  > is(sect.3 <- unitizer_sect("mytest", expr.3), "unitizerSectionExpression")
  [1] TRUE
  > identical(sect.1, sect.3)
  [1] TRUE
  > is(sect.4 <- unitizer_sect("mytest", expr.4), "unitizerSectionExpression")
  [1] TRUE
  > identical(sect.1, sect.4)
  [1] TRUE
  > is(sect.5 <- unitizer_sect("mytest", expression(1 + 1,
  +     b <- 5, matrix(integer(), nrow = b, ncol = b))), "unitizerSectionExpression")
  [1] TRUE
  > identical(sect.1, sect.5)
  [1] TRUE
  > is(sect.1 <- unitizer_sect("mytest", expr.1, compare = identical),
  +     "unitizerSectionExpression")
  [1] TRUE
  > unitizer_sect("hello")  # warn
  Warning in unitizer_sect("hello") : `unitizer_sect` "hello" is empty.
  NULL
  > 
  > # - "Custom Comparison Functions" ----------------------------------------------
  > 
  > # Run expressions with different comparison functions
  > set.seed(1)
  > expr.1 <- expression(50 + runif(1)/10^10, message("Hello There",
  +     runif(1)), cat("Hello there", runif(1)), stop("Yo", runif(1)))
  > expr.2 <- expression(50 + runif(1)/10^10, message("Hello There",
  +     runif(1)), cat("Hello there", runif(1)), stop("Yo", runif(1)))
  > expr.3 <- expression(unitizer_sect("change comp funs", compare = identical,
  +     {
  +         50 + runif(1)/10^10
  +         message("Hello There", runif(1))
  +         cat("Hello there", runif(1))
  +         stop("Yo", runif(1))
  +     }))
  > expr.4 <- expression(
  +   unitizer_sect(
  +     "change comp funs",
  +     compare = testFuns(
  +       value = identical, output = all.equal, message = all.equal,
  +       conditions = function(x, y) TRUE),
  +       {
  +         50 + runif(1)/10^10
  +         message("Hello There", runif(1))
  +         cat("Hello there", runif(1))
  +         stop("Yo", runif(1))
  + }))
  > my.unitizer <- new("unitizer", id = 1, zero.env = new.env())
  > coi(my.unitizer <- my.unitizer + expr.1)
  > my.unitizer2 <- new("unitizer", id = 2, zero.env = new.env())
  > # make previous items into reference items
  > coi(my.unitizer2 <- my.unitizer2 + my.unitizer@items.new)
  > # now add back items to compare
  > coi(my.unitizer2 <- my.unitizer2 + expr.2)
  > my.unitizer3 <- new("unitizer", id = 3, zero.env = new.env())
  > # make previous items into reference items
  > coi(my.unitizer3 <- my.unitizer3 + my.unitizer@items.new)
  > # now add back items to compare
  > coi(my.unitizer3 <- my.unitizer3 + expr.3)
  > my.unitizer4 <- new("unitizer", id = 4, zero.env = new.env())
  > # make previous items into reference items
  > coi(my.unitizer4 <- my.unitizer4 + my.unitizer@items.new)
  > # now add back items to compare
  > coi(my.unitizer4 <- my.unitizer4 + expr.4)
  > 
  > my.unitizer2@tests.result
       value conditions output message aborted
  [1,]  TRUE       TRUE   TRUE    TRUE    TRUE
  [2,]  TRUE      FALSE   TRUE    TRUE    TRUE
  [3,]  TRUE       TRUE   TRUE    TRUE    TRUE
  [4,]  TRUE      FALSE   TRUE    TRUE    TRUE
  > my.unitizer3@tests.result
       value conditions output message aborted
  [1,] FALSE       TRUE   TRUE    TRUE    TRUE
  [2,]  TRUE      FALSE   TRUE    TRUE    TRUE
  [3,]  TRUE       TRUE   TRUE    TRUE    TRUE
  [4,]  TRUE      FALSE   TRUE    TRUE    TRUE
  > my.unitizer4@tests.result
       value conditions output message aborted
  [1,] FALSE       TRUE   TRUE    TRUE    TRUE
  [2,]  TRUE       TRUE   TRUE   FALSE    TRUE
  [3,]  TRUE       TRUE  FALSE    TRUE    TRUE
  [4,]  TRUE       TRUE   TRUE   FALSE    TRUE
  > 
  > 
  > proc.time()
     user  system elapsed 
     0.90    0.09    0.98 
Running the tests in 'tests/t-state.R' failed.
Complete output:
  > source(file.path("_helper", "init.R"))
  > 
  > options(unitizer.color = FALSE, width = 80L)
  > 
  > # - "Random Seed" --------------------------------------------------------------
  > 
  > old.seed <- if (!exists(".Random.seed")) NULL else .Random.seed
  > seed.dat <- getOption("unitizer.seed")
  > 
  > suppressWarnings(
  +   untz.glob <-
  +     unitizer:::unitizerGlobal$new(enable.which = setNames(2L, "random.seed"))
  + )
  > do.call(set.seed, seed.dat)
  > new.seed <- .Random.seed
  > state <- untz.glob$state()
  > invisible(runif(10))    # see if we can reset state after this
  > untz.glob$reset(state)
  An object of class "unitizerGlobalIndices"
  Slot "search.path":
  [1] 0
  
  Slot "options":
  [1] 0
  
  Slot "working.directory":
  [1] 0
  
  Slot "random.seed":
  [1] 2
  
  Slot "namespaces":
  [1] 0
  
  > identical(.Random.seed, new.seed)
  [1] TRUE
  > untz.glob$resetFull()
  An object of class "unitizerGlobalIndices"
  Slot "search.path":
  [1] 1
  
  Slot "options":
  [1] 1
  
  Slot "working.directory":
  [1] 1
  
  Slot "random.seed":
  [1] 1
  
  Slot "namespaces":
  [1] 1
  
  > 
  > if (is.null(old.seed)) {
  +   !isTRUE(exists(".Random.seed"))
  + } else identical(old.seed, .Random.seed)
  [1] TRUE
  > 
  > # - "State Show" ---------------------------------------------------------------
  > 
  > show(unitizer:::unitizerStatePristine())
             Settings Values
  1           par.env <auto>
  2       search.path      2
  3           options      2
  4 working.directory      2
  5       random.seed      2
  6        namespaces      2
  -----
  0: off
  1: track starting with initial state
  2: track starting with clean state
  <auto>: use special unitizer environment as 'par.env'
  See `?unitizerState` for more details.
  > 
  > # - "all.equal.unitizerDummy" --------------------------------------------------
  > 
  > dummy <- new("unitizerDummy")
  > blah <- "hello"
  > ref.txt <- "`.REF` value was not recorded, but `.NEW` value was; they are likely different"
  > identical(all.equal(dummy, blah), ref.txt)
  [1] TRUE
  > all.equal(dummy, dummy)
  [1] TRUE
  > identical(
  +   all.equal(blah, dummy),
  +   "`.NEW` value was not recorded, but `.REF` value was; they are likely different"
  + )
  [1] TRUE
  > # testing S4 / S3 methods, first works, second doesn't since we can't
  > # have an S3 generic with dispatch on 2nd arg
  > 
  > identical(
  +   evalq(all.equal(new("unitizerDummy"), "hello"), getNamespace("stats")),
  +   ref.txt
  + )
  [1] TRUE
  > evalq(all.equal("hello", new("unitizerDummy")), getNamespace("stats"))
  [1] "Modes: character, S4"                           
  [2] "Attributes: < target is NULL, current is list >"
  [3] "target is character, current is unitizerDummy"  
  > 
  > # - "All Equal States" ---------------------------------------------------------
  > 
  > # Doesn't seem like we're comparing these to anything?  Maybe should look into
  > # doing so?
  > 
  > state.A <- new("unitizerGlobalState", search.path = letters[1:3],
  +     options = list(a = 5:7, b = new("unitizerDummy"), c = "hello"),
  +     working.directory = "a/b/c")
  > state.B <- new("unitizerGlobalState", search.path = letters[1:3],
  +     options = list(a = 5:7, b = new("unitizerDummy"), d = "goodbye",
  +         c = new("unitizerDummy")), working.directory = new("unitizerDummy"),
  +     random.seed = 1:3)
  > state.C <- new("unitizerGlobalState", search.path = letters,
  +     options = list(a = list(5, 6, 7), c = LETTERS), working.directory = new("unitizerDummy"),
  +     random.seed = 1:3)
  > # just compare to A
  > state.D <- new("unitizerGlobalState", search.path = letters[1:3],
  +     options = list(a = list(1, 2, 3), b = new("unitizerDummy"),
  +         c = "hello"), working.directory = "a/b/c")
  > state.E <- new("unitizerGlobalState", options = setNames(as.list(1:20),
  +     head(letters, 20)))
  > state.F <- new("unitizerGlobalState", options = setNames(as.list(1:20),
  +     tail(letters, 20)))
  > # This one is supposed to return something non-character or TRUE when used
  > # with the provided all.equal
  > state.G <- new("unitizerGlobalState", options = list(a = structure(TRUE,
  +     class = "unitizer_glob_state_test"), b = 0))
  > state.H <- new("unitizerGlobalState", options = list(a = structure(FALSE,
  +     class = "unitizer_glob_state_test"), b = 2))
  > 
  > # - "as.state" -----------------------------------------------------------------
  > 
  > identical(
  +   unitizer:::as.state("recommended"),
  +   unitizer:::as.state(unitizer:::unitizerStateSuggested())
  + )
  [1] TRUE
  > identical(
  +   unitizer:::as.state("suggested"),
  +   unitizer:::as.state(unitizer:::unitizerStateSuggested())
  + )
  [1] TRUE
  > identical(
  +   unitizer:::as.state("pristine"),
  +   unitizer:::as.state(unitizer:::unitizerStatePristine())
  + )
  [1] TRUE
  > 
  > # unitizerStateProcessed should produce the default object (which currently
  > # is "off")
  > 
  > all.equal(
  +   unitizer:::as.state(.GlobalEnv),
  +   unitizer:::as.state(unitizer:::unitizerStateSuggested(par.env = .GlobalEnv))
  + )
  [1] TRUE
  > all.equal(
  +   unitizer:::as.state(in_pkg("stats")),
  +   unitizer:::as.state(
  +     unitizer:::unitizerStateSuggested(par.env = getNamespace("stats"))
  + ) )
  [1] TRUE
  > 
  > stats.lib <- file.path(system.file(package = "stats"), "R")
  > all.equal(
  +   unitizer:::as.state(in_pkg(), test.files = stats.lib),
  +   unitizer:::as.state(
  +     unitizer:::unitizerStateSuggested(par.env = getNamespace("stats"))
  + ) )
  [1] TRUE
  > try(unitizer:::as.state(200))
  Error in as.state_raw(x) : 
    Argument `x` must be character(1L) %in% c("pristine", "recommended", "suggested"
  , "basic", "off", "safe"), NULL, an environment, or must inherit from S4 classes
  `unitizerStateRaw`, `unitizerStateProcessed` or `unitizerInPkg` in order to be 
  interpreted as a unitizer state object.
  > state <- unitizer:::unitizerStateOff()
  > # bypass validity method
  > state@options <- 2L
  > try(validObject(state))
  Error in validObject(state) : 
    invalid class "unitizerStateOff" object: Argument `state` is an invalid state: 'options' is set to 2, but 'search.path' and 'namespaces' are not
  > # state raw conversions
  > identical(
  +   unitizer:::as.state(unitizer:::unitizerStateRaw()),
  +   unitizer:::unitizerStateProcessed()
  + )
  [1] TRUE
  > identical(
  +   unitizer:::as.state(unitizer:::unitizerStateRaw(par.env = "stats")),
  +   unitizer:::unitizerStateProcessed(par.env = getNamespace("stats"))
  + )
  [1] TRUE
  > state@options <- 0L
  > state.proc <- unitizer:::as.unitizerStateProcessed(state)
  > state.raw <- unitizer:::as.unitizerStateRaw(state.proc)
  > is(state.raw, "unitizerStateRaw")
  [1] TRUE
  > all.equal(
  +   lapply(slotNames(state), slot, object = state.proc),
  +   lapply(slotNames(state.raw), slot, object = state.raw)
  + )
  [1] TRUE
  > try(unitizer:::as.state(unitizer:::unitizerStateRaw(par.env = in_pkg())))
  Error in in_pkg_to_env(x.raw@par.env, test.files) : 
    Unable to detect package to use namespace of as parent environment; see `?
  unitizerState` for how to specify a package namespace explicitly as a parent 
  environment.
  Error in unitizer:::as.state(unitizer:::unitizerStateRaw(par.env = in_pkg())) : 
    Unable to convert `par.env` value to a namespace environment
  > 
  > identical(
  +   unitizer:::as.state(unitizer:::unitizerStateRaw(par.env = in_pkg("stats"))),
  +   unitizer:::unitizerStateProcessed(par.env = getNamespace("stats"))
  + )
  [1] TRUE
  > try(
  +   unitizer:::as.state(
  +     unitizer:::unitizerStateRaw(par.env = in_pkg("asdfalkdfasd"))
  + ) )
  Error in loadNamespace(name) : there is no package called 'asdfalkdfasd'
  Error in in_pkg_to_env(x.raw@par.env, test.files) : 
    Unable to load "asdfalkdfasd" namespace to use as parent environment; see 
  `?unitizerState` for instructions on how to specify a package namespace as a 
  parent environment for tests.
  Error in unitizer:::as.state(unitizer:::unitizerStateRaw(par.env = in_pkg("asdfalkdfasd"))) : 
    Unable to convert `par.env` value to a namespace environment
  > try(
  +   unitizer:::as.state(
  +     unitizer:::unitizerStateRaw(par.env = in_pkg("")), test.files = getwd()
  + ) )
  Error in in_pkg("") : Argument `package` may not be an empty string
  > # impossible states
  > state.obj <- unitizer:::unitizerStateRaw()
  > state.obj@options <- 2L
  > try(unitizer:::as.state(state.obj))
  Error in unitizer:::as.state(state.obj) : 
    Options state tracking (2) must be less than namespace state tracking (0).
  > state.obj@namespaces <- 2L
  > state.obj@search.path <- 1L
  > try(unitizer:::as.state(state.obj))
  Error in unitizer:::as.state(state.obj) : 
    Namespace state tracking (2) must be less than or equal to search path state 
  tracking (1).
  > 
  > # - "as.state_raw" -------------------------------------------------------------
  > 
  > old.opt.loc <- options(unitizer.state = .GlobalEnv)
  > try(unitizer:::as.state_raw(.GlobalEnv))
  Error in unitizer:::as.state_raw(.GlobalEnv) : 
    Value for `getOption('unitizer.state')` is incompatible with using an environment or an 'unitizerInPkg' object as the value for the `state` argument because it also is an environment or a 'unitizerInPkg' object; you must change the option or the `state` argument to be compatible.
  > options(unitizer.state = 42L)
  > try(unitizer:::as.state_raw(.GlobalEnv))
  Error in unitizer:::as.state_raw(.GlobalEnv) : 
    `getOption('unitizer.state')` must be character(1L) %in% c("pristine", "recom-
  mended", "suggested", "basic", "off", "safe"), NULL, an environment, or must 
  inherit from S4 classes `unitizerStateRaw`, `unitizerStateProcessed` or `
  unitizerInPkg` in order to be interpreted as a unitizer state object.
  > state.raw <- unitizer:::as.unitizerStateRaw(unitizer:::unitizerStateOff())
  > state.proc <- unitizer:::as.unitizerStateProcessed(state.raw)
  > my.env <- new.env()
  > options(unitizer.state = state.raw)
  > state.raw@par.env <- my.env
  > all.equal(unitizer:::as.state_raw(my.env), state.raw)
  [1] TRUE
  > options(unitizer.state = state.proc)
  > my.env <- new.env()
  > state.proc@par.env <- my.env
  > all.equal(
  +   unitizer:::as.state_raw(my.env),
  +   unitizer:::as.unitizerStateRaw(state.proc)
  + )
  [1] TRUE
  > options(old.opt.loc)
  > 
  > # - "state" --------------------------------------------------------------------
  > 
  > # all these assume we set the options to be in recommended mode
  > 
  > all.equal(state("stats"), unitizer:::unitizerStateSuggested(par.env = "stats"))
  [1] TRUE
  > 
  > all.equal(
  +   state(in_pkg("stats")),
  +   unitizer:::unitizerStateSuggested(par.env = in_pkg("stats"))
  + )
  [1] TRUE
  > all.equal(
  +   state(in_pkg()), unitizer:::unitizerStateSuggested(par.env = in_pkg())
  + )
  [1] TRUE
  > all.equal(
  +   state(search.path = 1), unitizer:::unitizerStateSuggested(search.path = 1L)
  + )
  [1] TRUE
  > s1 <- unitizer:::unitizerStateSuggested(par.env = .GlobalEnv)
  > for (i in setdiff(slotNames(s1), "par.env")) slot(s1, i) <- 0L
  > s2 <- unitizer:::unitizerStateOff()
  > all.equal(s1, s2)
  [1] TRUE
  > # invalid state
  > try(state(search.path = 3))
  Error in state(search.path = 3) : 
    Argument `search.path` must be integer(1L)  in 0:2
  > try(state(options = 2, namespaces = 1))
  Error in state(options = 2, namespaces = 1) : 
    Unable to create valid `unitizerStateRaw` object: Argument `state` is an invalid state: 'options' is set to 2, but 'search.path' and 'namespaces' are not
  > try(state(namespaces = 2, search.path = 1))
  Error in state(namespaces = 2, search.path = 1) : 
    Unable to create valid `unitizerStateRaw` object: Argument `state` is an invalid state: 'namespaces' is set to 2, but 'search.path' is not
  > state.inv <- unitizer:::unitizerStateProcessed()
  > state.inv@options <- 2L
  > try(unitizer:::as.state(state.inv))
  Error in unitizer:::as.state(state.inv) : 
    Options state tracking (2) must be less than namespace state tracking (0).
  > state.inv@namespaces <- 2L
  > try(unitizer:::as.state(state.inv))
  Error in unitizer:::as.state(state.inv) : 
    Namespace state tracking (2) must be less than or equal to search path state 
  tracking (0).
  > # captured <in: >
  > any(grepl("<in: .*>", capture.output(show(state(in_pkg())))))
  [1] TRUE
  > any(grepl("<in: package:stats>", capture.output(show(state(in_pkg("stats"))))))
  [1] TRUE
  > any(grepl("namespace:stats", capture.output(show(state(asNamespace("stats"))))))
  [1] TRUE
  > 
  > # - "in_pkg" -------------------------------------------------------------------
  > 
  > try(in_pkg(""))
  Error in in_pkg("") : Argument `package` may not be an empty string
  > identical(as.character(in_pkg()), "<in: auto-detect-pkg>")
  [1] TRUE
  > identical(as.character(in_pkg("stats")), "<in: package:stats>")
  [1] TRUE
  > identical(capture.output(show(in_pkg())), "<in: auto-detect-pkg>")
  [1] TRUE
  > try(unitizer:::in_pkg_to_env(in_pkg(), "/"))
  Error in unitizer:::in_pkg_to_env(in_pkg(), "/") : 
    Unable to detect package to use namespace of as parent environment; see `?
  unitizerState` for how to specify a package namespace explicitly as a parent 
  environment.
  > 
  > # - "merge states" -------------------------------------------------------------
  > 
  > trk.new <- new("unitizerGlobalTrackingStore", search.path = list(1,
  +     2, 3), options = list("a", "b"))
  > trk.ref <- new("unitizerGlobalTrackingStore", search.path = list(4,
  +     5, 6), options = list("c", "d"))
  > items <- new("unitizerItems")
  > items <- items + new("unitizerItem", call = quote(1 + 1), glob.indices = new("unitizerGlobalIndices",
  +     search.path = 1L, options = 2L))
  > items <- items + new("unitizerItem", call = quote(2 + 1), glob.indices = new("unitizerGlobalIndices",
  +     search.path = 2L, options = 1L))
  > items <- items + new("unitizerItem", call = quote(1 * 1), reference = TRUE,
  +     glob.indices = new("unitizerGlobalIndices", search.path = 1L,
  +         options = 1L))
  > items <- items + new("unitizerItem", call = quote(2 * 1), reference = TRUE,
  +     glob.indices = new("unitizerGlobalIndices", search.path = 3L,
  +         options = 2L))
  > res <- unitizer:::mergeStates(items, trk.new, trk.ref)
  > 
  > sapply(res$items, function(x) as.integer(slot(x, "glob.indices")))
                    [,1] [,2] [,3] [,4]
  search.path          1    2    4    5
  options              2    1    3    4
  working.directory    0    0    0    0
  random.seed          0    0    0    0
  namespaces           0    0    0    0
  > s.n.to.check <- c("search.path", "options", "working.directory",
  +     "random.seed", "namespaces")
  > sapply(s.n.to.check, slot, object = res$states)
  $search.path
  $search.path[[1]]
  [1] 1
  
  $search.path[[2]]
  [1] 2
  
  $search.path[[3]]
  [1] 3
  
  $search.path[[4]]
  [1] 4
  
  $search.path[[5]]
  [1] 6
  
  
  $options
  $options[[1]]
  [1] "a"
  
  $options[[2]]
  [1] "b"
  
  $options[[3]]
  [1] "c"
  
  $options[[4]]
  [1] "d"
  
  
  $working.directory
  list()
  
  $random.seed
  list()
  
  $namespaces
  list()
  
  > # No reference items
  > items.no.ref <- items[1:2]
  > identical(
  +   unitizer:::mergeStates(items.no.ref, trk.new, trk.ref), 
  +   list(items = items.no.ref, states = trk.new)
  + )
  [1] TRUE
  > # No new items; note that we only remap the used states to the new state
  > # which is why we need all the .mod objects
  > 
  > items.no.new <- items[3:4]
  > items.no.new.mod <- items.no.new
  > items.no.new.mod[[2L]]@glob.indices@search.path <- 2L
  > trk.ref.mod <- trk.ref
  > trk.ref.mod@search.path[[2L]] <- NULL
  > 
  > identical(
  +   unitizer:::mergeStates(
  +     items.no.new, new("unitizerGlobalTrackingStore"),trk.ref
  +   ),
  +   list(items = items.no.new.mod, states = trk.ref.mod)
  + )
  [1] TRUE
  > 
  > 
  > proc.time()
     user  system elapsed 
     0.75    0.10    0.84 
Running the tests in 'tests/t-upgrade.R' failed.
Complete output:
  > source(file.path("_helper", "init.R"))
  > blat_vers <- function(x) sub("'\\d+(?:\\.\\d+)*'", "'<version>'", x)
  > 
  > # - "Upgrade works" ------------------------------------------------------------
  > 
  > # this is also now tested as part of load
  > unitizer <-
  +   get_unitizer(file.path("_helper", "unitizers", "trivial.unitizer.0.4.2"))
  > try(validObject(unitizer, complete = TRUE))
  Error in validObject(object[[x]], complete = TRUE) : 
    invalid class "unitizerItem" object: 1: slots in class definition but not in object: "call.dep", "section.id", "section.name", "glob.indices", "state"
  invalid class "unitizerItem" object: 2: In slot "data" of class "unitizerItemData": invalid object for slot "value" in class "unitizerItemData": got class "logical", should be or extend class "list"
  > as.character(unitizer@version)
  [1] "0.4.2"
  > unitizer.up <- unitizer:::upgrade_internal(unitizer) # warning
  Warning in addSlot(object, "cons", NULL) :
    Slot `cons` does not exist in current version of `unitizer` so not added to object.
  Warning in addSlot(object, "jump.to.test", 0L) :
    Slot `jump.to.test` does not exist in current version of `unitizer` so not added to object.
  > validObject(unitizer.up)
  [1] TRUE
  > identical(unitizer.up@version, as.character(packageVersion("unitizer")))
  [1] TRUE
  > 
  > # - Upgrade Warnings in Unitize ------------------------------------------------
  > 
  > tdir <- tempfile()
  > dir.create(tdir)
  > dir.create(file.path(tdir, "trivial.unitizer"))
  > file.copy(file.path("_helper", "unitizers", "trivial.R"), tdir)
  [1] TRUE
  > file.copy(
  +   file.path("_helper", "unitizers", "trivial.unitizer.0.4.2", "data.rds"),
  +   file.path(tdir, "trivial.unitizer")
  + )
  [1] TRUE
  > odir <- setwd(tdir)
  > unitizer:::read_line_set_vals('N')
  > out <- unitizer:::capture_output(
  +   try(unitize(file.path(tdir, "trivial.R"), interactive.mode=TRUE))
  + )
  > out[] <- lapply(out, blat_vers)
  > out
  - Output -----------------------------------------------------------------------
  
  
  | 
  | The following unitizer will be upgraded to version '<version>':
  | 
  | - trivial.unitizer (at '<version>')
  
  unitizer> N
  
  - Message ----------------------------------------------------------------------
  
  Warning in check_call_stack() :
    It appears you are running unitizer inside an error handling function such as 
  `withCallingHanlders`, `tryCatch`, or `withRestarts`.  This is strongly dis-
  couraged as it may cause unpredictable behavior from unitizer in the event tests
  produce conditions / errors.  We strongly recommend you re-run your tests 
  outside of such handling functions.
  Warning in addSlot(object, "cons", NULL) :
    Slot `cons` does not exist in current version of `unitizer` so not added to object.
  Warning in addSlot(object, "jump.to.test", 0L) :
    Slot `jump.to.test` does not exist in current version of `unitizer` so not added to object.
  Warning in load_unitizers(store.ids[active], test.files[active], par.frame = util.frame,  :
    Upgraded test file does not match original test file ('NA' vs 'trivial.R').
  | unitizer upgrades are IRREVERSIBLE and not backwards compatible. 
  | Proceed?
  
  Error in unitize_core(test.file.inf, list(store.id.inf), state = state,  : 
    Cannot proceed without upgrading unitizers.
  > 
  > unitizer:::read_line_set_vals(c('Y','Q'))
  > out <- unitizer:::capture_output(
  +   unitize(file.path(tdir, "trivial.R"), interactive.mode=TRUE)
  + )
  > out[] <- lapply(out, blat_vers)
  > out
  - Output -----------------------------------------------------------------------
  
  
  | 
  | The following unitizer will be upgraded to version '<version>':
  | 
  | - trivial.unitizer (at '<version>')
  
  unitizer> Y
  
  +------------------------------------------------------------------------------+
  | unitizer for: trivial.R                                                      |
  +------------------------------------------------------------------------------+
  
               Pass Fail  New
   <untitled>     1    -    3
  ...........................
                  1    -    3
  
  - New --------------------------------------------------------------------------
  
  | The 3 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, 
  | [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  > x <- 1 + 1
  > x + 2
  [1] 4
  
  unitizer> Q
  
  | unitizer unchanged.
  
  - Message ----------------------------------------------------------------------
  
  Warning in addSlot(object, "cons", NULL) :
    Slot `cons` does not exist in current version of `unitizer` so not added to object.
  Warning in addSlot(object, "jump.to.test", 0L) :
    Slot `jump.to.test` does not exist in current version of `unitizer` so not added to object.
  Warning in load_unitizers(store.ids[active], test.files[active], par.frame = util.frame,  :
    Upgraded test file does not match original test file ('NA' vs 'trivial.R').
  | unitizer upgrades are IRREVERSIBLE and not backwards compatible. 
  | Proceed?
  
  | No changes recorded.
  > unitizer:::read_line_set_vals(NULL)
  > setwd(odir)
  > unlink(tdir, recursive=TRUE)
  > 
  > # - Upgrade Multiple Unitizers Unitize -----------------------------------------
  > 
  > tdir <- tempfile()
  > dir.create(tdir)
  > dir.create(file.path(tdir, "trivial1.unitizer"))
  > dir.create(file.path(tdir, "trivial2.unitizer"))
  > file.copy(
  +   file.path("_helper", "unitizers", "trivial.R"),
  +   file.path(tdir, c("trivial1.R", "trivial2.R"))
  + )
  [1] TRUE TRUE
  > file.copy(
  +   file.path("_helper", "unitizers", "trivial.unitizer.0.4.2", "data.rds"),
  +   file.path(tdir, "trivial1.unitizer")
  + )
  [1] TRUE
  > file.copy(
  +   file.path("_helper", "unitizers", "trivial.unitizer.0.4.2", "data.rds"),
  +   file.path(tdir, "trivial2.unitizer")
  + )
  [1] TRUE
  > odir <- setwd(tdir)
  > unitizer:::read_line_set_vals(c('Y','Q'))
  > out <- unitizer:::capture_output(
  +   unitize_dir(tdir, interactive.mode=TRUE)
  + )
  > out[] <- lapply(out, blat_vers)
  > out
  - Output -----------------------------------------------------------------------
  
  
  | 
  | The following unitizers will be upgraded to version '<version>':
  | 
  | - trivial1.unitizer (at '<version>')
  | - trivial2.unitizer (at '<version>')
  
  unitizer> Y
  
  | Summary of files in common directory '.':
  | 
  |                 Pass Fail  New
  | *1. trivial1.R     1    -    3
  | *2. trivial2.R     1    -    3
  | ..............................
  |                    2    -    6
  | Legend:
  | * `unitizer` requires review
  
  | Type number of unitizer to review, 'A' to review all that require review
  
  unitizer> Q
  
  - Message ----------------------------------------------------------------------
  
  Warning in addSlot(object, "cons", NULL) :
    Slot `cons` does not exist in current version of `unitizer` so not added to object.
  Warning in addSlot(object, "jump.to.test", 0L) :
    Slot `jump.to.test` does not exist in current version of `unitizer` so not added to object.
  Warning in addSlot(object, "cons", NULL) :
    Slot `cons` does not exist in current version of `unitizer` so not added to object.
  Warning in addSlot(object, "jump.to.test", 0L) :
    Slot `jump.to.test` does not exist in current version of `unitizer` so not added to object.
  Warning in load_unitizers(store.ids[active], test.files[active], par.frame = util.frame,  :
    Upgraded test file does not match original test file ('NA' vs 'trivial1.R').
  Warning in load_unitizers(store.ids[active], test.files[active], par.frame = util.frame,  :
    Upgraded test file does not match original test file ('NA' vs 'trivial2.R').
  | unitizer upgrades are IRREVERSIBLE and not backwards compatible. 
  | Proceed?
  
  > unitizer:::read_line_set_vals(NULL)
  > setwd(odir)
  > unlink(tdir, recursive=TRUE)
  > 
  > # - "Rename" -------------------------------------------------------------------
  > 
  > setClass("untzUpgrTest", slots = c(a = "character"))
  > x <- new("untzUpgrTest", a = letters)
  > validObject(x)
  [1] TRUE
  > setClass("untzUpgrTest", slots = c(b = "character"))
  > try(validObject(x))
  Error in validObject(x) : 
    invalid class "untzUpgrTest" object: slots in class definition but not in object: "b"
  > try(capture.output(unitizer:::renameSlot(x, "c", "b"), type = "message"))
  Error in unitizer:::renameSlot(x, "c", "b") : 
    Old slot `c` doesn't exist in object
  > x.rename <- unitizer:::renameSlot(x, "a", "b")
  > validObject(x.rename)
  [1] TRUE
  > 
  > # - "Later but valid version" --------------------------------------------------
  > 
  > test.file <- file.path(TMP.DIR, "tests.R")
  > cat("1 + 1", file = test.file)
  > unitizer:::capture_output(unitize(test.file, auto.accept = "new"))
  > version <- unlist(strsplit(as.character(packageVersion("unitizer")),
  +     ".", fixed = TRUE))
  > version[1] <- as.character(as.numeric(version[1]) + 1)
  > version.new <- paste0(version, collapse = ".")
  > unitizer.rds <- readRDS(file.path(TMP.DIR, "tests.unitizer", "data.rds"))
  > unitizer.rds@version <- version.new
  > # this should work
  > !nchar(unitizer:::unitizer_valid(unitizer.rds))
  [1] TRUE
  > # now lets cause an error
  > unitizer.rds@eval.time <- runif(5)
  > grepl("NB: ", unitizer:::unitizer_valid(unitizer.rds))
  [1] TRUE
  > 
  > # - "Failing Test w/ Upgrade" --------------------------------------------------
  > 
  > # Unitizer will fail, but also requires an upgrade.  This ensures the failure is
  > # shown despite the need for an upgrade.
  > tdir <- tempfile()
  > dir.create(tdir)
  > dir.create(file.path(tdir, "fail-and-upgrade.unitizer"))
  > file.copy(file.path("_helper", "unitizers", "fail-and-upgrade.R"), tdir)
  [1] TRUE
  > file.copy(
  +   file.path("_helper", "unitizers", "fail-and-upgrade.unitizer", "data.rds"),
  +   file.path(tdir, "fail-and-upgrade.unitizer")
  + )
  [1] TRUE
  > odir <- setwd(tdir)
  > try(unitize(file.path("fail-and-upgrade.R")))
  
  Warning in check_call_stack() :
    It appears you are running unitizer inside an error handling function such as 
  `withCallingHanlders`, `tryCatch`, or `withRestarts`.  This is strongly dis-
  couraged as it may cause unpredictable behavior from unitizer in the event tests
  produce conditions / errors.  We strongly recommend you re-run your tests 
  outside of such handling functions.
  Warning in history_capt(history, interactive.mode) :
    Unable to capture history in non-interactive mode.
  +------------------------------------------------------------------------------+
  | unitizer for: fail-and-upgrade.R                                             |
  +------------------------------------------------------------------------------+
  
               Pass Fail
   <untitled>     -    1
  ......................
                  -    1
  
  - Failed -----------------------------------------------------------------------
  
  | The following test failed because the new evaluation does not match the 
  | reference value from the store. Overwrite with new result ([Y]es, [N]o, 
  | [P]rev, [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  # fails with newer versions of unitizer so we can make sure upgrade shows error
  # and doesn't just gag at the upgrade prompt
  
  > packageVersion("unitizer") < "1.4.15"
  [1] FALSE
  
  | Value mismatch: 
  
  < .ref       > .new     
  @@ 1 @@      @@ 1 @@    
  < [1] TRUE   > [1] FALSE
  
  | State mismatch; see `.DIFF$state` for details.
  
  | User input required to proceed, but we are in non-interactive mode.
  
  | unitizer unchanged.
  
  |   * Fail: packageVersion("unitizer") < "1.4.15"
  | in 'fail-and-upgrade.R'
  
  | Newly evaluated tests do not match unitizer (Fail: 1); see above for more 
  | info, or run in interactive mode.
  
  Error in unitize_core(test.file.inf, list(store.id.inf), state = state,  : 
    Cannot proceed in non-interactive mode.
  > 
  > # Confirm upgrade needed
  > capture.output(unitizer:::read_line_set_vals(c('Y', 'Q')))
  character(0)
  > out <- unitizer:::capture_output(
  +   unitize(file.path("fail-and-upgrade.R"), interactive.mode=TRUE)
  + )
  > out[] <- lapply(out, blat_vers)
  > out
  - Output -----------------------------------------------------------------------
  
  
  | 
  | The following unitizer will be upgraded to version '<version>':
  | 
  | - fail-and-upgrade.unitizer (at '<version>')
  
  unitizer> Y
  
  +------------------------------------------------------------------------------+
  | unitizer for: fail-and-upgrade.R                                             |
  +------------------------------------------------------------------------------+
  
               Pass Fail
   <untitled>     -    1
  ......................
                  -    1
  
  - Failed -----------------------------------------------------------------------
  
  | The following test failed because the new evaluation does not match the 
  | reference value from the store. Overwrite with new result ([Y]es, [N]o, 
  | [P]rev, [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  # fails with newer versions of unitizer so we can make sure upgrade shows error
  # and doesn't just gag at the upgrade prompt
  
  > packageVersion("unitizer") < "1.4.15"
  [1] FALSE
  
  | Value mismatch: 
  
  < .ref       > .new     
  @@ 1 @@      @@ 1 @@    
  < [1] TRUE   > [1] FALSE
  
  | State mismatch; see `.DIFF$state` for details.
  
  unitizer> Q
  
  | unitizer unchanged.
  
  - Message ----------------------------------------------------------------------
  
  | unitizer upgrades are IRREVERSIBLE and not backwards compatible. 
  | Proceed?
  
  | No changes recorded.
  > 
  > unitizer:::read_line_set_vals(NULL)
  > setwd(odir)
  > unlink(tdir, recursive=TRUE)
  > 
  > 
  > proc.time()
     user  system elapsed 
     3.04    0.15    3.20 
Running the tests in 'tests/t-utz2.R' failed.
Complete output:
  > # Overflow tests from testthat.unitize.R
  > 
  > source(file.path("_helper", "init.R"))
  > source(file.path("_helper", "pkgs.R"))
  Install Packages
  Setup Demos
  > 
  > library(unitizer)
  > 
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > # - "unreviewed variations" ----------------------------------------------------
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > 
  > # Test unreviewed
  > # Accept one and go to unreviewed
  > # Accept one more and browse and go to unreviewed
  > # Accept two remaining and confirm no unreviewed
  > # No unreviewed tests
  > unitizer:::read_line_set_vals(
  +   c("Y", "Q", "U", "Y", "B", "U", "Y", "Y", "U", "B", "U", "Q")
  + )
  > out <- unitizer:::capture_output(unitize(FLM.TEST.FILE, interactive.mode = TRUE))
  > unitizer:::clean_eval_exp(out)
  - Output -----------------------------------------------------------------------
  
  
  +------------------------------------------------------------------------------+
  | unitizer for: unitizer/fastlm1.R                                             |
  +------------------------------------------------------------------------------+
  
               Pass Fail  New
   <untitled>     -    -    4
  ...........................
                  -    -    4
  
  - New --------------------------------------------------------------------------
  
  | The 4 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, 
  | [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  # Assignments and calls to `library` are not considered tests by
  # `unitizer` so you will not need to review them
  
  > library(utzflm, lib.loc = getOption("unitizer.tmp.lib.loc"))
  > dat <- data.frame(x = 1:100, y = (1:100)^2)
  > res <- fastlm(dat$x, dat$y)
  
  # The `unitizer>` prompt is like the standard R prompt. You may
  # enter expressions such as `lm(y ~ x, dat)$coefficients`, or
  # `str(res)`.
  #
  # Once you are done reviewing, you need to tell `unitizer` you
  # accept the test by typing 'Y' at the prompt.  Enter 'H' for help.
  
  > res
  intercept     slope       rsq 
  -1717.000   101.000     0.939 
  attr(,"class")
  [1] "fastlm"
  
  unitizer> Y
  
  # There are three more tests to review; accept them with 'Y'
  
  > get_slope(res)
  [1] 101
  
  unitizer> Q
  
  = Finalize Unitizer ============================================================
  
  | You have 3 unreviewed tests; press `B` to browse tests, `U` to go to first 
  | unreviewed test.
  
  | Update unitizer ([Y]es, [N]o, [P]rev, [B]rowse, [U]nreviewed, [R]erun)?
  
  unitizer> U
  
  # There are three more tests to review; accept them with 'Y'
  
  > get_slope(res)
  [1] 101
  
  unitizer> Y
  
  > get_rsq(res)
  [1] 0.939
  
  unitizer> B
  
    *1. library(utzflm, lib.loc = getOption("unitizer.tmp.lib.loc")) .     -:-
    *2. dat <- data.frame(x = 1:100, y = (1:100)^2)   .  .  .  .  .  .     -:-
    *3. res <- fastlm(dat$x, dat$y) .  .  .  .  .  .  .  .  .  .  .  .     -:-
     4. res .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .   New:Y
     5. get_slope(res)  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .   New:Y
     6. get_rsq(res) .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .   New:-
     7. fastlm(1:100, 1:10)   .  .  .  .  .  .  .  .  .  .  .  .  .  .   New:-
  
  | What test do you wish to review (input a test number, [U]nreviewed)?
  
  unitizer> U
  
  - New --------------------------------------------------------------------------
  
  | The 4 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, 
  | [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  > get_rsq(res)
  [1] 0.939
  
  unitizer> Y
  
  # This last test is expected to cause an error; press 'Y' to
  # accept it so future checks can confirm the same error persists
  
  > fastlm(1:100, 1:10)
  
  unitizer> Y
  
  = Finalize Unitizer ============================================================
  
  | Update unitizer ([Y]es, [N]o, [P]rev, [B]rowse, [R]erun)?
  
  unitizer> U
  
  | Update unitizer ([Y]es, [N]o, [P]rev, [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  unitizer> B
  
    *1. library(utzflm, lib.loc = getOption("unitizer.tmp.lib.loc")) .     -:-
    *2. dat <- data.frame(x = 1:100, y = (1:100)^2)   .  .  .  .  .  .     -:-
    *3. res <- fastlm(dat$x, dat$y) .  .  .  .  .  .  .  .  .  .  .  .     -:-
     4. res .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .   New:Y
     5. get_slope(res)  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .   New:Y
     6. get_rsq(res) .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .   New:Y
     7. fastlm(1:100, 1:10)   .  .  .  .  .  .  .  .  .  .  .  .  .  .   New:Y
  
  | What test do you wish to review (input a test number, [U]nreviewed)?
  
  unitizer> U
  
  = Finalize Unitizer ============================================================
  
  | Update unitizer ([Y]es, [N]o, [P]rev, [B]rowse, [R]erun)?
  
  unitizer> Q
  
  | unitizer unchanged.
  
  - Message ----------------------------------------------------------------------
  
  | You will IRREVERSIBLY modify 'unitizer/fastlm1.unitizer' by:
  | - Adding 1 out of 4 new tests
  
  Error in fastlm(1:100, 1:10) : 
    Arguments `x` and `y` must be the same length.
  | You will IRREVERSIBLY modify 'unitizer/fastlm1.unitizer' by:
  | - Adding 4 out of 4 new tests
  
  Error in : object 'U' not found
  | No unreviewed tests.
  
  | You will IRREVERSIBLY modify 'unitizer/fastlm1.unitizer' by:
  | - Adding 4 out of 4 new tests
  
  | Changes discarded.
  > 
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > # - "Re-eval" ------------------------------------------------------------------
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > 
  > # Test re-eval
  > # Re-eval and jump back to file 1
  > # Quit from file 1 and back to main menu
  > # Accept one test in file 2 and quit
  > # Go to file 3, accept one, and Re-eval all
  > 
  > unitizer:::read_line_set_vals(
  +   c("1", "Y", "R", "Y", "Q", "2", "Y", "Y", "3", "Y", "RR", "Y", "Q", "Q")
  + )
  > untz1 <- unitize_dir(FLM.TEST.DIR, interactive.mode = TRUE)
  
  | Summary of files in common directory 'unitizer':
  | 
  |                        Pass Fail  New
  | *1.         fastlm1.R     -    -    4
  | *2.         fastlm2.R     -    -    1
  | *3. unitizer.fastlm.R     -    -    3
  | .....................................
  |                           -    -    8
  | Legend:
  | * `unitizer` requires review
  
  | Type number of unitizer to review, 'A' to review all that require review
  
  unitizer> 1
  +------------------------------------------------------------------------------+
  | unitizer for: unitizer/fastlm1.R                                             |
  +------------------------------------------------------------------------------+
  
               Pass Fail  New
   <untitled>     -    -    4
  ...........................
                  -    -    4
  
  - New --------------------------------------------------------------------------
  
  | The 4 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, 
  | [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  # Assignments and calls to `library` are not considered tests by
  # `unitizer` so you will not need to review them
  
  > library(utzflm, lib.loc = getOption("unitizer.tmp.lib.loc"))
  > dat <- data.frame(x = 1:100, y = (1:100)^2)
  > res <- fastlm(dat$x, dat$y)
  
  # The `unitizer>` prompt is like the standard R prompt. You may
  # enter expressions such as `lm(y ~ x, dat)$coefficients`, or
  # `str(res)`.
  #
  # Once you are done reviewing, you need to tell `unitizer` you
  # accept the test by typing 'Y' at the prompt.  Enter 'H' for help.
  
  > res
  intercept     slope       rsq 
  -1717.000   101.000     0.939 
  attr(,"class")
  [1] "fastlm"
  
  unitizer> Y
  
  # There are three more tests to review; accept them with 'Y'
  
  > get_slope(res)
  [1] 101
  
  unitizer> R
  
  | Toggling re-run mode ON for this unitizer
  
  = Finalize Unitizer ============================================================
  
  | You have 3 unreviewed tests; press `B` to browse tests, `U` to go to first 
  | unreviewed test.
  
  | You will IRREVERSIBLY modify 'unitizer/fastlm1.unitizer' by:
  | - Adding 1 out of 4 new tests
  
  | Update unitizer and re-run unitizer ([Y]es, [N]o, [P]rev, [B]rowse, [U]
  | nreviewed, [R]erun)?
  
  unitizer> Y
  
  | unitizer updated.
  
  +------------------------------------------------------------------------------+
  | unitizer for: unitizer/fastlm1.R                                             |
  +------------------------------------------------------------------------------+
  
               Pass Fail  New
   <untitled>     1    -    3
  ...........................
                  1    -    3
  
  - New --------------------------------------------------------------------------
  
  | The 3 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, 
  | [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  | Jumping to test #5 because that was the test under review when test re-run was
  | requested.
  
  # There are three more tests to review; accept them with 'Y'
  
  > get_slope(res)
  [1] 101
  
  unitizer> Q
  
  | No changes recorded.
  | unitizer unchanged.
  
  | Summary of files in common directory 'unitizer':
  | 
  |                        Pass Fail  New
  | *1.         fastlm1.R     1    -    3
  | *2.         fastlm2.R     -    -    1
  | *3. unitizer.fastlm.R     -    -    3
  | .....................................
  |                           1    -    7
  | Legend:
  | * `unitizer` requires review
  
  | Type number of unitizer to review, 'A' to review all that require review
  
  unitizer> 2
  +------------------------------------------------------------------------------+
  | unitizer for: unitizer/fastlm2.R                                             |
  +------------------------------------------------------------------------------+
  
               Pass Fail  New
   <untitled>     -    -    1
  ...........................
                  -    -    1
  
  - New --------------------------------------------------------------------------
  
  | The following test is new. Add test to store ([Y]es, [N]o, [P]rev, [B]rowse, 
  | [R]erun, [Q]uit, [H]elp)?
  
  # For internal tests only; not for demo
  
  > x <- 1:10
  > y <- 1:10^3
  > res <- summary(lm(y ~ x, data.frame(x = x, y = y)))
  > intercept <- res$coefficients[1, 1]
  > slope <- res$coefficients[2, 1]
  > rsq <- res$r.squared
  > structure(c(intercept = intercept, slope = slope, rsq = rsq), 
  +     class = "fastlm")
  intercept     slope       rsq 
   4.95e+02  1.00e+00  9.90e-05 
  attr(,"class")
  [1] "fastlm"
  
  unitizer> Y
  
  = Finalize Unitizer ============================================================
  
  | You will IRREVERSIBLY modify 'unitizer/fastlm2.unitizer' by:
  | - Adding 1 out of 1 new tests
  
  | Update unitizer ([Y]es, [N]o, [P]rev, [B]rowse, [R]erun)?
  
  unitizer> Y
  
  | unitizer updated.
  
  | Summary of files in common directory 'unitizer':
  | 
  |                        Pass Fail  New
  | *1.         fastlm1.R     1    -    3
  | $2.         fastlm2.R     ?    ?    ?
  | *3. unitizer.fastlm.R     -    -    3
  | .....................................
  |                           ?    ?    ?
  | Legend:
  | * `unitizer` requires review
  | $ `unitizer` has been modified and needs to be re-run to recompute summary
  
  | Type number of unitizer to review, 'A' to review all that require review, 'R' 
  | to re-run all updated
  
  unitizer> 3
  +------------------------------------------------------------------------------+
  | unitizer for: unitizer/unitizer.fastlm.R                                     |
  +------------------------------------------------------------------------------+
  
               Pass Fail  New
   <untitled>     -    -    3
  ...........................
                  -    -    3
  
  - New --------------------------------------------------------------------------
  
  | The 3 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, 
  | [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  # Extra test file for internal tests; not for DEMO
  
  > library(utzflm, lib.loc = getOption("unitizer.tmp.lib.loc"))
  > x <- 1:10
  > y <- x^3
  > res <- fastlm(x, y)
  > get_slope(res)
  [1] 105
  
  unitizer> Y
  
  > get_rsq(res)
  [1] 0.862
  
  unitizer> RR
  
  | Toggling re-run mode ON for all loaded unitizers
  
  = Finalize Unitizer ============================================================
  
  | You have 2 unreviewed tests; press `B` to browse tests, `U` to go to first 
  | unreviewed test.
  
  | You will IRREVERSIBLY modify 'unitizer/unitizer.fastlm.unitizer' by:
  | - Adding 1 out of 3 new tests
  
  | Update unitizer and re-run all loaded unitizers ([Y]es, [N]o, [P]rev, [B]
  | rowse, [U]nreviewed, [R]erun)?
  
  unitizer> Y
  
  | unitizer updated.
  
  | Summary of files in common directory 'unitizer':
  | 
  |                        Pass Fail  New
  | *1.         fastlm1.R     1    -    3
  |  2.         fastlm2.R     1    -    -
  | *3. unitizer.fastlm.R     1    -    2
  | .....................................
  |                           3    -    5
  | Legend:
  | * `unitizer` requires review
  
  | Type number of unitizer to review, 'A' to review all that require review
  
  unitizer> Q
  
  > print(untz1)
  Summary of tests (accept/total):
  
   id         test.file       New    Passed    Totals
    1         fastlm1.R       0/3       1/1       1/4 $
    2         fastlm2.R       0/0       1/1       1/1 $
    3 unitizer.fastlm.R       0/2       1/1       1/3 $
  -----------------------------------------------------
    0            Totals       0/5       3/3       3/8
  
  $ unitizer was saved in prior evaluation
  
  Test files in common directory 'tests/unitizer'
  > # remove temp file names and display
  > invisible(lapply(untz1, function(x) {print(x); cat('\n')}))
  Test File: tests/unitizer/fastlm1.R
  Store ID: tests/unitizer/fastlm1.unitizer
  
    id                           call ignored status user reviewed
  1  4 library(utzflm, lib.loc = g...       * Passed    Y    FALSE
  2  5 dat <- data.frame(x = 1:100...       * Passed    Y    FALSE
  3  6    res <- fastlm(dat$x, dat$y)       * Passed    Y    FALSE
  4  7                            res         Passed    Y    FALSE
  5  1                 get_slope(res)            New    N    FALSE
  6  2                   get_rsq(res)            New    N    FALSE
  7  3            fastlm(1:100, 1:10)            New    N    FALSE
  
  You chose NOT to save these changes to the unitizer store
  
  Test File: tests/unitizer/fastlm2.R
  Store ID: tests/unitizer/fastlm2.unitizer
  
    id                           call ignored status user reviewed
  1  1                      x <- 1:10       * Passed    Y    FALSE
  2  2                    y <- 1:10^3       * Passed    Y    FALSE
  3  3 res <- summary(lm(y ~ x, da...       * Passed    Y    FALSE
  4  4 intercept <- res$coefficien...       * Passed    Y    FALSE
  5  5 slope <- res$coefficients[2...       * Passed    Y    FALSE
  6  6           rsq <- res$r.squared       * Passed    Y    FALSE
  7  7 structure(c(intercept = int...         Passed    Y    FALSE
  
  You chose NOT to save these changes to the unitizer store
  
  Test File: tests/unitizer/unitizer.fastlm.R
  Store ID: tests/unitizer/unitizer.fastlm.unitizer
  
    id                           call ignored status user reviewed
  1  3 library(utzflm, lib.loc = g...       * Passed    Y    FALSE
  2  4                      x <- 1:10       * Passed    Y    FALSE
  3  5                       y <- x^3       * Passed    Y    FALSE
  4  6            res <- fastlm(x, y)       * Passed    Y    FALSE
  5  7                 get_slope(res)         Passed    Y    FALSE
  6  1                   get_rsq(res)            New    N    FALSE
  7  2             get_intercept(res)            New    N    FALSE
  
  You chose NOT to save these changes to the unitizer store
  
  > 
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > # - "Section Extra" ------------------------------------------------------------
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > 
  > # Make sure that deleted items from a section are still marked from that
  > # section upgrade to version two to use the files that are set up for that
  > # there; notice update_fastlm_*extra*
  > # Re-set by dropping unitizers
  > 
  > unlink(list.dirs(FLM.TEST.DIR, recursive = FALSE), recursive = TRUE)
  > unitizer:::update_fastlm_extra(FLM)
  > inst_pak(FLM)
  > test.file.1 <- file.path(FLM.TEST.DIR, "unitizer.fastlm.R")
  > test.file.2 <- file.path(FLM.TEST.DIR, "unitizer.fastlm2.R")
  > test.store <- file.path(FLM.TEST.DIR, "store2.unitizer")
  > # First auto accept all initial tests, and then re-run with second version to
  > # make sure deleted tests are where we think they should be
  > out.1 <-
  +   unitizer:::capture_output(unitize(test.file.1, test.store, auto.accept = "new"))
  > unitizer:::read_line_set_vals(c("B", "Q"))
  > out.2 <- unitizer:::capture_output(
  +   untz.2 <- unitize(test.file.2, test.store, interactive.mode = TRUE)
  + )
  > attributes(untz.2) <- NULL
  > untz.2
  [[1]]
  [1] 1 2 3 4 5 6 7
  
  [[2]]
  [1] "library(utzflm, lib.loc = getOption(\"unitizer.tmp.lib.loc\"))"
  [2] "x <- 1:10"                                                     
  [3] "y <- x^2"                                                      
  [4] "res <- fastlm(x, y)"                                           
  [5] "get_slope(res)"                                                
  [6] "get_rsq(res)"                                                  
  [7] "2 * get_slope(res) + get_intercept(res)"                       
  
  [[3]]
  [1] "Basic Tests"    "Basic Tests"    "Basic Tests"    "Basic Tests"   
  [5] "Basic Tests"    "Advanced Tests" "Advanced Tests"
  
  [[4]]
  [1]  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE
  
  [[5]]
  [1] Failed  Failed  Failed  Failed  Failed  Failed  Removed
  Levels: New Passed Failed Removed Corrupted
  
  [[6]]
  [1] N N N N N N N
  Levels: Y N
  
  [[7]]
  [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE
  
  > 
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > # - "warning when comp funs produce output" ------------------------------------
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > 
  > # Sections with comp funs that output to stdout/stderr
  > temp.loc <- tempfile()
  > dir.create(temp.loc)
  > file.copy(file.path(START.DIR, "_helper", "unitizers", "sects.R"), temp.loc)
  [1] TRUE
  > f.sec <- file.path(temp.loc, "sects.R")
  > odir <- setwd(temp.loc)
  > out <- unitizer:::capture_output(
  +   unitize(f.sec, auto.accept = "new", interactive.mode = FALSE
  + ) )
  > 
  > unitize(f.sec, interactive.mode = FALSE)
  
  Warning in close_and_clear(e1@global$cons) :
    Test comparison functions appear to have produced output, which should not happen (see `?unitizer_sect` for more details).  If you did not provide custom testing functions, contact maintainer.  First 50 lines follow:
  I'm outputting to stdout
  I'm outputting to stderr
  I'm outputting to both 1
  I'm outputting to both 2
  
  Warning in history_capt(history, interactive.mode) :
    Unable to capture history in non-interactive mode.
  | 3/3 tests passed; nothing to review.
  
  > setwd(odir)
  > unlink(temp.loc, recursive = TRUE)
  > 
  > # - "Corner Case Files" --------------------------------------------------------
  > 
  > # Corner case files
  > # empty
  > temp.empty <- paste0(tempfile(), "-empty.R")
  > cat("\n", file = temp.empty)
  > empty.capt <- unitizer:::capture_output(unitize(temp.empty, force = TRUE))
  > # File, but does not end in .R
  > temp.bad <- paste0(tempfile())
  > 
  > cat("\n", file = temp.bad)
  > badname.capt <- unitizer:::capture_output(try(unitize(temp.bad)))
  > any(grepl("`get_unitizer` error", out$message))
  [1] FALSE
  > 
  > any(grepl("Empty unitizer", empty.capt$output))
  [1] TRUE
  > any(grepl("No valid unitizers available", badname.capt$message))
  [1] FALSE
  > unlink(c(temp.empty, temp.bad))
  > 
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > # - "Re-eval change" -----------------------------------------------------------
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > 
  > # re-eval reeval with a modified file
  > temp.reeval.base <- paste0(tempfile(), "-reeval")
  > temp.reeval <- paste0(temp.reeval.base, ".R")
  > temp.reeval.utz <- paste0(temp.reeval.base, ".unitizer")
  > cat("1 + 1\n2 + 2\n", file = temp.reeval)
  > # force re-review
  > unitizer:::read_line_set_vals(c("Y", "P", "Y", "cat(\"1 + 1\n2 + 3\n\", file=temp.reeval)",
  +     "R", "Y", "Q"))
  > # state = environment() so we can access variables from this local
  > reeval.capt <- unitizer:::capture_output(unitize(temp.reeval,
  +     state = environment(), interactive.mode = TRUE))
  > unlink(c(temp.reeval, temp.reeval.utz), recursive = TRUE)
  > 
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > # - "Condition fail" -----------------------------------------------------------
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > 
  > # Fail test with conditions
  > temp.cond.base <- paste0(tempfile(), "-cond")
  > temp.cond <- paste0(tempfile(), ".R")
  > temp.cond.utz <- paste0(tempfile(), ".unitizer")
  > cond.message <- "hello world"
  > cat("warning(cond.message)", file = temp.cond)
  > unitizer:::read_line_set_vals(c("Y", "Y"))
  > # state = environment() so we can access variables from this local
  > unitizer:::capture_output(
  +   unitize(temp.cond, state = environment(), interactive.mode = TRUE)
  + )
  > cond.message <- "goodbye world"
  > unitizer:::read_line_set_vals("Q")
  > cond.capt <-
  + unitizer:::capture_output(
  +   unitize(temp.cond, state = environment(), interactive.mode = TRUE)
  + )
  > sum(grepl("Conditions mismatch", cond.capt$output)) == 1L
  [1] TRUE
  > unlink(c(temp.cond, temp.cond.utz), recursive = TRUE)
  > 
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > # - "Force" --------------------------------------------------------------------
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > #
  > # Toggle force update, in order for this to work we need to create a situation
  > # where in a `unitize_dir`, one file passes, the other doesn't, and we review
  > # the file that passes.  Otherwise the only other way to do it is to set force
  > # from the beginning, but that ruins the toggle effect.  One possible issue
  > # here is that we don't have a great way to check the file actually changed.
  > 
  > temp.forceup.base.dir <- tempfile()
  > dir.create(temp.forceup.base.dir)
  > temp.forceup.1 <- file.path(temp.forceup.base.dir, "force1.R")
  > temp.forceup.2 <- file.path(temp.forceup.base.dir, "force2.R")
  > cat("force.var\n", file = temp.forceup.1)
  > cat("4 + 1\n", file = temp.forceup.2)
  > force.var <- 1
  > unitizer:::capture_output({
  +   unitize(temp.forceup.1, auto.accept = "new", state = environment())
  +   unitize(temp.forceup.2, auto.accept = "new", state = environment())
  + })
  > force.var <- 2
  > unitizer:::read_line_set_vals(c("2", "1", "Y", "O", "Q", "Q"))
  > force.capt <- unitizer:::capture_output(unitize_dir(temp.forceup.base.dir,
  +     state = environment(), interactive.mode = TRUE))
  > unlink(temp.forceup.base.dir, recursive = TRUE)
  > sum(grepl("Toggling force update mode ON", force.capt$message)) ==
  +     1L
  [1] TRUE
  > sum(grepl("You are about to .* with re-evaluated", force.capt$message)) ==
  +     1L
  [1] TRUE
  > 
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > # - "Compare Funs" -------------------------------------------------------------
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > 
  > # Bad comparison functions
  > temp.bad.comp <- paste0(tempfile(), ".R")
  > cat("\n  unitizer_sect(\n    'bad comp', {1 + 1; 2 + 2},\n    compare=function(x, y) list('failed', 'comparison')\n  )\n",
  +     file = temp.bad.comp)
  > unitizer:::capture_output(unitize(temp.bad.comp, auto.accept = "new"))
  > unitizer:::read_line_set_vals(c("Q"))
  > bad.comp.capt <- unitizer:::capture_output(unitize(temp.bad.comp,
  +     interactive.mode = TRUE))
  > unlink(temp.bad.comp)
  > 
  > sum(grepl("Unable to compare value", bad.comp.capt$message)) == 1L
  [1] TRUE
  > sum(grepl("Corrupted", bad.comp.capt$output)) >= 1L
  [1] TRUE
  > 
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > # - "bad map" ------------------------------------------------------------------
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > 
  > # Bad store mapping functions
  > 
  > try(unitize_dir(FLM.TEST.DIR, store.ids = function(x) stop("Bad store map fun")))
  
  Error in FUN(X[[i]], ...) : Bad store map fun
  Error in unitize_dir(FLM.TEST.DIR, store.ids = function(x) stop("Bad store map fun")) : 
    Argument `store.ids` is a function, but caused an error when attempting to use it to convert test file names to `unitizer` ids.
  > 
  > unitizer:::read_line_set_vals(NULL)
  > 
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > # - "Multiple Bookmarks" -------------------------------------------------------
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > 
  > # Issue 245: In review-all mode should not move to next unitizer until the
  > # review bookmark is cleared.
  > 
  > temp.dir <- tempfile()
  > dir.create(temp.dir)
  > writeLines("'hello'\n'world'", file.path(temp.dir, "a.R"))
  > writeLines("2 + 1\n3 + 2", file.path(temp.dir, "b.R"))
  > writeLines("pi\n2 * pi\nsqrt(pi)", file.path(temp.dir, "c.R"))
  > unitizer:::read_line_set_vals(
  +   c("A","N","N","Y","Y","R","Y","Q","Y","R","Y","Y","Y","Y","Q")
  + )
  > unitize_dir(temp.dir, interactive.mode=TRUE)
  
  | Summary of files in common directory '.':
  | 
  |          Pass Fail  New
  | *1. a.R     -    -    2
  | *2. b.R     -    -    2
  | *3. c.R     -    -    3
  | .......................
  |             -    -    7
  | Legend:
  | * `unitizer` requires review
  
  | Type number of unitizer to review, 'A' to review all that require review
  
  unitizer> A
  
  +------------------------------------------------------------------------------+
  | unitizer for: a.R                                                            |
  +------------------------------------------------------------------------------+
  
               Pass Fail  New
   <untitled>     -    -    2
  ...........................
                  -    -    2
  
  - New --------------------------------------------------------------------------
  
  | The 2 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, 
  | [B]rowse, [R]erun, [QQ]uit All, [Q]uit, [H]elp)?
  
  > "hello"
  [1] "hello"
  
  unitizer> N
  
  > "world"
  [1] "world"
  
  unitizer> N
  
  = Finalize Unitizer ============================================================
  
  | You made no changes to the unitizer so there is no need to update it.  While 
  | unnecessary, you can force an update by typing O at the prompt.
  
  | Exit unitizer ([Y]es, [P]rev, [B]rowse, [R]erun, f[O]rce, [QQ]uit All)?
  
  unitizer> Y
  
  | unitizer unchanged.
  
  +------------------------------------------------------------------------------+
  | unitizer for: b.R                                                            |
  +------------------------------------------------------------------------------+
  
               Pass Fail  New
   <untitled>     -    -    2
  ...........................
                  -    -    2
  
  - New --------------------------------------------------------------------------
  
  | The 2 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, 
  | [B]rowse, [R]erun, [QQ]uit All, [Q]uit, [H]elp)?
  
  > 2 + 1
  [1] 3
  
  unitizer> Y
  
  > 3 + 2
  [1] 5
  
  unitizer> R
  
  | Toggling re-run mode ON for this unitizer
  
  = Finalize Unitizer ============================================================
  
  | You have 1 unreviewed tests; press `B` to browse tests, `U` to go to first 
  | unreviewed test.
  
  | You will IRREVERSIBLY modify 'b.unitizer' by:
  | - Adding 1 out of 2 new tests
  
  | Update unitizer and re-run unitizer ([Y]es, [N]o, [P]rev, [B]rowse, [U]
  | nreviewed, [R]erun, [QQ]uit All)?
  
  unitizer> Y
  
  | unitizer updated.
  
  +------------------------------------------------------------------------------+
  | unitizer for: b.R                                                            |
  +------------------------------------------------------------------------------+
  
               Pass Fail  New
   <untitled>     1    -    1
  ...........................
                  1    -    1
  
  - New --------------------------------------------------------------------------
  
  | The following test is new. Add test to store ([Y]es, [N]o, [P]rev, [B]rowse, 
  | [R]erun, [QQ]uit All, [Q]uit, [H]elp)?
  
  | Jumping to test #2 because that was the test under review when test re-run was
  | requested.
  
  > 3 + 2
  [1] 5
  
  unitizer> Q
  
  | No changes recorded.
  | unitizer unchanged.
  
  +------------------------------------------------------------------------------+
  | unitizer for: c.R                                                            |
  +------------------------------------------------------------------------------+
  
               Pass Fail  New
   <untitled>     -    -    3
  ...........................
                  -    -    3
  
  - New --------------------------------------------------------------------------
  
  | The 3 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, 
  | [B]rowse, [R]erun, [QQ]uit All, [Q]uit, [H]elp)?
  
  > pi
  [1] 3.14
  
  unitizer> Y
  
  > 2 * pi
  [1] 6.28
  
  unitizer> R
  
  | Toggling re-run mode ON for this unitizer
  
  = Finalize Unitizer ============================================================
  
  | You have 2 unreviewed tests; press `B` to browse tests, `U` to go to first 
  | unreviewed test.
  
  | You will IRREVERSIBLY modify 'c.unitizer' by:
  | - Adding 1 out of 3 new tests
  
  | Update unitizer and re-run unitizer ([Y]es, [N]o, [P]rev, [B]rowse, [U]
  | nreviewed, [R]erun, [QQ]uit All)?
  
  unitizer> Y
  
  | unitizer updated.
  
  +------------------------------------------------------------------------------+
  | unitizer for: c.R                                                            |
  +------------------------------------------------------------------------------+
  
               Pass Fail  New
   <untitled>     1    -    2
  ...........................
                  1    -    2
  
  - New --------------------------------------------------------------------------
  
  | The 2 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, 
  | [B]rowse, [R]erun, [Q]uit, [H]elp)?
  
  | Jumping to test #2 because that was the test under review when test re-run was
  | requested.
  
  > 2 * pi
  [1] 6.28
  
  unitizer> Y
  
  > sqrt(pi)
  [1] 1.77
  
  unitizer> Y
  
  = Finalize Unitizer ============================================================
  
  | You will IRREVERSIBLY modify 'c.unitizer' by:
  | - Adding 2 out of 2 new tests
  
  | Update unitizer ([Y]es, [N]o, [P]rev, [B]rowse, [R]erun)?
  
  unitizer> Y
  
  | unitizer updated.
  
  | Summary of files in common directory '.':
  | 
  |          Pass Fail  New
  | *1. a.R     -    -    2
  | *2. b.R     1    -    1
  | $3. c.R     ?    ?    ?
  | .......................
  |             ?    ?    ?
  | Legend:
  | * `unitizer` requires review
  | $ `unitizer` has been modified and needs to be re-run to recompute summary
  
  | Type number of unitizer to review, 'A' to review all that require review, 'R' 
  | to re-run all updated
  
  unitizer> Q
  
  > 
  > # Make sure re-eval all clears all bookmarks
  > unlink(
  +   list.files(temp.dir, full.names=TRUE, pattern="\\.unitizer$"),
  +   recursive=TRUE
  + )
  > unitizer:::read_line_set_vals(c("A","Q","Y","RR","Y","Q"))
  > unitize_dir(temp.dir, interactive.mode=TRUE)
  
  | Summary of files in common directory '.':
  | 
  |          Pass Fail  New
  | *1. a.R     -    -    2
  | *2. b.R     -    -    2
  | *3. c.R     -    -    3
  | .......................
  |             -    -    7
  | Legend:
  | * `unitizer` requires review
  
  | Type number of unitizer to review, 'A' to review all that require review
  
  unitizer> A
  
  +------------------------------------------------------------------------------+
  | unitizer for: a.R                                                            |
  +------------------------------------------------------------------------------+
  
               Pass Fail  New
   <untitled>     -    -    2
  ...........................
                  -    -    2
  
  - New --------------------------------------------------------------------------
  
  | The 2 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, 
  | [B]rowse, [R]erun, [QQ]uit All, [Q]uit, [H]elp)?
  
  > "hello"
  [1] "hello"
  
  unitizer> Q
  
  | No changes recorded.
  | unitizer unchanged.
  
  +------------------------------------------------------------------------------+
  | unitizer for: b.R                                                            |
  +------------------------------------------------------------------------------+
  
               Pass Fail  New
   <untitled>     -    -    2
  ...........................
                  -    -    2
  
  - New --------------------------------------------------------------------------
  
  | The 2 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, 
  | [B]rowse, [R]erun, [QQ]uit All, [Q]uit, [H]elp)?
  
  > 2 + 1
  [1] 3
  
  unitizer> Y
  
  > 3 + 2
  [1] 5
  
  unitizer> RR
  
  | Toggling re-run mode ON for all loaded unitizers
  
  = Finalize Unitizer ============================================================
  
  | You have 1 unreviewed tests; press `B` to browse tests, `U` to go to first 
  | unreviewed test.
  
  | You will IRREVERSIBLY modify 'b.unitizer' by:
  | - Adding 1 out of 2 new tests
  
  | Update unitizer and re-run all loaded unitizers ([Y]es, [N]o, [P]rev, [B]
  | rowse, [U]nreviewed, [R]erun, [QQ]uit All)?
  
  unitizer> Y
  
  | unitizer updated.
  
  | Summary of files in common directory '.':
  | 
  |          Pass Fail  New
  | *1. a.R     -    -    2
  | *2. b.R     1    -    1
  | *3. c.R     -    -    3
  | .......................
  |             1    -    6
  | Legend:
  | * `unitizer` requires review
  
  | Type number of unitizer to review, 'A' to review all that require review
  
  unitizer> Q
  
  > 
  > unitizer:::read_line_set_vals(NULL)
  > unlink(temp.dir, recursive=TRUE)
  > 
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > # - "Non-Standard Conditions" --------------------------------------------------
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > 
  > # Issue 272: some conditions don't produce any output, but for `unitizer` we
  > # consider normally non-test expressions that produce conditions as tests.  So
  > # we need a mechanism for clarifying what happened.
  > 
  > temp.dir <- tempfile()
  > temp.file <- file.path(temp.dir, 'a.R')
  > dir.create(temp.dir)
  > 
  > unitizer:::read_line_set_vals("Q")
  > writeLines(
  +   c(
  +     "cond <- simpleCondition('hello')",
  +     "class(cond) <- c('svgchop_unsupported', 'svgchop', class(cond))",
  +     "invisible(signalCondition(cond))"
  +   ),
  +   temp.file
  + )
  > unitize(temp.file, interactive.mode=TRUE)
  
  +------------------------------------------------------------------------------+
  | unitizer for: a.R                                                            |
  +------------------------------------------------------------------------------+
  
               Pass Fail  New
   <untitled>     -    -    1
  ...........................
                  -    -    1
  
  - New --------------------------------------------------------------------------
  
  | The following test is new. Add test to store ([Y]es, [N]o, [P]rev, [B]rowse, 
  | [R]erun, [Q]uit, [H]elp)?
  
  > cond <- simpleCondition("hello")
  > class(cond) <- c("svgchop_unsupported", "svgchop", class(cond))
  > invisible(signalCondition(cond))
  
  | Test silently signalled conditions (use e.g. .NEW$conditions[[1]] to inspect):
  
  Condition list with 1 condition:
  1. svgchop_unsupported: hello
  
  unitizer> Q
  
  | No changes recorded.
  | unitizer unchanged.
  
  > 
  > unitizer:::read_line_set_vals(NULL)
  > unlink(temp.dir, recursive=TRUE)
  > 
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > # - "Output Transcript in non-Interactive" -------------------------------------
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > 
  > # Issue 286: don't capture output in non-interactive.
  > # We need `try` because we're testing what happens when the unitizer fails.
  > 
  > temp.dir <- tempfile()
  > temp.file <- file.path(temp.dir, 'a.R')
  > dir.create(temp.dir)
  > writeLines('warning("boom")', temp.file)  # can't use error b/c try below
  > old.opt <- options(unitizer.transcript=NULL, unitizer.show.progress=TRUE)
  > try(unitize(temp.file))
  
  Warning in check_call_stack() :
    It appears you are running unitizer inside an error handling function such as 
  `withCallingHanlders`, `tryCatch`, or `withRestarts`.  This is strongly dis-
  couraged as it may cause unpredictable behavior from unitizer in the event tests
  produce conditions / errors.  We strongly recommend you re-run your tests 
  outside of such handling functions.
  Preloads...
  Loading unitizer data...
  Parsing tests...
  Parsing a.R
  Evaluating tests...
  
  warning("boom")
  Warning in withVisible(warning("boom")) : boom
  
  Prepping Unitizers...
  Warning in history_capt(history, interactive.mode) :
    Unable to capture history in non-interactive mode.
  
  +------------------------------------------------------------------------------+
  | unitizer for: a.R                                                            |
  +------------------------------------------------------------------------------+
  
               Pass Fail  New
   <untitled>     -    -    1
  ...........................
                  -    -    1
  
  - New --------------------------------------------------------------------------
  
  | The following test is new. Add test to store ([Y]es, [N]o, [P]rev, [B]rowse, 
  | [R]erun, [Q]uit, [H]elp)?
  
  > warning("boom")
  
  | Test signalled conditions (use e.g. .NEW$conditions[[1]] to inspect):
  
  Condition list with 1 condition:
  1. Warning: boom
  
  | User input required to proceed, but we are in non-interactive mode.
  
  | unitizer unchanged.
  
  |   * New: warning("boom")
  | in 'a.R'
  
  | Newly evaluated tests do not match unitizer (New: 1); see above for more info,
  | or run in interactive mode.
  
  | Running in transcript mode: only stderr text that is also part of a signalled 
  | condition is in the test review section (scroll up to the evaluation section 
  | for the rest). See `transcript` parameter in `?unitize`.
  
  Error in unitize_core(test.file.inf, list(store.id.inf), state = state,  : 
    Cannot proceed in non-interactive mode.
  > options(old.opt)
  > unlink(temp.dir, recursive=TRUE)
  > 
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > # - "Display All Tests in non-Interactive" -------------------------------------
  > # /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  > 
  > # Issue 293: don't stop after first failing test
  > # We need `try` because we're testing what happens when the unitizer fails.
  > 
  > temp.dir <- tempfile()
  > temp.file.a <- file.path(temp.dir, 'a.R')
  > temp.file.b <- file.path(temp.dir, 'b.R')
  > dir.create(temp.dir)
  > writeLines(c("1 + 1", "warning('hello')"), temp.file.a)
  > writeLines(c("2 + 1", "warning('goodbye')"), temp.file.b)
  > try(unitize_dir(temp.dir, transcript=FALSE))
  
  Warning in check_call_stack() :
    It appears you are running unitizer inside an error handling function such as 
  `withCallingHanlders`, `tryCatch`, or `withRestarts`.  This is strongly dis-
  couraged as it may cause unpredictable behavior from unitizer in the event tests
  produce conditions / errors.  We strongly recommend you re-run your tests 
  outside of such handling functions.
  Warning in history_capt(history, interactive.mode) :
    Unable to capture history in non-interactive mode.
  | Summary of files in common directory '.':
  | 
  |          Pass Fail  New
  | *1. a.R     -    -    2
  | *2. b.R     -    -    2
  | .......................
  |             -    -    4
  | Legend:
  | * `unitizer` requires review
  
  +------------------------------------------------------------------------------+
  | unitizer for: a.R                                                            |
  +------------------------------------------------------------------------------+
  
               Pass Fail  New
   <untitled>     -    -    2
  ...........................
                  -    -    2
  
  - New --------------------------------------------------------------------------
  
  | The 2 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, 
  | [B]rowse, [R]erun, [QQ]uit All, [Q]uit, [H]elp)?
  
  > 1 + 1
  [1] 2
  
  > warning("hello")
  Warning: hello
  
  | User input required to proceed, but we are in non-interactive mode.
  
  | unitizer unchanged.
  
  +------------------------------------------------------------------------------+
  | unitizer for: b.R                                                            |
  +------------------------------------------------------------------------------+
  
               Pass Fail  New
   <untitled>     -    -    2
  ...........................
                  -    -    2
  
  - New --------------------------------------------------------------------------
  
  | The 2 tests in this section are new. Add tests to store ([Y]es, [N]o, [P]rev, 
  | [B]rowse, [R]erun, [QQ]uit All, [Q]uit, [H]elp)?
  
  > 2 + 1
  [1] 3
  
  > warning("goodbye")
  Warning: goodbye
  
  | User input required to proceed, but we are in non-interactive mode.
  
  | unitizer unchanged.
  
  |   * New: 1 + 1
  |   * New: warning("hello")
  | in 'a.R'
  
  |   * New: 2 + 1
  |   * New: warning("goodbye")
  | in 'b.R'
  
  | Newly evaluated tests do not match unitizer (New: 4); see above for more info,
  | or run in interactive mode.
  
  Error in unitize_core(test.files = test.files, store.ids = store.ids,  : 
    Cannot proceed in non-interactive mode.
  > options(old.opt)
  > unlink(temp.dir, recursive=TRUE)
  > 
  > 
  > proc.time()
     user  system elapsed 
     7.12    0.57   16.12 
Running the tests in 'tests/zz-check.R' failed.
Complete output:
  > source('aammrtf/check.R')
  43: > lorem1 <- "Today, with Kiernan on the stand offering confirmation, Howard walked the jury through the enormous amount of data pulled from Ulbricht's computer. Defense lawyers haven't had a chance yet to respond to this evidence<e2><80><94>that will likely come tomorrow. The mountain they have to climb looks higher than ever, though. Last week, Ulbricht's lawyer outlined a defense in which Ulbricht walked away from the marketplace he created and was \"lured back.\" But what will explain the dozens of folders of data on this laptop, with data from the upper echelons of Silk Road management<e2><80><94>mixed with the most intimate details of Ulbricht's personal life?"
  
  
  
  
  
  
  
  
  
  
  
  
  
  Error: .Rout files missing (failed?):
  't-browser.Rout', 't-capture.Rout', 't-demo.Rout', 't-get.Rout', 't-handledruns.Rout', 't-ischecks.Rout', 't-item.Rout', 't-list.Rout', 't-nav.Rout', 't-parse.Rout', 't-prompt.Rout', 't-repairenvs.Rout', 't-section.Rout', 't-state.Rout', 't-upgrade.Rout', 't-utz2.Rout'
  In addition: Warning message:
  In eval(ei, envir) : Some outputs contain non-ASCII:
  't-text.Rout'
  Execution halted