Running 'Arguments-FILES.R' [0s]
  Running 'FileProgressBar.R' [2s]
  Running 'GString.R' [0s]
  Running 'Java.R' [0s]
  Running 'MultiVerbose.R' [0s]
  Running 'NullVerbose.R' [0s]
  Running 'Options.R' [173s]
  Running 'ProgressBar.R' [1s]
  Running 'Settings.R' [0s]
  Running 'System.R' [0s]
  Running 'TextStatusBar.R' [171s]
  Running 'VComments.R' [0s]
  Running 'Verbose.R' [0s]
  Running 'absolute-relative-paths.R' [159s]
  Running 'attachLocally.R' [0s]
  Running 'callHooks.R' [0s]
  Running 'capitalize.R' [0s]
  Running 'captureOutput.R' [161s]
  Running 'cmdArgs.R' [0s]
  Running 'colClasses.R' [0s]
  Running 'commandArgs.R' [157s]
  Running 'compressFile.R' [1s]
  Running 'compressPDF.R' [168s]
  Running 'copyRenameFile.R' [178s]
  Running 'countLines.R' [165s]
  Running 'cout.R' [173s]
  Running 'createFileAtomically.R' [166s]
  Running 'createLink.R' [170s]
  Running 'dataFrame.R' [160s]
  Running 'dimNA.R' [0s]
  Running 'displayCode.R' [1s]
  Running 'doCall.R' [0s]
  Running 'eget.R' [0s]
  Running 'egsub.R' [0s]
  Running 'env.R' [0s]
  Running 'extract.array.R' [157s]
  Running 'fileAccess.R' [11s]
  Running 'filePath.R' [0s]
  Running 'findFiles.R' [3s]
  Running 'findSourceTraceback.R' [24s]
  Running 'gcDLLs.R' [154s]
  Running 'gcat.R' [162s]
  Running 'getOption.R' [165s]
  Running 'getParent.R' [0s]
  Running 'hpaste.R' [160s]
  Running 'insert.R' [166s]
  Running 'intToHex.R' [0s]
  Running 'isPackageLoaded.R' [0s]
  Running 'isReplicated.R' [1s]
  Running 'isUrl.R' [0s]
  Running 'isZero.R' [0s]
  Running 'listDirectory.R' [164s]
  Running 'loadObject.R' [0s]
  Running 'loadToEnv.R' [171s]
  Running 'mkdirs.R' [169s]
  Running 'mout.R' [163s]
  Running 'mpager.R' [0s]
  Running 'nullfile.R' [0s]
  Running 'parseRepos.R' [165s]
  Running 'pushBackupFile.R' [0s]
  Running 'pushTemporaryFile.R' [43s]
  Running 'queryRCmdCheck.R' [173s]
  Running 'readBinFragments.R' [1s]
  Running 'readWindowsShellLink.R' [3s]
  Running 'readWindowsShortcut.R' [162s]
  Running 'resample.R' [0s]
  Running 'seqToHumanReadable.R' [160s]
  Running 'seqToIntervals.R' [0s]
  Running 'sourceDirectory.R' [171s]
  Running 'sourceTo.R' [0s]
  Running 'splitByPattern.R' [0s]
  Running 'subplots.R' [169s]
  Running 'symlinks,dirs.R' [173s]
  Running 'symlinks,files.R' [0s]
  Running 'systemR.R' [1s]
  Running 'tempvar.R' [0s]
  Running 'tmpfile.R' [153s]
  Running 'toCamelCase.R' [175s]
  Running 'touchFile.R' [2s]
  Running 'use.R' [170s]
  Running 'useRepos.R' [0s]
  Running 'whichVector.R' [1s]
  Running 'withCapture.R' [0s]
  Running 'withLocale.R' [162s]
  Running 'withOptions.R' [157s]
  Running 'withRepos.R' [171s]
  Running 'withSeed.R' [0s]
  Running 'withSink.R' [207s]
  Running 'withTimeout.R' [7s]
  Running 'wrap.array.R' [152s]
  Running 'writeDataFrame.R' [61s]
  Running 'zzz_finalizer_crash.R' [165s]
Running the tests in 'tests/Options.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > local <- Options()
  > print(local)
  [1] "Options: 0 options set."
  > str(local)
  Options:
   list()
  > print(names(local))
  NULL
  > print(nbrOfOptions(local))
  [1] 0
  > print(getLeaves(local))
  NULL
  > 
  > 
  > # Query a missing option
  > cex <- getOption(local, "graphics/cex")
  > cat("graphics/cex =", cex, "\n")  # Returns NULL
  graphics/cex = 
  > 
  > # Query a missing option with default value
  > cex <- getOption(local, "graphics/cex", defaultValue=1)
  > cat("graphics/cex =", cex, "\n")  # Returns NULL
  graphics/cex = 1 
  > 
  > # Set option and get previous value
  > oldCex <- setOption(local, "graphics/cex", 2)
  > cat("previous graphics/cex =", oldCex, "\n")  # Returns NULL
  previous graphics/cex = 
  > 
  > # Set option again and get previous value
  > oldCex <- setOption(local, "graphics/cex", 3)
  > cat("previous graphics/cex =", oldCex, "\n")  # Returns 2
  previous graphics/cex = 2 
  > 
  > # Query a missing option with default value, which is ignored
  > cex <- getOption(local, "graphics/cex", defaultValue=1)
  > cat("graphics/cex =", cex, "\n")  # Returns 3
  graphics/cex = 3 
  > 
  > # Query multiple options with multiple default values
  > multi <- getOption(local, c("graphics/cex", "graphics/pch"), c(1,2))
  > print(multi)
  $`graphics/cex`
  [1] 3
  
  $`graphics/pch`
  [1] 2
  
  > 
  > # Check existance of multiple options
  > has <- hasOption(local, c("graphics/cex", "graphics/pch"))
  > print(has)
  graphics/cex graphics/pch 
          TRUE        FALSE 
  > 
  > # Get a subtree of options
  > graphics <- getOption(local, "graphics")
  > print(graphics)
  $cex
  [1] 3
  
  > 
  > # Get the complete tree of options
  > all <- getOption(local)
  > print(all)
  $graphics
  $graphics$cex
  [1] 3
  
  
  > 
  > proc.time()
     user  system elapsed 
     0.28    0.06    0.32 
Running the tests in 'tests/TextStatusBar.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Read all HTML files in the base package
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > path <- system.file(package="base")
  > files <- list.files(path, recursive=TRUE, full.names=TRUE)
  > files <- files[sapply(files, FUN=isFile)]
  > nfiles <- length(files)
  > 
  > cat(sprintf("Reading %d files in %s:\n", nfiles, path))
  Reading 24 files in D:/RCompile/recent/R/library/base:
  > 
  > # Create a status bar with four labels
  > sb <- TextStatusBar("File: %-*s [%3.0f%% %7.0f bytes %-8s]",
  +                 hfill=1, file="", progress=0, nbytes=0L, time="")
  > 
  > nbytes <- 0L
  > for (kk in seq_len(nfiles)) {
  +   file <- files[kk]
  + 
  +   # Update the status bar
  +   if (sb) {
  +     setLabel(sb, "progress", 100*kk/nfiles)
  +     if (kk %% 10 == 1 || kk == nfiles)
  +       setLabel(sb, "file", substr(basename(file), 1, 44))
  + 
  +     size <- file.info(file)$size
  +     # popMessage() calls update() too
  +     popMessage(sb, sprintf("Processing %s (%.2fkB)",
  +                                        basename(file), size/1024))
  +     flush(sb)
  +   }
  + 
  +   # Read the file
  +   bfr <- readBin(file, what="raw", n=size)
  +   nbytes <- nbytes + size
  + 
  +   # Emulate a slow process
  +   if (interactive()) Sys.sleep(rexp(1, rate=60))
  + 
  +   # Update the status bar
  +   if (sb) {
  +     setLabel(sb, "nbytes", nbytes)
  +     setLabel(sb, "time", format(Sys.time(), "%H:%M:%S"))
  +     update(sb)
  +   }
  + }
  Processing CITATION (0.63kB)
  File: CITATION                                    [  4%       0 bytes         ]File: CITATION                                    [  4%     643 bytes 09:11:02]                                                                               Processing DESCRIPTION (0.39kB)
  File: CITATION                                    [  8%     643 bytes 09:11:02]File: CITATION                                    [  8%    1041 bytes 09:11:02]                                                                               Processing INDEX (24.71kB)
  File: CITATION                                    [ 12%    1041 bytes 09:11:02]File: CITATION                                    [ 12%   26342 bytes 09:11:02]                                                                               Processing Rd.rds (22.12kB)
  File: CITATION                                    [ 17%   26342 bytes 09:11:02]File: CITATION                                    [ 17%   48998 bytes 09:11:02]                                                                               Processing demo.rds (0.25kB)
  File: CITATION                                    [ 21%   48998 bytes 09:11:02]File: CITATION                                    [ 21%   49251 bytes 09:11:02]                                                                               Processing features.rds (0.12kB)
  File: CITATION                                    [ 25%   49251 bytes 09:11:02]File: CITATION                                    [ 25%   49373 bytes 09:11:02]                                                                               Processing hsearch.rds (22.95kB)
  File: CITATION                                    [ 29%   49373 bytes 09:11:02]File: CITATION                                    [ 29%   72875 bytes 09:11:02]                                                                               Processing links.rds (13.24kB)
  File: CITATION                                    [ 33%   72875 bytes 09:11:02]File: CITATION                                    [ 33%   86435 bytes 09:11:02]                                                                               Processing package.rds (0.56kB)
  File: CITATION                                    [ 38%   86435 bytes 09:11:02]File: CITATION                                    [ 38%   87004 bytes 09:11:02]                                                                               Processing Rprofile (7.25kB)
  File: CITATION                                    [ 42%   87004 bytes 09:11:02]File: CITATION                                    [ 42%   94430 bytes 09:11:02]                                                                               Processing base (5.32kB)
  File: base                                        [ 46%   94430 bytes 09:11:02]File: base                                        [ 46%   99879 bytes 09:11:02]                                                                               Processing base.rdb (1061.01kB)
  File: base                                        [ 50%   99879 bytes 09:11:02]File: base                                        [ 50% 1186349 bytes 09:11:02]                                                                               Processing base.rdx (13.75kB)
  File: base                                        [ 54% 1186349 bytes 09:11:02]File: base                                        [ 54% 1200427 bytes 09:11:02]                                                                               Processing error.catching.R (3.29kB)
  File: base                                        [ 58% 1200427 bytes 09:11:02]File: base                                        [ 58% 1203794 bytes 09:11:02]                                                                               Processing is.things.R (4.69kB)
  File: base                                        [ 62% 1203794 bytes 09:11:02]File: base                                        [ 62% 1208592 bytes 09:11:02]                                                                               Processing recursion.R (2.07kB)
  File: base                                        [ 67% 1208592 bytes 09:11:02]File: base                                        [ 67% 1210707 bytes 09:11:02]                                                                               Processing scoping.R (1.52kB)
  File: base                                        [ 71% 1210707 bytes 09:11:02]File: base                                        [ 71% 1212267 bytes 09:11:02]                                                                               Processing AnIndex (36.52kB)
  File: base                                        [ 75% 1212267 bytes 09:11:02]File: base                                        [ 75% 1249659 bytes 09:11:02]                                                                               Processing aliases.rds (12.37kB)
  File: base                                        [ 79% 1249659 bytes 09:11:02]File: base                                        [ 79% 1262328 bytes 09:11:02]                                                                               Processing base.rdb (2446.42kB)
  File: base                                        [ 83% 1262328 bytes 09:11:02]File: base                                        [ 83% 3767460 bytes 09:11:02]                                                                               Processing base.rdx (9.11kB)
  File: base.rdx                                    [ 88% 3767460 bytes 09:11:02]File: base.rdx                                    [ 88% 3776788 bytes 09:11:02]                                                                               Processing paths.rds (3.10kB)
  File: base.rdx                                    [ 92% 3776788 bytes 09:11:02]File: base.rdx                                    [ 92% 3779960 bytes 09:11:02]                                                                               Processing 00Index.html (150.83kB)
  File: base.rdx                                    [ 96% 3779960 bytes 09:11:02]File: base.rdx                                    [ 96% 3934409 bytes 09:11:02]                                                                               Processing R.css (1.80kB)
  File: R.css                                       [100% 3934409 bytes 09:11:02]File: R.css                                       [100% 3936253 bytes 09:11:02]> setLabel(sb, "file", "<done>")
  > update(sb)
  File: <done>                                      [100% 3936253 bytes 09:11:02]> cat("\n")
  
  > 
  > ## Odds and ends
  > print(getLabel(sb, "progress"))
  [1] 100
  > print(newline(sb))
  
  NULL
  > updateLabels(sb)
  File: <done>                                      [100% 3936253 bytes 09:11:02]> 
  > 
  > proc.time()
     user  system elapsed 
     0.31    0.10    0.40 
Running the tests in 'tests/absolute-relative-paths.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > warnifnot <- egsub("stop", "warning", stopifnot, value=FALSE)
  > 
  > message("Absolute and relative paths ...")
  Absolute and relative paths ...
  > 
  > message("- Absolute and relative path of getwd()")
  - Absolute and relative path of getwd()
  > stopifnot(identical(getAbsolutePath("."), getwd()))
  > stopifnot(identical(getRelativePath("."), "."))
  > 
  > message("- Tilde expansion")
  - Tilde expansion
  > pathH0 <- normalizePath("~")
  > print(pathH0)
  [1] "C:\\Users\\CRAN\\Documents"
  > pathH <- normalizePath("~", winslash = "/")
  > print(pathH)
  [1] "C:/Users/CRAN/Documents"
  > pathHA <- getAbsolutePath(pathH)
  > print(pathHA)
  [1] "C:/Users/CRAN/Documents"
  > 
  > pathA <- getAbsolutePath("~", expandTilde=TRUE)
  > print(pathA)
  [1] "C:/Users/CRAN/Documents"
  > warnifnot(identical(tolower(pathA), tolower(pathH)))
  > 
  > pathR <- getRelativePath("~")
  > print(pathR)
  [1] "C:/Users/CRAN/Documents"
  > warnifnot(identical(tolower(getAbsolutePath(pathR)), tolower(pathH)))
  > 
  > pathR <- getRelativePath("~", caseSensitive=TRUE)
  > print(pathR)
  [1] "C:/Users/CRAN/Documents"
  > 
  > 
  > message("- ~/../Documents")
  - ~/../Documents
  > pathA <- getAbsolutePath("~/../Documents", expandTilde=TRUE)
  > pathA0 <- file.path(getParent(pathH), "Documents")
  > ## Account for the case when getParent(pathH) = "C:/", which in case
  > ## we get C://Documents instead of C:/Documents
  > pathA0 <- normalizePath(pathA0, winslash = "/")
  > utils::str(list(pathA = pathA, pathA0 = pathA0))
  List of 2
   $ pathA : chr "C:/Users/CRAN/Documents"
   $ pathA0: chr "C:/Users/CRAN/Documents"
  > stopifnot(pathA == pathA0)
  > 
  > message("- /tmp/")
  - /tmp/
  > pathA <- getAbsolutePath("/tmp/", expandTilde=TRUE)
  > print(pathA)
  [1] "/tmp"
  > stopifnot(identical(pathA, "/tmp"))
  > 
  > 
  > message("- Microsoft Windows UNC paths")
  - Microsoft Windows UNC paths
  > stopifnot(identical(getAbsolutePath("//vinata/biomed"), "//vinata/biomed"))
  > stopifnot(identical(getAbsolutePath("//vinata///biomed"), "//vinata/biomed"))
  > 
  > message("- Vector of files")
  - Vector of files
  > paths <- c(".", "..", getwd())
  > print(paths)
  [1] "."                                                 
  [2] ".."                                                
  [3] "d:/Rcompile/CRANpkg/local/4.4/R.utils.Rcheck/tests"
  > pathsA <- getAbsolutePath(paths)
  > print(pathsA)
                                                     . 
  "d:/Rcompile/CRANpkg/local/4.4/R.utils.Rcheck/tests" 
                                                    .. 
        "d:/Rcompile/CRANpkg/local/4.4/R.utils.Rcheck" 
    d:/Rcompile/CRANpkg/local/4.4/R.utils.Rcheck/tests 
  "d:/Rcompile/CRANpkg/local/4.4/R.utils.Rcheck/tests" 
  > pathsR <- getRelativePath(paths)
  > print(pathsR)
                                                   . 
                                                 "." 
                                                  .. 
                                                ".." 
  d:/Rcompile/CRANpkg/local/4.4/R.utils.Rcheck/tests 
                                                 "." 
  > pathsAR <- getRelativePath(pathsA)
  > print(pathsAR)
  d:/Rcompile/CRANpkg/local/4.4/R.utils.Rcheck/tests 
                                                 "." 
        d:/Rcompile/CRANpkg/local/4.4/R.utils.Rcheck 
                                                ".." 
  d:/Rcompile/CRANpkg/local/4.4/R.utils.Rcheck/tests 
                                                 "." 
  > pathsRA <- getAbsolutePath(pathsR)
  > print(pathsRA)
                                                     . 
  "d:/Rcompile/CRANpkg/local/4.4/R.utils.Rcheck/tests" 
                                                    .. 
        "d:/Rcompile/CRANpkg/local/4.4/R.utils.Rcheck" 
                                                     . 
  "d:/Rcompile/CRANpkg/local/4.4/R.utils.Rcheck/tests" 
  > 
  > # Sanity checks
  > stopifnot(all(isAbsolutePath(pathsA)))
  > stopifnot(all(!isAbsolutePath(pathsR)))
  > stopifnot(all(pathsRA == pathsA))
  > stopifnot(all(pathsAR == pathsR))
  > 
  > 
  > message("- Paths relative to given directories")
  - Paths relative to given directories
  > stopifnot(getRelativePath("foo", "foo") == ".")
  > stopifnot(getRelativePath("foo/bar", "foo") == "bar")
  > stopifnot(getRelativePath("foo/bar", "foo/bar/yah") == "..")
  > stopifnot(getRelativePath("foo/bar/cool", "foo/bar/yah/sub/") == "../../cool")
  > stopifnot(getRelativePath("/tmp/foo/", "/tmp/") == "foo")
  > stopifnot(getRelativePath("/tmp/bar/", "/bar/foo/") == "../../tmp/bar")
  > stopifnot(getRelativePath("C:/foo/bar/", "C:/bar/") == "../foo/bar")
  > stopifnot(getRelativePath("C:/foo/bar/", "D:/bar/") == "C:/foo/bar")
  > 
  > message("Absolute and relative paths ... DONE")
  Absolute and relative paths ... DONE
  > 
  > proc.time()
     user  system elapsed 
     0.43    0.09    0.51 
Running the tests in 'tests/captureOutput.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > message("*** captureOutput() == capture.output()")
  *** captureOutput() == capture.output()
  > for (n in c(0, 1, 10, 100, 1000)) {
  +   printf("n=%d\n", n)
  +   x <- rnorm(n)
  +   str(x)
  + 
  +   bfr0 <- capture.output(print(x))
  +   bfr <- captureOutput(print(x))
  +   stopifnot(nchar(bfr) == nchar(bfr0))
  + 
  +   stopifnot(identical(bfr, bfr0))
  + } # for (n ...)
  n=0
   num(0) 
  n=1
   num -0.0412
  n=10
   num [1:10] -1.393 0.187 0.989 0.745 -1.46 ...
  n=100
   num [1:100] -0.303 0.638 0.105 -1.278 -0.892 ...
  n=1000
   num [1:1000] -0.0726 -1.3693 0.1068 1.7169 -0.4754 ...
  > 
  > message("*** captureOutput(..., collapse=ch)")
  *** captureOutput(..., collapse=ch)
  > x <- c("abc", "123", "def\n456")
  > for (ch in list(NULL, "\n", "\r", "\n\r", "\r\n", ";\n", "")) {
  +   bfr0 <- paste(capture.output(cat(x)), collapse=ch)
  +   bfr <- captureOutput(cat(x), collapse=ch)
  +   str(list(bfr0=bfr0, bfr=bfr))
  +   stopifnot(identical(bfr0, bfr))
  + }
  List of 2
   $ bfr0: chr [1:2] "abc 123 def" "456"
   $ bfr : chr [1:2] "abc 123 def" "456"
  List of 2
   $ bfr0: chr "abc 123 def\n456"
   $ bfr : chr "abc 123 def\n456"
  List of 2
   $ bfr0: chr "abc 123 def\r456"
   $ bfr : chr "abc 123 def\r456"
  List of 2
   $ bfr0: chr "abc 123 def\n\r456"
   $ bfr : chr "abc 123 def\n\r456"
  List of 2
   $ bfr0: chr "abc 123 def\r\n456"
   $ bfr : chr "abc 123 def\r\n456"
  List of 2
   $ bfr0: chr "abc 123 def;\n456"
   $ bfr : chr "abc 123 def;\n456"
  List of 2
   $ bfr0: chr "abc 123 def456"
   $ bfr : chr "abc 123 def456"
  > 
  > 
  > message("*** captureOutput(..., file='foo.txt')")
  *** captureOutput(..., file='foo.txt')
  > x <- c("abc", "123", "def\n456")
  > capture.output(cat(x), file="foo1.txt")
  > captureOutput(cat(x), file="foo2.txt")
  > bfr1 <- readLines("foo1.txt", warn=FALSE)
  > bfr2 <- readLines("foo2.txt", warn=FALSE)
  > stopifnot(all.equal(bfr2, bfr1))
  > file.remove("foo1.txt")
  [1] TRUE
  > file.remove("foo2.txt")
  [1] TRUE
  > 
  > 
  > 
  > proc.time()
     user  system elapsed 
     0.34    0.06    0.37 
Running the tests in 'tests/commandArgs.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > ######################################################################
  > # How R was invoked
  > ######################################################################
  > cmd <- paste(commandArgs(), collapse=" ")
  > cat("How R was invoked:\n")
  How R was invoked:
  > cat(cmd, "\n")
  D:\RCompile\recent\R/bin/x64/Rterm.exe -f commandArgs.R --restore --save --vanilla 
  > 
  > # Get all arguments
  > args <- commandArgs()
  > print(args)
  [1] "D:\\RCompile\\recent\\R/bin/x64/Rterm.exe"
  [2] "-f"                                       
  [3] "commandArgs.R"                            
  [4] "--restore"                                
  [5] "--save"                                   
  [6] "--vanilla"                                
  > 
  > # Get only "private" arguments and not the name of the R executable.
  > args <- commandArgs(excludeReserved=TRUE)[-1]
  > print(args)
  character(0)
  > 
  > # Assert backward compatibility
  > args0 <- base::commandArgs()
  > args <- commandArgs()
  > stopifnot(all.equal(args, args0))
  > 
  > 
  > 
  > ######################################################################
  > # Parsed command-line arguments
  > ######################################################################
  > # Call #1:
  > argsC <- c("R", "--encoding=ASCII", "--encoding", "ASCII", "DATAPATH=../data", "--args", "--root=do da", "--foo", "bar", "--details", "--a=2", "--src_file=foo.R")
  > print(argsC)
   [1] "R"                "--encoding=ASCII" "--encoding"       "ASCII"           
   [5] "DATAPATH=../data" "--args"           "--root=do da"     "--foo"           
   [9] "bar"              "--details"        "--a=2"            "--src_file=foo.R"
  > 
  > # Truth:
  > args0 <- list("R", encoding="ASCII", encoding="ASCII", DATAPATH="../data", args=TRUE, root="do da", foo="bar", details=TRUE, a="2", "src_file"="foo.R")
  > 
  > args <- commandArgs(asValues=TRUE, .args=argsC)
  > str(args)
  List of 10
   $         : chr "R"
   $ encoding: chr "ASCII"
   $ encoding: chr "ASCII"
   $ DATAPATH: chr "../data"
   $ args    : logi TRUE
   $ root    : chr "do da"
   $ foo     : chr "bar"
   $ details : logi TRUE
   $ a       : chr "2"
   $ src_file: chr "foo.R"
  > stopifnot(all.equal(args, args0))
  > 
  > # Exclude reserved
  > args <- commandArgs(asValues=TRUE, excludeReserved=TRUE, excludeEnvVars=TRUE, .args=argsC)[-1L]
  > stopifnot(all.equal(args, args0[-(1:5)]))
  > 
  > 
  > # Call #2:
  > argsC <- c("R", "noname1", "DATAPATH=../data", "--args", "--root=do da", "noname2", "--foo", "bar", "--details", "--a=2", "noname3", "noname4", "noname5", "--b=pi", "--c:=pi")
  > print(argsC)
   [1] "R"                "noname1"          "DATAPATH=../data" "--args"          
   [5] "--root=do da"     "noname2"          "--foo"            "bar"             
   [9] "--details"        "--a=2"            "noname3"          "noname4"         
  [13] "noname5"          "--b=pi"           "--c:=pi"         
  > 
  > # Truth:
  > args0 <- list("R", "noname1", DATAPATH="../data", args=TRUE, root="do da", "noname2", foo="bar", details=TRUE, a="2", "noname3", "noname4", "noname5", b="pi", c=structure("pi", class="CmdArgExpression"))
  > 
  > args <- commandArgs(asValues=TRUE, .args=argsC)
  > str(args)
  List of 14
   $         : chr "R"
   $         : chr "noname1"
   $ DATAPATH: chr "../data"
   $ args    : logi TRUE
   $ root    : chr "do da"
   $         : chr "noname2"
   $ foo     : chr "bar"
   $ details : logi TRUE
   $ a       : chr "2"
   $         : chr "noname3"
   $         : chr "noname4"
   $         : chr "noname5"
   $ b       : chr "pi"
   $ c       : 'CmdArgExpression' chr "pi"
  > stopifnot(all.equal(args, args0))
  > 
  > # Truth (when evaluating expression):
  > args0 <- list("R", "noname1", DATAPATH="../data", args=TRUE, root="do da", "noname2", foo="bar", details=TRUE, a=2, "noname3", "noname4", "noname5", b="pi", c=pi)
  > 
  > args <- commandArgs(asValues=TRUE, adhoc=TRUE, .args=argsC)
  > str(args)
  List of 14
   $         : chr "R"
   $         : chr "noname1"
   $ DATAPATH: chr "../data"
   $ args    : logi TRUE
   $ root    : chr "do da"
   $         : chr "noname2"
   $ foo     : chr "bar"
   $ details : logi TRUE
   $ a       : int 2
   $         : chr "noname3"
   $         : chr "noname4"
   $         : chr "noname5"
   $ b       : chr "pi"
   $ c       : num 3.14
  > stopifnot(all.equal(args, args0))
  > 
  > 
  > for (asValues in c(TRUE, FALSE)) {
  +   # Argument 'defaults'
  +   args <- commandArgs(asValues=asValues, .args=argsC, defaults=c(a=1L, d=4L))
  +   str(args)
  + 
  +   # Argument 'always'
  +   args <- commandArgs(asValues=asValues, .args=argsC, always=c(c=4L))
  +   str(args)
  + 
  +   # Argument 'unique'
  +   args <- commandArgs(asValues=asValues, .args=argsC, unique=TRUE)
  +   str(args)
  + 
  +   # Argument 'os'
  +   args <- commandArgs(asValues=asValues, os="current")
  +   str(args)
  + 
  +   # Unusual option: -name=value
  +   args <- commandArgs(asValues=asValues, .args="-foo=4")
  +   str(args)
  + 
  +   # Default
  +   args <- commandArgs(asValues=asValues)
  +   str(args)
  + } # for (asValues ...)
  List of 15
   $         : chr "R"
   $ d       : int 4
   $         : chr "noname1"
   $ DATAPATH: chr "../data"
   $ args    : logi TRUE
   $ root    : chr "do da"
   $         : chr "noname2"
   $ foo     : chr "bar"
   $ details : logi TRUE
   $ a       : int 2
   $         : chr "noname3"
   $         : chr "noname4"
   $         : chr "noname5"
   $ b       : chr "pi"
   $ c       : 'CmdArgExpression' chr "pi"
  List of 15
   $         : chr "R"
   $         : chr "noname1"
   $ DATAPATH: chr "../data"
   $ args    : logi TRUE
   $ root    : chr "do da"
   $         : chr "noname2"
   $ foo     : chr "bar"
   $ details : logi TRUE
   $ a       : chr "2"
   $         : chr "noname3"
   $         : chr "noname4"
   $         : chr "noname5"
   $ b       : chr "pi"
   $ c       : 'CmdArgExpression' chr "pi"
   $ c       : int 4
  List of 14
   $         : chr "R"
   $         : chr "noname1"
   $ DATAPATH: chr "../data"
   $ args    : logi TRUE
   $ root    : chr "do da"
   $         : chr "noname2"
   $ foo     : chr "bar"
   $ details : logi TRUE
   $ a       : chr "2"
   $         : chr "noname3"
   $         : chr "noname4"
   $         : chr "noname5"
   $ b       : chr "pi"
   $ c       : 'CmdArgExpression' chr "pi"
  List of 5
   $        : chr "D:\\RCompile\\recent\\R/bin/x64/Rterm.exe"
   $ f      : chr "commandArgs.R"
   $ restore: logi TRUE
   $ save   : logi TRUE
   $ vanilla: logi TRUE
  List of 1
   $ foo: chr "4"
  List of 5
   $        : chr "D:\\RCompile\\recent\\R/bin/x64/Rterm.exe"
   $ f      : chr "commandArgs.R"
   $ restore: logi TRUE
   $ save   : logi TRUE
   $ vanilla: logi TRUE
   Named chr [1:17] "R" "1" "4" "noname1" "DATAPATH=../data" "--args" ...
   - attr(*, "names")= chr [1:17] "" "a" "d" "" ...
   chr [1:16] "R" "noname1" "DATAPATH=../data" "--args" "--root=do da" ...
   chr [1:15] "R" "noname1" "DATAPATH=../data" "--args" "--root=do da" ...
   chr [1:6] "D:\\RCompile\\recent\\R/bin/x64/Rterm.exe" "-f" "commandArgs.R" ...
   chr "-foo=4"
   chr [1:6] "D:\\RCompile\\recent\\R/bin/x64/Rterm.exe" "-f" "commandArgs.R" ...
  > 
  > proc.time()
     user  system elapsed 
     0.57    0.03    0.59 
Running the tests in 'tests/compressPDF.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > oopts <- options(warn=1)
  > 
  > message("*** compressPDF() ...")
  *** compressPDF() ...
  > 
  > pathname <- file.path(R.home("doc"), "NEWS.pdf")
  > if (file_test("-f", pathname)) {
  +   tryCatch({
  +     pathnameZ <- compressPDF(pathname)
  +     print(pathnameZ)
  + 
  +     pathnameZ <- compressPDF(pathname, skip=TRUE)
  +     print(pathnameZ)
  + 
  +     pathnameZ <- compressPDF(pathname, overwrite=TRUE)
  +     print(pathnameZ)
  + 
  +     file.remove(pathnameZ)
  +     removeDirectory(dirname(pathnameZ))
  +   }, error = function(ex) {
  +     warning("TEST ERROR: ", ex$message)
  +   })
  + }
  [1] "compressedPDFs/NEWS.pdf"
  attr(,"result")
  D:/RCompile/recent/R/doc/NEWS.pdf           compressedPDFs/NEWS.pdf 
                             560578                            353305 
  [1] "compressedPDFs/NEWS.pdf"
  [1] "compressedPDFs/NEWS.pdf"
  attr(,"result")
  D:/RCompile/recent/R/doc/NEWS.pdf           compressedPDFs/NEWS.pdf 
                             560578                            353305 
  > 
  > message("*** compressPDF() ...DONE")
  *** compressPDF() ...DONE
  > 
  > options(oopts)
  > 
  > proc.time()
     user  system elapsed 
     0.48    0.53    6.39 
Running the tests in 'tests/copyRenameFile.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > # Create file
  > cat("Hello", file="hello.txt")
  > stopifnot(isFile("hello.txt"))
  > 
  > # Copy file
  > copyFile("hello.txt", "hello2.txt", verbose=TRUE)
  Copying file safely...
   Source: hello.txt
   Destination: hello2.txt
   Copying to temporary file using file.copy()...
   Copying to temporary file using file.copy()...done
   Renaming temporary file to destination name...
   Renaming temporary file to destination name...done
   Validating destination file...
   Validating destination file...done
  Copying file safely...done
  [1] TRUE
  > stopifnot(isFile("hello2.txt"))
  > 
  > # Copy file
  > stopifnot(all(isFile(c("hello.txt", "hello2.txt"))))
  > 
  > # Copy file by overwriting existing file
  > copyFile("hello.txt", "hello2.txt", overwrite=TRUE)
  [1] TRUE
  > stopifnot(isFile("hello2.txt"))
  > 
  > # Copy file to directory
  > pathD <- tempdir()
  > copyFile("hello.txt", pathD)
  [1] TRUE
  > pathnameD <- file.path(pathD, "hello.txt")
  > stopifnot(isFile(pathnameD))
  > file.remove(pathnameD)
  [1] TRUE
  > 
  > # Rename file
  > renameFile("hello2.txt", "hello3.txt", verbose=TRUE)
  Renaming file safely...
   Pathname: hello2.txt
   New pathname: hello3.txt
   Renaming file using file.rename()...
    Result: TRUE
   Renaming file using file.rename()...done
   Validating...
   Validating...done
  Renaming file safely...done
  [1] TRUE
  > stopifnot(!isFile("hello2.txt"))
  > stopifnot(isFile("hello3.txt"))
  > 
  > # Rename file by overwriting existing file
  > renameFile("hello3.txt", "hello.txt", overwrite=TRUE)
  [1] TRUE
  > stopifnot(!isFile("hello3.txt"))
  > stopifnot(isFile("hello.txt"))
  > 
  > 
  > # Move file to directory (and back)
  > # NOTE: We are not moving file to tempdir() just in case
  > # that is on a different file system which in case we
  > # risk getting error "cannot rename file reason 'Invalid
  > # cross-device link' (some Unix problem)
  > pathD <- "foo"
  > mkdirs(pathD)
  [1] TRUE
  > renameFile("hello.txt", pathD)
  [1] TRUE
  > pathnameD <- file.path(pathD, "hello.txt")
  > stopifnot(isFile(pathnameD))
  > renameFile(pathnameD, ".")
  [1] TRUE
  > 
  > 
  > ## Exception handling
  > res <- try(copyFile("hello.txt", "hello.txt"), silent=TRUE)
  > stopifnot(inherits(res, "try-error"))
  > 
  > 
  > # Cleanup
  > removeDirectory("foo")
  > file.remove("hello.txt")
  [1] TRUE
  > 
  > proc.time()
     user  system elapsed 
     1.56   12.65   15.29 
Running the tests in 'tests/countLines.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > pathname <- tempfile()
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Local functions
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > writeString <- function(s, file) {
  +   raw <- charToRaw(s)
  +   writeBin(raw, con=file)
  +   if (is.character(file)) {
  +     # Sanity check
  +     stopifnot(file.info(file)$size == length(raw))
  +   }
  + } # writeString()
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Empty file
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > cat("", file=pathname)
  > # Sanity check
  > stopifnot(file.info(pathname)$size == 0L)
  > 
  > n <- countLines(pathname)
  > stopifnot(n == 0L)
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # File with one line
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # File: Ending with a new line
  > writeString("Hello world!\n", file=pathname)
  > n <- countLines(pathname)
  > stopifnot(n == 1L)
  > 
  > # File: Last line does not end with a new line
  > writeString("Hello world!", file=pathname)
  > n <- countLines(pathname)
  > stopifnot(n == 1L)
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Files with multiple lines
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > bfr <- letters[1:9]
  > 
  > # File: All lines ending with a new line
  > writeString(paste(c(bfr, ""), collapse="\n"), file=pathname)
  > n <- countLines(pathname)
  > stopifnot(n == length(bfr))
  > 
  > # File: Last line does not end with a new line
  > writeString(paste(bfr, collapse="\n"), file=pathname)
  > n <- countLines(pathname)
  > stopifnot(n == length(bfr))
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Counting either CR, LF, or CRLF
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > for (newline in c("\r", "\n", "\r\n")) {
  +   cat("Newline sequence:\n")
  +   str(newline)
  +   writeString(paste(bfr, collapse=newline), file=pathname)
  + 
  +   # Reading from file
  +   n <- countLines(pathname)
  +   stopifnot(n == length(bfr))
  + 
  +   # Reading from connection
  +   con <- file(pathname, open="rb")
  +   n <- countLines(con)
  +   close(con)
  +   stopifnot(n == length(bfr))
  + }
  Newline sequence:
   chr "\r"
  Newline sequence:
   chr "\n"
  Newline sequence:
   chr "\r\n"
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Compressed files
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > pathnameGZ <- sprintf("%s.gz", pathname)
  > for (newline in c("\r", "\n", "\r\n")) {
  +   cat("Newline sequence:\n")
  +   str(newline)
  + 
  +   con <- gzfile(pathnameGZ, open="wb")
  +   writeString(paste(bfr, collapse=newline), file=con)
  +   close(con)
  + 
  +   # Reading from file
  +   n <- countLines(pathnameGZ)
  +   stopifnot(n == length(bfr))
  +   print(n)
  + 
  +   # Reading from connection
  +   con <- gzfile(pathname, open="rb")
  +   n <- countLines(con)
  +   close(con)
  +   print(n)
  +   stopifnot(n == length(bfr))
  + }
  Newline sequence:
   chr "\r"
  [1] 9
  attr(,"lastLineHasNewline")
  [1] FALSE
  [1] 9
  attr(,"lastLineHasNewline")
  [1] FALSE
  Newline sequence:
   chr "\n"
  [1] 9
  attr(,"lastLineHasNewline")
  [1] FALSE
  [1] 9
  attr(,"lastLineHasNewline")
  [1] FALSE
  Newline sequence:
   chr "\r\n"
  [1] 9
  attr(,"lastLineHasNewline")
  [1] FALSE
  [1] 9
  attr(,"lastLineHasNewline")
  [1] FALSE
  > 
  > # Cleanup
  > file.remove(pathnameGZ)
  [1] TRUE
  > file.remove(pathname)
  [1] TRUE
  > 
  > proc.time()
     user  system elapsed 
     0.45    0.10    0.54 
Running the tests in 'tests/cout.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > show <- methods::show
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # General tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > x <- letters[1:8]
  > x2 <- c(x[-1], "\n")
  > x3 <- x2[-1]
  > y <- as.list(x[1:3])
  > 
  > cat("mprint():\n")
  mprint():
  > print(x)
  [1] "a" "b" "c" "d" "e" "f" "g" "h"
  > cprint(x)
  [1] "a" "b" "c" "d" "e" "f" "g" "h"
  > 
  > print(y)
  [[1]]
  [1] "a"
  
  [[2]]
  [1] "b"
  
  [[3]]
  [1] "c"
  
  > cprint(y)
  [[1]]
  [1] "a"
  
  [[2]]
  [1] "b"
  
  [[3]]
  [1] "c"
  
  > 
  > cat("mcat():\n")
  mcat():
  > cat(x, "\n")
  a b c d e f g h 
  > ccat(x, "\n")
  a b c d e f g h 
  > 
  > cat(x2)
  b c d e f g h 
  > ccat(x2)
  b c d e f g h 
  > 
  > cat(x3, sep=",")
  c,d,e,f,g,h,
  > ccat(x3, sep=",")
  c,d,e,f,g,h,
  > 
  > cat(x3, sep="\n")
  c
  d
  e
  f
  g
  h
  
  
  > ccat(x3, sep="\n")
  c
  d
  e
  f
  g
  h
  
  
  > 
  > 
  > cat("mstr():\n")
  mstr():
  > str(x)
   chr [1:8] "a" "b" "c" "d" "e" "f" "g" "h"
  > cstr(x)
   chr [1:8] "a" "b" "c" "d" "e" "f" "g" "h"
  > 
  > str(y)
  List of 3
   $ : chr "a"
   $ : chr "b"
   $ : chr "c"
  > cstr(y)
  List of 3
   $ : chr "a"
   $ : chr "b"
   $ : chr "c"
  > 
  > cat("mshow():\n")
  mshow():
  > show(x)
  [1] "a" "b" "c" "d" "e" "f" "g" "h"
  > cshow(x)
  [1] "a" "b" "c" "d" "e" "f" "g" "h"
  > 
  > show(y)
  [[1]]
  [1] "a"
  
  [[2]]
  [1] "b"
  
  [[3]]
  [1] "c"
  
  > cshow(y)
  [[1]]
  [1] "a"
  
  [[2]]
  [1] "b"
  
  [[3]]
  [1] "c"
  
  > 
  > cat("mprintf():\n")
  mprintf():
  > printf("x=%d\n", 1:3)
  x=1
  x=2
  x=3
  > cprintf("x=%d\n", 1:3)
  x=1
   x=2
   x=3
  > 
  > cat("mout():\n")
  mout():
  > writeLines(x)
  a
  b
  c
  d
  e
  f
  g
  h
  > cout(writeLines(x))
  a
  b
  c
  d
  e
  f
  g
  h
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Tests related to closure
  > # - - - - - - - - - - - -- - - - - - - - - - - - - - - - - -
  > cfoo <- function(a=1) {
  +   cprintf("a=%s\n", a)
  + }
  > 
  > cbar <- function(...) {
  +   cfoo(...)
  + }
  > 
  > a <- 2
  > cfoo(a)
  a=2
  > cfoo(3)
  a=3
  > 
  > cbar(a)
  a=2
  > cbar(3)
  a=3
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Assert that "console" messages cannot be captured/sunk
  > # via neither stdout nor stderr
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > res <- captureOutput({ ccat("Hello") })
  Hello
  > str(res)
   chr(0) 
  > stopifnot(length(res) == 0L)
  > 
  > withSink({ ccat("Hello") }, file="foo.txt", type="message")
  Hello
  > res <- readLines("foo.txt")
  > str(res)
   chr(0) 
  > stopifnot(length(res) == 0L)
  > 
  > proc.time()
     user  system elapsed 
     0.32    0.09    0.39 
Running the tests in 'tests/createFileAtomically.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Create a file atomically
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > n <- 10
  > createFileAtomically("foobar.txt", FUN=function(pathname) {
  +   cat(file=pathname, "This file was created atomically.\n")
  +   cat(file=pathname, "Timestamp: ", as.character(Sys.time()), "\n", sep="")
  +   for (kk in 1:n) {
  +     cat(file=pathname, kk, "\n", append=TRUE)
  +     # Emulate a slow process
  +     if (interactive()) Sys.sleep(0.1)
  +   }
  +   cat(file=pathname, "END OF FILE\n", append=TRUE)
  + }, overwrite=TRUE)
  > 
  > # Skip, if already exists
  > createFileAtomically("foobar.txt", FUN=function(pathname) {
  +   cat("This will not be called\n")
  + }, skip=TRUE, verbose=TRUE)
  Writes a file atomically...
   Pathname: foobar.txt
   Argument 'skip': TRUE
   Argument 'overwrite': FALSE
   Returning already existing file (skip=TRUE).
  Writes a file atomically...done
  [1] "foobar.txt"
  > 
  > bfr <- readLines("foobar.txt")
  > cat(bfr, sep="\n")
  Timestamp: 2024-03-23 09:33:17.625459
  1 
  2 
  3 
  4 
  5 
  6 
  7 
  8 
  9 
  10 
  END OF FILE
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Overwrite the file atomically (emulate write failure)
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > tryCatch({
  +   createFileAtomically("foobar.txt", FUN=function(pathname) {
  +     cat(file=pathname, "Trying to create a new file.\n")
  +     cat(file=pathname, "Writing a bit, but then an error...\n", append=TRUE)
  +     # Emulate write error
  +     stop("An error occured while writing to the new file.")
  +     cat(file=pathname, "END OF FILE\n", append=TRUE)
  +   }, overwrite=TRUE)
  + }, error = function(ex) {
  +   print(ex$message)
  + })
  > 
  > # The original file was never overwritten
  > bfr2 <- readLines("foobar.txt")
  > cat(bfr2, sep="\n")
  Timestamp: 2024-03-23 09:33:17.625459
  1 
  2 
  3 
  4 
  5 
  6 
  7 
  8 
  9 
  10 
  END OF FILE
  > stopifnot(identical(bfr2, bfr))
  > 
  > # The partially temporary file remains
  > stopifnot(isFile("foobar.txt.tmp"))
  > bfr3 <- readLines("foobar.txt.tmp")
  > cat(bfr3, sep="\n")
  Trying to create a new file.
  Writing a bit, but then an error...
  > 
  > file.remove("foobar.txt.tmp")
  [1] TRUE
  > file.remove("foobar.txt")
  [1] TRUE
  > 
  > proc.time()
     user  system elapsed 
     0.42    0.07    0.48 
Running the tests in 'tests/createLink.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > verbose <- Verbose(threshold=-1)
  > 
  > options(warn = 1L)
  > 
  > pathname <- tempfile("foo_", fileext = ".txt")
  > pathname <- getAbsolutePath(pathname)
  > cat(file=pathname, "Hello world!\n")
  > 
  > ## NOTE: Not all systems support creation of links, which is
  > ## why we need to run the tests using tryCatch().
  > 
  > ## Try all methods at once
  > link <- basename(pathname)
  > tryCatch({
  +   linkR <- createLink(link=link, target=pathname)
  +   verbose && cat(verbose, "Link returned: ", linkR)
  +   linkR <- normalizePath(linkR)
  +   link <- normalizePath(link)
  +   if (linkR != link) {
  +     throw("Requested and returned link are not the same: ", sQuote(linkR), " != ", sQuote(link))
  +   }
  + }, error = function(ex) {
  +   verbose && cat(verbose, "Failed to create link: ", ex$message)
  + })
  Ihre Berechtigungen reichen nicht aus, um diesen Vorgang auszuführen.
  Warning in system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait,  :
    running command 'C:\Windows\system32\cmd.exe /c mklink "foo_928c458717e.txt" "D:/temp/Rtmp4GHath/foo_928c458717e.txt"' had status 1
  Link returned: foo_928c458717e.txt
  Warning in normalizePath(path.expand(path), winslash, mustWork) :
    path[1]="foo_928c458717e.txt": Das System kann die angegebene Datei nicht finden
  Warning in normalizePath(path.expand(path), winslash, mustWork) :
    path[1]="foo_928c458717e.txt": Das System kann die angegebene Datei nicht finden
  > 
  > ## One method at the time
  > methods <- c("unix-symlink", "windows-ntfs-symlink", "windows-shortcut")
  > for (method in methods) {
  +   verbose && enterf(verbose, "Method '%s'", method)
  +   verbose && cat(verbose, "Target: ", pathname)
  +   link <- sprintf("%s-to-%s", method, basename(pathname))
  +   verbose && cat(verbose, "Link to create: ", link)
  +   tryCatch({
  +     linkR <- createLink(link=link, target=pathname, method=method)
  +     verbose && cat(verbose, "Link returned: ", linkR)
  +     linkR <- normalizePath(linkR)
  +     link <- normalizePath(link)
  +     if (linkR != link) {
  +       throw("Requested and returned link are not the same: ", sQuote(linkR), " != ", sQuote(link))
  +     }
  +   }, error = function(ex) {
  +     verbose && cat(verbose, "Failed to create link: ", ex$message)
  +   })
  +   verbose && exit(verbose)
  + }
  Method 'unix-symlink'...
   Target: D:/temp/Rtmp4GHath/foo_928c458717e.txt
   Link to create: unix-symlink-to-foo_928c458717e.txt
   Failed to create link: Failed to create file link (methods attempted: 'unix-symlink'; current working directory: 'd:/Rcompile/CRANpkg/local/4.4/R.utils.Rcheck/tests'): 'unix-symlink-to-foo_928c458717e.txt'[.lnk] -> 'D:/temp/Rtmp4GHath/foo_928c458717e.txt'
  Warnings and errors captured: unix-symlink produced simpleWarning: 'cannot symlink 'D:\temp\Rtmp4GHath\foo_928c458717e.txt' to 'unix-symlink-to-foo_928c458717e.txt', reason 'Dem Client fehlt ein erforderliches Recht''
  Method 'unix-symlink'...done
  Method 'windows-ntfs-symlink'...
   Target: D:/temp/Rtmp4GHath/foo_928c458717e.txt
   Link to create: windows-ntfs-symlink-to-foo_928c458717e.txt
  Ihre Berechtigungen reichen nicht aus, um diesen Vorgang auszuführen.
  Warning in system(cmd, intern = intern, wait = wait | intern, show.output.on.console = wait,  :
    running command 'C:\Windows\system32\cmd.exe /c mklink "windows-ntfs-symlink-to-foo_928c458717e.txt" "D:/temp/Rtmp4GHath/foo_928c458717e.txt"' had status 1
   Failed to create link: Failed to create file link (methods attempted: 'windows-ntfs-symlink'; current working directory: 'd:/Rcompile/CRANpkg/local/4.4/R.utils.Rcheck/tests'): 'windows-ntfs-symlink-to-foo_928c458717e.txt'[.lnk] -> 'D:/temp/Rtmp4GHath/foo_928c458717e.txt'
  Warnings and errors captured: windows-ntfs-symlink produced Exception: 'Shell command 'mklink "windows-ntfs-symlink-to-foo_928c458717e.txt" "D:/temp/Rtmp4GHath/foo_928c458717e.txt"' had status 1 (using shell 'C:\Windows\system32\cmd.exe'): '
  Method 'windows-ntfs-symlink'...done
  Method 'windows-shortcut'...
   Target: D:/temp/Rtmp4GHath/foo_928c458717e.txt
   Link to create: windows-shortcut-to-foo_928c458717e.txt
   Link returned: windows-shortcut-to-foo_928c458717e.txt
  Warning in normalizePath(path.expand(path), winslash, mustWork) :
    path[1]="windows-shortcut-to-foo_928c458717e.txt": Das System kann die angegebene Datei nicht finden
  Warning in normalizePath(path.expand(path), winslash, mustWork) :
    path[1]="windows-shortcut-to-foo_928c458717e.txt": Das System kann die angegebene Datei nicht finden
  Method 'windows-shortcut'...done
  > 
  > if (isFile(pathname)) file.remove(pathname)
  [1] TRUE
  > 
  > proc.time()
     user  system elapsed 
     0.50    0.10    1.29 
Running the tests in 'tests/dataFrame.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > df <- dataFrame(colClasses=c(a="integer", b="double"), nrow=10)
  > df[,1] <- sample(1:nrow(df))
  > df[,2] <- rnorm(nrow(df))
  > print(df)
      a           b
  1   7  1.07593103
  2   1  0.84175525
  3   2 -0.03393849
  4   9  0.14677006
  5  10 -0.31946275
  6   8 -1.53804809
  7   3 -1.09111144
  8   4  0.08622458
  9   5 -0.33239547
  10  6 -0.43683501
  > 
  > proc.time()
     user  system elapsed 
     0.25    0.09    0.32 
Running the tests in 'tests/extract.array.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Example using an array with a random number of dimensions
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > maxdim <- 4
  > dim <- sample(3:maxdim, size=sample(2:maxdim, size=1), replace=TRUE)
  > ndim <- length(dim)
  > dimnames <- list()
  > for (kk in 1:ndim)
  +   dimnames[[kk]] <- sprintf("%s%d", letters[kk], 1:dim[kk])
  > x <- 1:prod(dim)
  > x <- array(x, dim=dim, dimnames=dimnames)
  > 
  > cat("\nArray 'x':\n")
  
  Array 'x':
  > print(x)
     b1 b2 b3
  a1  1  4  7
  a2  2  5  8
  a3  3  6  9
  > 
  > 
  > cat("\nExtract 'x[2:3,...]':\n")
  
  Extract 'x[2:3,...]':
  > print(extract(x, "1"=2:3))
     b1 b2 b3
  a2  2  5  8
  a3  3  6  9
  > 
  > cat("\nExtract 'x[3,2:3,...]':\n")
  
  Extract 'x[3,2:3,...]':
  > print(extract(x, "1"=3,"2"=2:3))
     b2 b3
  a3  6  9
  > 
  > cat("\nExtract 'x[...,2:3]':\n")
  
  Extract 'x[...,2:3]':
  > print(extract(x, indices=2:3, dims=length(dim(x))))
     b2
  a1  4
  a2  5
  a3  6
  > 
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Assertions
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > y <- array(1:24, dim=c(2,3,4))
  > yA <- y[,,2:3]
  > yB <- extract(y, indices=list(2:3), dims=length(dim(y)))
  > stopifnot(identical(yB, yA))
  > 
  > yA <- y[,2:3,2]
  > yB <- extract(y, indices=list(2:3,2), dims=c(2,3), drop=TRUE)
  > stopifnot(identical(yB, yA))
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Matrix
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > y <- matrix(1:24, nrow=6, ncol=4)
  > yA <- y[,2:3]
  > yB <- extract(y, indices=list(2:3), dims=length(dim(y)))
  > stopifnot(identical(yB, yA))
  > 
  > proc.time()
     user  system elapsed 
     0.25    0.14    0.39 
Running the tests in 'tests/gcDLLs.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > message("*** getDLLs() ...")
  *** getDLLs() ...
  > 
  > dlls <- strayDLLs()
  > print(dlls)
  > 
  > dlls <- gcDLLs(quiet = TRUE)
  > print(dlls)
  > 
  > dlls <- gcDLLs(quiet = FALSE)
  > print(dlls)
  > 
  > message("*** getDLLs() ... DONE")
  *** getDLLs() ... DONE
  > 
  > proc.time()
     user  system elapsed 
     0.17    0.10    0.26 
Running the tests in 'tests/gcat.R' failed.
Complete output:
  > message("*** Testing gcat()...")
  *** Testing gcat()...
  > 
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > gcat("Hello world!\n")
  Hello world!
  > 
  > a <- 1
  > gcat("a=${a}\n")
  a=1
  > 
  > gcat(GString("a=${a}\n"))
  a=1
  > 
  > message("*** Testing gcat()...DONE")
  *** Testing gcat()...DONE
  > 
  > 
  > message("*** Testing gstring()...")
  *** Testing gstring()...
  > 
  > a <- 2
  > s <- gstring("a=${a}\n")
  > print(s)
  [1] "a=2\n"
  > 
  > cat("a=${a}\n", file="foo.txt")
  > s <- gstring(file="foo.txt")
  > print(s)
  [1] "a=2"
  > file.remove("foo.txt")
  [1] TRUE
  > 
  > pathT <- tempdir()
  > pathname <- file.path(pathT, "foo.txt")
  > cat("a=${a}\n", file=pathname)
  > s <- gstring(file="foo.txt", path=pathT)
  > print(s)
  [1] "a=2"
  > file.remove(pathname)
  [1] TRUE
  > 
  > message("*** Testing gcat()...DONE")
  *** Testing gcat()...DONE
  > 
  > proc.time()
     user  system elapsed 
     0.23    0.12    0.36 
Running the tests in 'tests/getOption.R' failed.
Complete output:
  > digits0 <- digits <- base::getOption("digits")
  > print(digits)
  [1] 7
  > 
  > digits <- getOption("digits")
  > print(digits)
  [1] 7
  > stopifnot(identical(digits, digits0))
  > 
  > digits <- R.utils::getOption("digits")
  > print(digits)
  [1] 7
  > stopifnot(identical(digits, digits0))
  > 
  > 
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > digits <- base::getOption("digits")
  > print(digits)
  [1] 7
  > stopifnot(identical(digits, digits0))
  > 
  > digits <- getOption("digits")
  > print(digits)
  [1] 7
  > stopifnot(identical(digits, digits0))
  > 
  > digits <- R.utils::getOption("digits")
  > print(digits)
  [1] 7
  > stopifnot(identical(digits, digits0))
  > 
  > 
  > 
  > proc.time()
     user  system elapsed 
     0.26    0.09    0.34 
Running the tests in 'tests/hpaste.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > 
  > # Some vectors
  > x <- 1:6
  > y <- 10:1
  > z <- LETTERS[x]
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  > # Abbreviation of output vector
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  > printf("x = %s.\n", hpaste(x))
  x = 1, 2, 3, ..., 6.
  > ## x = 1, 2, 3, ..., 6.
  > 
  > printf("x = %s.\n", hpaste(x, maxHead=2))
  x = 1, 2, ..., 6.
  > ## x = 1, 2, ..., 6.
  > 
  > printf("x = %s.\n", hpaste(x, maxHead=3)) # Default
  x = 1, 2, 3, ..., 6.
  > ## x = 1, 2, 3, ..., 6.
  > 
  > # It will never output 1, 2, 3, 4, ..., 6
  > printf("x = %s.\n", hpaste(x, maxHead=4))
  x = 1, 2, 3, 4, 5, 6.
  > ## x = 1, 2, 3, 4, 5 and 6.
  > 
  > # Showing the tail
  > printf("x = %s.\n", hpaste(x, maxHead=1, maxTail=2))
  x = 1, ..., 5, 6.
  > ## x = 1, ..., 5, 6.
  > 
  > # Turning off abbreviation
  > printf("y = %s.\n", hpaste(y, maxHead=Inf))
  y = 10, 9, 8, 7, 6, 5, 4, 3, 2, 1.
  > ## y = 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
  > 
  > ## ...or simply
  > printf("y = %s.\n", paste(y, collapse=", "))
  y = 10, 9, 8, 7, 6, 5, 4, 3, 2, 1.
  > ## y = 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  > # Adding a special separator before the last element
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  > # Change last separator
  > printf("x = %s.\n", hpaste(x, lastCollapse=" and "))
  x = 1, 2, 3, 4, 5 and 6.
  > ## x = 1, 2, 3, 4, 5 and 6.
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Empty input
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  > s <- hpaste(integer(0))
  > stopifnot(identical(s, character(0L)))
  > 
  > s <- hpaste(integer(0), empty = "")
  > stopifnot(identical(s, ""))
  > 
  > s <- hpaste(integer(0), empty = NA_character_)
  > stopifnot(identical(s, NA_character_))
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  > # Backward compatibility with paste()
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  > s1 <- hpaste(x, maxHead=Inf)
  > s2 <- paste(x, collapse=", ")
  > printf("s = %s.\n", s1)
  s = 1, 2, 3, 4, 5, 6.
  > stopifnot(identical(s1, s2))
  > 
  > s1 <- hpaste('<', x, '>', maxHead=Inf)
  > s2 <- paste('<', x, '>', sep="", collapse=", ")
  > printf("s = %s.\n", s1)
  s = <1>, <2>, <3>, <4>, <5>, <6>.
  > stopifnot(identical(s1, s2))
  > 
  > s1 <- hpaste(x, y, z, sep="/", maxHead=Inf)
  > s2 <- paste(x, y, z, sep="/", collapse=", ")
  > printf("s = %s.\n", s1)
  s = 1/10/A, 2/9/B, 3/8/C, 4/7/D, 5/6/E, 6/5/F, 1/4/A, 2/3/B, 3/2/C, 4/1/D.
  > stopifnot(identical(s1, s2))
  > 
  > s1 <- hpaste(x, collapse=NULL, maxHead=Inf)
  > s2 <- paste(x, collapse=NULL)
  > stopifnot(identical(s1, s2))
  > 
  > 
  > proc.time()
     user  system elapsed 
     0.20    0.14    0.32 
Running the tests in 'tests/insert.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > 
  > # Insert NAs (default) between all values
  > y <- c(a=1, b=2, c=3)
  > print(y)
  a b c 
  1 2 3 
  > x <- insert(y, ats=2:length(y))
  > Ex <- c(y[1], NA_real_, y[2], NA_real_, y[3])
  > print(x)
   a     b     c 
   1 NA  2 NA  3 
  > stopifnot(identical(x,Ex))
  > 
  > # Insert at first position
  > y <- c(a=1, b=2, c=3)
  > print(y)
  a b c 
  1 2 3 
  > x <- insert(y, ats=1, values=rep(NA_real_, 2))
  > Ex <- c(NA_real_,NA_real_,y)
  > print(x)
         a  b  c 
  NA NA  1  2  3 
  > stopifnot(identical(x,Ex))
  > 
  > x <- insert(y, ats=1, values=rep(NA_real_,2), useNames=FALSE)
  > print(x)
  [1] NA NA  1  2  3
  > 
  > # Insert at last position (names of 'values' are ignored
  > # because input vector has no names)
  > x <- insert(1:3, ats=4, values=c(d=2, e=1))
  > Ex <- c(1:3,2,1)
  > print(x)
  [1] 1 2 3 2 1
  > stopifnot(identical(x,Ex))
  > 
  > 
  > # Insert in the middle of a vector
  > x <- insert(c(1,3,2,1), ats=2, values=2)
  > print(x)
  [1] 1 2 3 2 1
  > stopifnot(identical(as.double(x),as.double(Ex)))
  > 
  > 
  > # Insert multiple vectors at multiple indices at once
  > x0 <- c(1:4, 8:11, 13:15)
  > 
  > x <- insert(x0, ats=c(5,9), values=list(5:7,12))
  > print(x)
   [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
  > Ex <- 1:max(x)
  > stopifnot(identical(as.double(x),as.double(Ex)))
  > 
  > x <- insert(x0, ats=c(5,9,12), values=list(5:7,12,16:18))
  > print(x)
   [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18
  > Ex <- 1:max(x)
  > stopifnot(identical(as.double(x),as.double(Ex)))
  > 
  > 
  > # Insert with duplicated locations (which requires grouping)
  > x <- letters[1:6]
  > ats <- c(1L, 1L, 4L)
  > values <- LETTERS[1:3]
  > y0 <- c("A", "B", "a", "b", "c", "C", "d", "e", "f")
  > y <- insert(x, ats = ats, values = values)
  > print(y)
  [1] "A" "B" "a" "b" "c" "C" "d" "e" "f"
  > stopifnot(identical(y, y0))
  > 
  > ats <- c(1L, 4L)
  > values <- list(LETTERS[1:2], LETTERS[3])
  > y <- insert(x, ats = ats, values = values)
  > print(y)
  [1] "A" "B" "a" "b" "c" "C" "d" "e" "f"
  > stopifnot(identical(y, y0))
  > 
  > 
  > # Insert missing indices
  > Ex <- 1:20
  > missing <- setdiff(Ex, x0)
  > x <- x0
  > for (m in missing)
  +   x <- insert(x, ats=m, values=m)
  > print(x)
   [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
  > stopifnot(identical(as.double(x),as.double(Ex)))
  > 
  > 
  > ## Exception handling
  > x <- 1:10
  > res <- try(y <- insert(x, ats=1:2, values=1:3), silent=TRUE)
  > stopifnot(inherits(res, "try-error"))
  > 
  > proc.time()
     user  system elapsed 
     0.29    0.03    0.31 
Running the tests in 'tests/listDirectory.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > path <- system.file(package="R.utils")
  > print(listDirectory(path))
   [1] "DESCRIPTION" "INDEX"       "MD5"         "Meta"        "NAMESPACE"  
   [6] "NEWS.md"     "R"           "WORDLIST"    "data-ex"     "help"       
  [11] "html"       
  > print(listDirectory(path, pattern="DESCRIPTION"))
  [1] "DESCRIPTION"
  > print(listDirectory(path, recursive=TRUE))
   [1] "DESCRIPTION"                         "INDEX"                              
   [3] "MD5"                                 "Meta"                               
   [5] "NAMESPACE"                           "NEWS.md"                            
   [7] "R"                                   "WORDLIST"                           
   [9] "data-ex"                             "help"                               
  [11] "html"                                "Meta/Rd.rds"                        
  [13] "Meta/features.rds"                   "Meta/hsearch.rds"                   
  [15] "Meta/links.rds"                      "Meta/nsInfo.rds"                    
  [17] "Meta/package.rds"                    "R/R.utils"                          
  [19] "R/R.utils.rdb"                       "R/R.utils.rdx"                      
  [21] "data-ex/HISTORY.LNK"                 "data-ex/NEWS.LNK"                   
  [23] "data-ex/exampleVComments.R"          "data-ex/lnkFileWith10BitsInFlag.lnk"
  [25] "help/AnIndex"                        "help/R.utils.rdb"                   
  [27] "help/R.utils.rdx"                    "help/aliases.rds"                   
  [29] "help/paths.rds"                      "html/00Index.html"                  
  [31] "html/R.css"                         
  > print(listDirectory(path, recursive=+Inf))
   [1] "DESCRIPTION"                         "INDEX"                              
   [3] "MD5"                                 "Meta"                               
   [5] "NAMESPACE"                           "NEWS.md"                            
   [7] "R"                                   "WORDLIST"                           
   [9] "data-ex"                             "help"                               
  [11] "html"                                "Meta/Rd.rds"                        
  [13] "Meta/features.rds"                   "Meta/hsearch.rds"                   
  [15] "Meta/links.rds"                      "Meta/nsInfo.rds"                    
  [17] "Meta/package.rds"                    "R/R.utils"                          
  [19] "R/R.utils.rdb"                       "R/R.utils.rdx"                      
  [21] "data-ex/HISTORY.LNK"                 "data-ex/NEWS.LNK"                   
  [23] "data-ex/exampleVComments.R"          "data-ex/lnkFileWith10BitsInFlag.lnk"
  [25] "help/AnIndex"                        "help/R.utils.rdb"                   
  [27] "help/R.utils.rdx"                    "help/aliases.rds"                   
  [29] "help/paths.rds"                      "html/00Index.html"                  
  [31] "html/R.css"                         
  > print(listDirectory(path, recursive=FALSE))
   [1] "DESCRIPTION" "INDEX"       "MD5"         "Meta"        "NAMESPACE"  
   [6] "NEWS.md"     "R"           "WORDLIST"    "data-ex"     "help"       
  [11] "html"       
  > print(listDirectory(path, recursive=0L))
   [1] "DESCRIPTION" "INDEX"       "MD5"         "Meta"        "NAMESPACE"  
   [6] "NEWS.md"     "R"           "WORDLIST"    "data-ex"     "help"       
  [11] "html"       
  > print(listDirectory(path, recursive=1L))
   [1] "DESCRIPTION"                         "INDEX"                              
   [3] "MD5"                                 "Meta"                               
   [5] "NAMESPACE"                           "NEWS.md"                            
   [7] "R"                                   "WORDLIST"                           
   [9] "data-ex"                             "help"                               
  [11] "html"                                "Meta/Rd.rds"                        
  [13] "Meta/features.rds"                   "Meta/hsearch.rds"                   
  [15] "Meta/links.rds"                      "Meta/nsInfo.rds"                    
  [17] "Meta/package.rds"                    "R/R.utils"                          
  [19] "R/R.utils.rdb"                       "R/R.utils.rdx"                      
  [21] "data-ex/HISTORY.LNK"                 "data-ex/NEWS.LNK"                   
  [23] "data-ex/exampleVComments.R"          "data-ex/lnkFileWith10BitsInFlag.lnk"
  [25] "help/AnIndex"                        "help/R.utils.rdb"                   
  [27] "help/R.utils.rdx"                    "help/aliases.rds"                   
  [29] "help/paths.rds"                      "html/00Index.html"                  
  [31] "html/R.css"                         
  > print(listDirectory(path, recursive=2L))
   [1] "DESCRIPTION"                         "INDEX"                              
   [3] "MD5"                                 "Meta"                               
   [5] "NAMESPACE"                           "NEWS.md"                            
   [7] "R"                                   "WORDLIST"                           
   [9] "data-ex"                             "help"                               
  [11] "html"                                "Meta/Rd.rds"                        
  [13] "Meta/features.rds"                   "Meta/hsearch.rds"                   
  [15] "Meta/links.rds"                      "Meta/nsInfo.rds"                    
  [17] "Meta/package.rds"                    "R/R.utils"                          
  [19] "R/R.utils.rdb"                       "R/R.utils.rdx"                      
  [21] "data-ex/HISTORY.LNK"                 "data-ex/NEWS.LNK"                   
  [23] "data-ex/exampleVComments.R"          "data-ex/lnkFileWith10BitsInFlag.lnk"
  [25] "help/AnIndex"                        "help/R.utils.rdb"                   
  [27] "help/R.utils.rdx"                    "help/aliases.rds"                   
  [29] "help/paths.rds"                      "html/00Index.html"                  
  [31] "html/R.css"                         
  > 
  > ## Full names
  > print(listDirectory(path, recursive=2L, fullNames=TRUE))
   [1] "D:/RCompile/CRANpkg/lib/4.4/R.utils/DESCRIPTION"                        
   [2] "D:/RCompile/CRANpkg/lib/4.4/R.utils/INDEX"                              
   [3] "D:/RCompile/CRANpkg/lib/4.4/R.utils/MD5"                                
   [4] "D:/RCompile/CRANpkg/lib/4.4/R.utils/Meta"                               
   [5] "D:/RCompile/CRANpkg/lib/4.4/R.utils/NAMESPACE"                          
   [6] "D:/RCompile/CRANpkg/lib/4.4/R.utils/NEWS.md"                            
   [7] "D:/RCompile/CRANpkg/lib/4.4/R.utils/R"                                  
   [8] "D:/RCompile/CRANpkg/lib/4.4/R.utils/WORDLIST"                           
   [9] "D:/RCompile/CRANpkg/lib/4.4/R.utils/data-ex"                            
  [10] "D:/RCompile/CRANpkg/lib/4.4/R.utils/help"                               
  [11] "D:/RCompile/CRANpkg/lib/4.4/R.utils/html"                               
  [12] "D:/RCompile/CRANpkg/lib/4.4/R.utils/Meta/Rd.rds"                        
  [13] "D:/RCompile/CRANpkg/lib/4.4/R.utils/Meta/features.rds"                  
  [14] "D:/RCompile/CRANpkg/lib/4.4/R.utils/Meta/hsearch.rds"                   
  [15] "D:/RCompile/CRANpkg/lib/4.4/R.utils/Meta/links.rds"                     
  [16] "D:/RCompile/CRANpkg/lib/4.4/R.utils/Meta/nsInfo.rds"                    
  [17] "D:/RCompile/CRANpkg/lib/4.4/R.utils/Meta/package.rds"                   
  [18] "D:/RCompile/CRANpkg/lib/4.4/R.utils/R/R.utils"                          
  [19] "D:/RCompile/CRANpkg/lib/4.4/R.utils/R/R.utils.rdb"                      
  [20] "D:/RCompile/CRANpkg/lib/4.4/R.utils/R/R.utils.rdx"                      
  [21] "D:/RCompile/CRANpkg/lib/4.4/R.utils/data-ex/HISTORY.LNK"                
  [22] "D:/RCompile/CRANpkg/lib/4.4/R.utils/data-ex/NEWS.LNK"                   
  [23] "D:/RCompile/CRANpkg/lib/4.4/R.utils/data-ex/exampleVComments.R"         
  [24] "D:/RCompile/CRANpkg/lib/4.4/R.utils/data-ex/lnkFileWith10BitsInFlag.lnk"
  [25] "D:/RCompile/CRANpkg/lib/4.4/R.utils/help/AnIndex"                       
  [26] "D:/RCompile/CRANpkg/lib/4.4/R.utils/help/R.utils.rdb"                   
  [27] "D:/RCompile/CRANpkg/lib/4.4/R.utils/help/R.utils.rdx"                   
  [28] "D:/RCompile/CRANpkg/lib/4.4/R.utils/help/aliases.rds"                   
  [29] "D:/RCompile/CRANpkg/lib/4.4/R.utils/help/paths.rds"                     
  [30] "D:/RCompile/CRANpkg/lib/4.4/R.utils/html/00Index.html"                  
  [31] "D:/RCompile/CRANpkg/lib/4.4/R.utils/html/R.css"                         
  > 
  > ## Non-existing
  > print(listDirectory("unknown-path"))
  NULL
  > 
  > 
  > proc.time()
     user  system elapsed 
     0.31    0.17    0.42 
Running the tests in 'tests/loadToEnv.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > file <- tempfile()
  > 
  > x <- 1:10
  > save(x, file=file)
  > 
  > env <- loadToEnv(file)
  > print(env)
  <environment: 0x000001c1ddc46b88>
  > print(ls(envir=env))
  [1] "x"
  > 
  > file.remove(file)
  [1] TRUE
  > 
  > proc.time()
     user  system elapsed 
     0.28    0.07    0.32 
Running the tests in 'tests/mkdirs.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > message("*** mkdirs() ...")
  *** mkdirs() ...
  > 
  > message("*** mkdirs(..., recursive=TRUE) ...")
  *** mkdirs(..., recursive=TRUE) ...
  > 
  > pathT <- tempdir()
  > mprint(pathT)
  [1] "D:\\temp\\RtmpADJaIU"
  > stopifnot(isDirectory(pathT))
  > 
  > path <- file.path(pathT, "foo", "bar")
  > mprint(path)
  [1] "D:\\temp\\RtmpADJaIU/foo/bar"
  > mkdirs(path)
  [1] TRUE
  > stopifnot(isDirectory(path))
  > 
  > paths <- c(dirname(path), path)
  > stopifnot(all(isDirectory(paths)))
  > 
  > path <- dirname(path)
  > removeDirectory(path, recursive=TRUE)
  > stopifnot(!isDirectory(path))
  > 
  > message("*** mkdirs(..., recursive=TRUE) ... DONE")
  *** mkdirs(..., recursive=TRUE) ... DONE
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # EXCEPTIONS
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > message("*** mkdirs(..., mustWork=TRUE) ...")
  *** mkdirs(..., mustWork=TRUE) ...
  > 
  > path <- file.path(pathT, "foo")
  > res <- mkdirs(path)
  > stopifnot(isDirectory(path))
  > 
  > ## Create file with same name
  > pathname <- file.path(path, "bar")
  > cat("Hello", file=pathname)
  > stopifnot(isFile(pathname))
  > 
  > res <- mkdirs(pathname)
  > stopifnot(isFile(pathname), !isDirectory(pathname))
  > 
  > res <- try(mkdirs(pathname, mustWork=TRUE), silent=TRUE)
  > cat(res)
  Error in mkdirs.default(pathname, mustWork = TRUE) : 
    Failed to create directory, because a file with the same pathname already exists: D:\temp\RtmpADJaIU/foo/bar
  > stopifnot(inherits(res, "try-error"))
  > stopifnot(isFile(pathname), !isDirectory(pathname))
  > 
  > ## Parent is a file, not a directory
  > path2 <- file.path(path, "bar", "yaa")
  > res <- try(mkdirs(path2, mustWork=TRUE), silent=TRUE)
  > cat(res)
  Error in mkdirs.default(path2, mustWork = TRUE) : 
    Could not create directory, because parent ('D:/temp/RtmpADJaIU/foo/bar') is a file not a directory: D:\temp\RtmpADJaIU/foo/bar/yaa
  > stopifnot(inherits(res, "try-error"))
  > stopifnot(!isDirectory(path2))
  > 
  > removeDirectory(path, recursive=TRUE)
  > stopifnot(!isDirectory(path))
  > 
  > message("*** mkdirs(..., mustWork=TRUE) ... DONE")
  *** mkdirs(..., mustWork=TRUE) ... DONE
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # SPECIAL:
  > # Windows has a undocumented "feature" that for some set
  > # ups on some machines (not all) it will for instance
  > # silently drop a trailing period and create the directory
  > # without it, e.g. 'G.S.' becomes 'G.S', cf.help("dir.create").
  > # See also https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=15996
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > message("*** mkdirs('G.S.') ...")
  *** mkdirs('G.S.') ...
  > 
  > path <- file.path(pathT, "G.S.")
  > mprint(path)
  [1] "D:\\temp\\RtmpADJaIU/G.S."
  > mkdirs(path)
  [1] TRUE
  > tryCatch({
  +   stopifnot(isDirectory(path))
  +   removeDirectory(path)
  + }, error = function(ex) {
  +   mprint(ex)
  + })
  > 
  > message("*** mkdirs('G.S.') ... DONE")
  *** mkdirs('G.S.') ... DONE
  > 
  > message("*** mkdirs() ... DONE")
  *** mkdirs() ... DONE
  > 
  > proc.time()
     user  system elapsed 
     0.40    0.10    2.51 
Running the tests in 'tests/mout.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > show <- methods::show
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # General tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > x <- letters[1:8]
  > x2 <- c(x[-1], "\n")
  > x3 <- x2[-1]
  > y <- as.list(x[1:3])
  > 
  > cat("mprint():\n")
  mprint():
  > print(x)
  [1] "a" "b" "c" "d" "e" "f" "g" "h"
  > mprint(x)
  [1] "a" "b" "c" "d" "e" "f" "g" "h"
  > 
  > print(y)
  [[1]]
  [1] "a"
  
  [[2]]
  [1] "b"
  
  [[3]]
  [1] "c"
  
  > mprint(y)
  [[1]]
  [1] "a"
  
  [[2]]
  [1] "b"
  
  [[3]]
  [1] "c"
  
  > 
  > cat("mcat():\n")
  mcat():
  > cat(x, "\n")
  a b c d e f g h 
  > mcat(x, "\n")
  a b c d e f g h 
  > 
  > cat(x2)
  b c d e f g h 
  > mcat(x2)
  b c d e f g h 
  > 
  > cat(x3, sep=",")
  c,d,e,f,g,h,
  > mcat(x3, sep=",")
  c,d,e,f,g,h,
  > 
  > cat(x3, sep="\n")
  c
  d
  e
  f
  g
  h
  
  
  > mcat(x3, sep="\n")
  c
  d
  e
  f
  g
  h
  
  
  > 
  > 
  > cat("mstr():\n")
  mstr():
  > str(x)
   chr [1:8] "a" "b" "c" "d" "e" "f" "g" "h"
  > mstr(x)
   chr [1:8] "a" "b" "c" "d" "e" "f" "g" "h"
  > 
  > str(y)
  List of 3
   $ : chr "a"
   $ : chr "b"
   $ : chr "c"
  > mstr(y)
  List of 3
   $ : chr "a"
   $ : chr "b"
   $ : chr "c"
  > 
  > cat("mshow():\n")
  mshow():
  > show(x)
  [1] "a" "b" "c" "d" "e" "f" "g" "h"
  > mshow(x)
  [1] "a" "b" "c" "d" "e" "f" "g" "h"
  > 
  > show(y)
  [[1]]
  [1] "a"
  
  [[2]]
  [1] "b"
  
  [[3]]
  [1] "c"
  
  > mshow(y)
  [[1]]
  [1] "a"
  
  [[2]]
  [1] "b"
  
  [[3]]
  [1] "c"
  
  > 
  > cat("mprintf():\n")
  mprintf():
  > printf("x=%d\n", 1:3)
  x=1
  x=2
  x=3
  > mprintf("x=%d\n", 1:3)
  x=1
  x=2
  x=3
  > 
  > cat("mout():\n")
  mout():
  > writeLines(x)
  a
  b
  c
  d
  e
  f
  g
  h
  > mout(writeLines(x))
  a
  b
  c
  d
  e
  f
  g
  h
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Tests related to closure
  > # - - - - - - - - - - - -- - - - - - - - - - - - - - - - - -
  > mfoo <- function(a=1) {
  +   mprintf("a=%s\n", a)
  + }
  > 
  > mbar <- function(...) {
  +   mfoo(...)
  + }
  > 
  > a <- 2
  > mfoo(a)
  a=2
  > mfoo(3)
  a=3
  > 
  > mbar(a)
  a=2
  > mbar(3)
  a=3
  > 
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Assert that "console" messages can be captured/sunk
  > # via stderr but not stdout
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > res <- captureOutput({ mcat("Hello") })
  Hello
  > str(res)
   chr(0) 
  > stopifnot(length(res) == 0L)
  > 
  > withSink({ mcat("Hello") }, file="foo.txt", type="message")
  > res <- readLines("foo.txt")
  > str(res)
   chr "Hello"
  > stopifnot(length(res) > 0L)
  > 
  > proc.time()
     user  system elapsed 
     0.31    0.10    0.40 
Running the tests in 'tests/parseRepos.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > message("CRAN:")
  CRAN:
  > str(as.list(parseRepos("CRAN")))
  List of 1
   $ CRAN: chr "https://cran.r-project.org"
  Warning message:
  In parseRepos("CRAN") :
    Had to fall back to a set of predefined repositories (please make sure to set your package repositories properly, cf. ?setRepositories): CRAN: '@CRAN@' -> 'https://cran.r-project.org'
  > 
  > message("braju.com:")
  braju.com:
  > str(as.list(parseRepos("braju.com")))
  List of 1
   $ braju.com: chr "https://braju.com/R"
  > 
  > message("CRAN + braju.com:")
  CRAN + braju.com:
  > str(as.list(parseRepos(c("CRAN", "braju.com"))))
  List of 2
   $ CRAN     : chr "https://cran.r-project.org"
   $ braju.com: chr "https://braju.com/R"
  Warning message:
  In parseRepos(c("CRAN", "braju.com")) :
    Had to fall back to a set of predefined repositories (please make sure to set your package repositories properly, cf. ?setRepositories): CRAN: '@CRAN@' -> 'https://cran.r-project.org'
  > 
  > message("braju.com + CRAN:")
  braju.com + CRAN:
  > str(as.list(parseRepos(c("braju.com", "CRAN"))))
  List of 2
   $ braju.com: chr "https://braju.com/R"
   $ CRAN     : chr "https://cran.r-project.org"
  Warning message:
  In parseRepos(c("braju.com", "CRAN")) :
    Had to fall back to a set of predefined repositories (please make sure to set your package repositories properly, cf. ?setRepositories): CRAN: '@CRAN@' -> 'https://cran.r-project.org'
  > 
  > message("All CRAN related repositories:")
  All CRAN related repositories:
  > str(as.list(parseRepos("[[CRAN]]")))
  List of 3
   $ CRAN     : chr "https://cran.r-project.org"
   $ CRANextra: chr "https://www.stats.ox.ac.uk/pub/RWin"
   $ CRAN     : chr "@CRAN@"
  Warning message:
  In parseRepos("[[CRAN]]") :
    Had to fall back to a set of predefined repositories (please make sure to set your package repositories properly, cf. ?setRepositories): CRAN: '@CRAN@' -> 'https://cran.r-project.org'
  > 
  > message("All BioC related repositories:")
  All BioC related repositories:
  > str(as.list(parseRepos("[[BioC]]")))
  List of 3
   $ BioCsoft: chr "https://bioconductor.org/packages/3.19/bioc"
   $ BioCann : chr "https://bioconductor.org/packages/3.19/data/annotation"
   $ BioCexp : chr "https://bioconductor.org/packages/3.19/data/experiment"
  > 
  > message("braju.com + all CRAN related repositories:")
  braju.com + all CRAN related repositories:
  > str(as.list(parseRepos(c("braju.com", "[[CRAN]]"))))
  List of 4
   $ braju.com: chr "https://braju.com/R"
   $ CRAN     : chr "https://cran.r-project.org"
   $ CRANextra: chr "https://www.stats.ox.ac.uk/pub/RWin"
   $ CRAN     : chr "@CRAN@"
  Warning message:
  In parseRepos(c("braju.com", "[[CRAN]]")) :
    Had to fall back to a set of predefined repositories (please make sure to set your package repositories properly, cf. ?setRepositories): CRAN: '@CRAN@' -> 'https://cran.r-project.org'
  > 
  > message("All CRAN related repositories + braju.com:")
  All CRAN related repositories + braju.com:
  > str(as.list(parseRepos(c("[[CRAN]]", "braju.com"))))
  List of 4
   $ CRAN     : chr "https://cran.r-project.org"
   $ CRANextra: chr "https://www.stats.ox.ac.uk/pub/RWin"
   $ CRAN     : chr "@CRAN@"
   $ braju.com: chr "https://braju.com/R"
  Warning message:
  In parseRepos(c("[[CRAN]]", "braju.com")) :
    Had to fall back to a set of predefined repositories (please make sure to set your package repositories properly, cf. ?setRepositories): CRAN: '@CRAN@' -> 'https://cran.r-project.org'
  > 
  > message("All CRAN related + BioC related repositories:")
  All CRAN related + BioC related repositories:
  > str(as.list(parseRepos(c("[[CRAN]]", "[[BioC]]"))))
  List of 6
   $ CRAN     : chr "https://cran.r-project.org"
   $ CRANextra: chr "https://www.stats.ox.ac.uk/pub/RWin"
   $ CRAN     : chr "@CRAN@"
   $ BioCsoft : chr "https://bioconductor.org/packages/3.19/bioc"
   $ BioCann  : chr "https://bioconductor.org/packages/3.19/data/annotation"
   $ BioCexp  : chr "https://bioconductor.org/packages/3.19/data/experiment"
  Warning message:
  In parseRepos(c("[[CRAN]]", "[[BioC]]")) :
    Had to fall back to a set of predefined repositories (please make sure to set your package repositories properly, cf. ?setRepositories): CRAN: '@CRAN@' -> 'https://cran.r-project.org'
  > 
  > message("All BioC related + CRAN related repositories:")
  All BioC related + CRAN related repositories:
  > str(as.list(parseRepos(c("[[BioC]]", "[[CRAN]]"))))
  List of 6
   $ BioCsoft : chr "https://bioconductor.org/packages/3.19/bioc"
   $ BioCann  : chr "https://bioconductor.org/packages/3.19/data/annotation"
   $ BioCexp  : chr "https://bioconductor.org/packages/3.19/data/experiment"
   $ CRAN     : chr "https://cran.r-project.org"
   $ CRANextra: chr "https://www.stats.ox.ac.uk/pub/RWin"
   $ CRAN     : chr "@CRAN@"
  Warning message:
  In parseRepos(c("[[BioC]]", "[[CRAN]]")) :
    Had to fall back to a set of predefined repositories (please make sure to set your package repositories properly, cf. ?setRepositories): CRAN: '@CRAN@' -> 'https://cran.r-project.org'
  > 
  > message("Mainstream (CRAN and BioC related) repositories (only):")
  Mainstream (CRAN and BioC related) repositories (only):
  > str(as.list(parseRepos("[[mainstream]]")))
  List of 6
   $ CRAN     : chr "https://cran.r-project.org"
   $ CRANextra: chr "https://www.stats.ox.ac.uk/pub/RWin"
   $ CRAN     : chr "@CRAN@"
   $ BioCsoft : chr "https://bioconductor.org/packages/3.19/bioc"
   $ BioCann  : chr "https://bioconductor.org/packages/3.19/data/annotation"
   $ BioCexp  : chr "https://bioconductor.org/packages/3.19/data/experiment"
  Warning message:
  In parseRepos("[[mainstream]]") :
    Had to fall back to a set of predefined repositories (please make sure to set your package repositories properly, cf. ?setRepositories): CRAN: '@CRAN@' -> 'https://cran.r-project.org'
  > 
  > message("An explicit repository URL:")
  An explicit repository URL:
  > str(as.list(parseRepos("http://r-forge.r-project.org")))
  List of 1
   $ : chr "http://r-forge.r-project.org"
  > 
  > message("An explicit repository URL + mainstream:")
  An explicit repository URL + mainstream:
  > str(as.list(parseRepos(c("http://r-forge.r-project.org", "[[mainstream]]"))))
  List of 7
   $          : chr "http://r-forge.r-project.org"
   $ CRAN     : chr "https://cran.r-project.org"
   $ CRANextra: chr "https://www.stats.ox.ac.uk/pub/RWin"
   $ CRAN     : chr "@CRAN@"
   $ BioCsoft : chr "https://bioconductor.org/packages/3.19/bioc"
   $ BioCann  : chr "https://bioconductor.org/packages/3.19/data/annotation"
   $ BioCexp  : chr "https://bioconductor.org/packages/3.19/data/experiment"
  Warning message:
  In parseRepos(c("http://r-forge.r-project.org", "[[mainstream]]")) :
    Had to fall back to a set of predefined repositories (please make sure to set your package repositories properly, cf. ?setRepositories): CRAN: '@CRAN@' -> 'https://cran.r-project.org'
  > 
  > message("Repositories according to option 'repos':")
  Repositories according to option 'repos':
  > str(as.list(parseRepos("[[current]]")))
  List of 1
   $ CRAN: chr "https://cran.r-project.org"
  Warning message:
  In parseRepos("[[current]]") :
    Had to fall back to a set of predefined repositories (please make sure to set your package repositories properly, cf. ?setRepositories): CRAN: '@CRAN@' -> 'https://cran.r-project.org'
  > 
  > message("All repositories known to this system:")
  All repositories known to this system:
  > str(as.list(parseRepos("[[all]]")))
  List of 9
   $ CRAN      : chr "https://cran.r-project.org"
   $ BioCsoft  : chr "https://bioconductor.org/packages/3.19/bioc"
   $ BioCann   : chr "https://bioconductor.org/packages/3.19/data/annotation"
   $ BioCexp   : chr "https://bioconductor.org/packages/3.19/data/experiment"
   $ CRANextra : chr "https://www.stats.ox.ac.uk/pub/RWin"
   $ R-Forge   : chr "https://R-Forge.R-project.org"
   $ rforge.net: chr "https://www.rforge.net"
   $ braju.com : chr "https://braju.com/R"
   $ CRAN      : chr "@CRAN@"
  Warning message:
  In parseRepos("[[all]]") :
    Had to fall back to a set of predefined repositories (please make sure to set your package repositories properly, cf. ?setRepositories): CRAN: '@CRAN@' -> 'https://cran.r-project.org'
  > 
  > proc.time()
     user  system elapsed 
     0.31    0.10    0.35 
Running the tests in 'tests/queryRCmdCheck.R' failed.
Complete output:
  > 
  > # Get the 'R CMD check' status, if any
  > status <- R.utils::queryRCmdCheck()
  > print(status)
  [1] "checkingTests"
  attr(,"evidences")
  attr(,"evidences")$R_CMD_CHECK
  [1] FALSE
  
  attr(,"evidences")$vanilla
  [1] TRUE
  
  attr(,"evidences")$pwd
  [1] TRUE
  
  attr(,"evidences")$examples
  [1] FALSE
  
  > 
  > if (status != "notRunning") {
  +   cat("The current R session was launched by R CMD check. Status:", status, "\n")
  + } else {
  +   cat("The current R session was not launched by R CMD check.\n")
  + }
  The current R session was launched by R CMD check. Status: checkingTests 
  > 
  > # Display how R was launched
  > print(base::commandArgs())
  [1] "D:\\RCompile\\recent\\R/bin/x64/Rterm.exe"
  [2] "-f"                                       
  [3] "queryRCmdCheck.R"                         
  [4] "--restore"                                
  [5] "--save"                                   
  [6] "--vanilla"                                
  > 
  > # Display loaded packages etc.
  > print(search())
  [1] ".GlobalEnv"        "package:stats"     "package:graphics" 
  [4] "package:grDevices" "package:utils"     "package:datasets" 
  [7] "package:methods"   "Autoloads"         "package:base"     
  > 
  > # Display current working directory
  > print(getwd())
  [1] "d:/Rcompile/CRANpkg/local/4.4/R.utils.Rcheck/tests"
  > 
  > proc.time()
     user  system elapsed 
     0.23    0.09    0.26 
Running the tests in 'tests/readWindowsShortcut.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > 
  > pathname <- system.file("data-ex/HISTORY.LNK", package="R.utils")
  > lnk <- readWindowsShortcut(pathname, verbose=TRUE)
  File header read:
  $magic
  [1] 76
  
  $guid
   [1]   1  20   2   0   0   0   0   0 192   0   0   0   0   0   0  70
  
  $flags
  [1] 159
  
  $fileAttributes
  [1] 32
  
  $creationTime
  [1] 755506800
  
  $modificationTime
  [1] -1773539680
  
  $lastAccessTime
  [1] 755113120
  
  $fileLength
  [1] 606
  
  $iconNumber
  [1] 0
  
  $showWndValue
  [1] 1
  
  $hotKey
  [1] 0
  
  $unknown
  [1] 0 0
  
  bytesToRead=497
  File location info:
  $length
  [1] 127
  
  $firstOffset
  [1] 28
  
  $flags
   availableOnLocalVolume availableOnNetworkShare 
                     TRUE                   FALSE 
  
  $offsetLocalVolumeInfo
  [1] 28
  
  $offsetBasePathname
  [1] 56
  
  $offsetNetworkVolumeInfo
  [1] 0
  
  $offsetRemainingPathname
  [1] 126
  
  $.offset
  [1] 28
  
  availableOnLocalVolume...
  File location info / Local Volume Table:
  $typeOfVolume
  Fixed 
      3 
  
  $volumeSerialNumber
  [1] -2077904061
  
  $volumeLabel
  [1] "IBM_PRELOAD"
  
  basePathname='C:\Documents and Settings\hb\braju.com.R\R.utils\R.utils\inst\HISTORY'
  availableOnLocalVolume...done
  > 
  > # Print all information
  > print(lnk)
  $header
  $header$magic
  [1] 76
  
  $header$guid
   [1]   1  20   2   0   0   0   0   0 192   0   0   0   0   0   0  70
  
  $header$flags
       hasShellItemIdList pointsToFileOrDirectory          hasDescription 
                     TRUE                    TRUE                    TRUE 
          hasRelativePath     hasWorkingDirectory hasCommandLineArguments 
                     TRUE                    TRUE                   FALSE 
            hasCustomIcon         unicodedStrings 
                    FALSE                    TRUE 
  
  $header$fileAttributes
                 isReadOnly                  isHidden              isSystemFile 
                      FALSE                     FALSE                     FALSE 
              isVolumeLabel               isDirectory isModifiedSinceLastBackup 
                      FALSE                     FALSE                      TRUE 
                isEncrypted                  isNormal               isTemporary 
                      FALSE                     FALSE                     FALSE 
               isSparseFile       hasReparsePointData              isCompressed 
                      FALSE                     FALSE                     FALSE 
                  isOffline 
                      FALSE 
  
  $header$creationTime
  [1] 755506800
  
  $header$modificationTime
  [1] -1773539680
  
  $header$lastAccessTime
  [1] 755113120
  
  $header$fileLength
  [1] 606
  
  $header$iconNumber
  [1] 0
  
  $header$showWndValue
  SW_NORMAL 
          1 
  
  $header$hotKey
  [1] 0
  
  $header$unknown
  [1] 0 0
  
  
  $fileLocationInfo
  $fileLocationInfo$flags
   availableOnLocalVolume availableOnNetworkShare 
                     TRUE                   FALSE 
  
  $fileLocationInfo$localVolumeTable
  $fileLocationInfo$localVolumeTable$typeOfVolume
  Fixed 
      3 
  
  $fileLocationInfo$localVolumeTable$volumeSerialNumber
  [1] -2077904061
  
  $fileLocationInfo$localVolumeTable$volumeLabel
  [1] "IBM_PRELOAD"
  
  
  $fileLocationInfo$basePathname
  [1] "C:\\Documents and Settings\\hb\\braju.com.R\\R.utils\\R.utils\\inst\\HISTORY"
  
  $fileLocationInfo$remainingPathname
  [1] ""
  
  
  $description
  [1] "C:\\Documents and Settings\\hb\\braju.com.R\\R.utils\\R.utils\\inst\\HISTORY"
  
  $relativePath
  [1] "..\\HISTORY"
  
  $workingDirectory
  [1] "C:\\Documents and Settings\\hb\\braju.com.R\\R.utils\\R.utils\\inst"
  
  $relativePathname
  [1] "..\\HISTORY"
  
  $pathname
  [1] "C:\\Documents and Settings\\hb\\braju.com.R\\R.utils\\R.utils\\inst\\HISTORY"
  
  > 
  > # Get the relative path to the target file
  > history <- file.path(dirname(pathname), lnk$relativePath)
  > 
  > # Alternatively, everything in one call
  > history <- filePath(pathname, expandLinks="relative")
  > 
  > proc.time()
     user  system elapsed 
     0.32    0.06    0.46 
Running the tests in 'tests/seqToHumanReadable.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > ## Empty
  > s <- seqToHumanReadable(integer(0L))
  > print(s)
  [1] ""
  > stopifnot(s == "")
  > 
  > ## Single
  > s <- seqToHumanReadable(0L)
  > print(s)
  [1] "0"
  > stopifnot(s == "0")
  > 
  > ## Duplicates
  > s <- seqToHumanReadable(c(1:2, 1:2))
  > print(s)
  [1] "1, 2"
  > stopifnot(s == "1, 2")
  > 
  > ## Two
  > s <- seqToHumanReadable(1:2)
  > print(s)
  [1] "1, 2"
  > stopifnot(s == "1, 2")
  > 
  > ## Two
  > s <- seqToHumanReadable(c(1, 3))
  > print(s)
  [1] "1, 3"
  > stopifnot(s == "1, 3")
  > 
  > ## A few subsets
  > x <- c(1:3, 5:8, 15, 21:20, 25:26)
  > s <- seqToHumanReadable(x)
  > print(s)
  [1] "1-3, 5-8, 15, 20, 21, 25, 26"
  > stopifnot(s == "1-3, 5-8, 15, 20, 21, 25, 26")
  > 
  > ## Other delimiters
  > s <- seqToHumanReadable(x, delimiter=":", collapse="; ")
  > print(s)
  [1] "1:3; 5:8; 15; 20; 21; 25; 26"
  > stopifnot(s == "1:3; 5:8; 15; 20; 21; 25; 26")
  > 
  > ## Display 1:2 as 1-2
  > s <- seqToHumanReadable(x, tau=1L)
  > print(s)
  [1] "1-3, 5-8, 15, 20-21, 25-26"
  > stopifnot(s == "1-3, 5-8, 15, 20-21, 25-26")
  > 
  > ## Display 1:3 as 1, 2, 3
  > s <- seqToHumanReadable(x, tau=3L)
  > print(s)
  [1] "1, 2, 3, 5-8, 15, 20, 21, 25, 26"
  > stopifnot(s == "1, 2, 3, 5-8, 15, 20, 21, 25, 26")
  > 
  > proc.time()
     user  system elapsed 
     0.29    0.04    0.32 
Running the tests in 'tests/sourceDirectory.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > ## Create a test folder with R scripts
  > path <- file.path(tempdir(), "R.utils")
  > dir.create(path, recursive = TRUE, showWarnings = FALSE)
  > 
  > pathname <- file.path(path, "increment_x.R")
  > cat(file = pathname, "x <- x + 1L\n")
  > 
  > x <- 0L
  > 
  > source(pathname)
  > message("x = ", x)
  x = 1
  > stopifnot(x == 1L)
  > 
  > source(pathname)
  > message("x = ", x)
  x = 2
  > stopifnot(x == 2L)
  > 
  > for (kk in 1:2) {
  +   sourceTo(pathname, modifiedOnly = TRUE)
  +   message("x = ", x)
  +   stopifnot(x == 3L)
  + }
  x = 3
  x = 3
  > 
  > Sys.sleep(1)
  > touchFile(pathname)
  > 
  > for (kk in 1:2) {
  +   sourceTo(pathname, modifiedOnly = TRUE)
  +   message("x = ", x)
  +   stopifnot(x == 4L)
  + }
  x = 4
  x = 4
  > 
  > sourceTo(pathname, modifiedOnly = FALSE)
  > message("x = ", x)
  x = 5
  > stopifnot(x == 5L)
  > 
  > for (kk in 1:2) {
  +   sourceDirectory(path, modifiedOnly = TRUE)
  +   message("x = ", x)
  +   stopifnot(x == 5L)
  + }
  x = 5
  x = 5
  > 
  > sourceDirectory(path, modifiedOnly = FALSE)
  > message("x = ", x)
  x = 6
  > stopifnot(x == 6L)
  > 
  > sourceDirectory(path, modifiedOnly = TRUE)
  > message("x = ", x)
  x = 6
  > stopifnot(x == 6L)
  > 
  > Sys.sleep(1)
  > touchFile(pathname)
  > 
  > for (kk in 1:2) {
  +   sourceDirectory(path, modifiedOnly = TRUE)
  +   message("x = ", x)
  +   stopifnot(x == 7L)
  + }
  x = 7
  x = 7
  > 
  > 
  > ## Cleanup
  > #unlink(path, recursive = TRUE)
  > 
  > proc.time()
     user  system elapsed 
     0.37    0.10    2.54 
Running the tests in 'tests/subplots.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > local({
  +   dev.new()
  +   on.exit(dev.off())
  +   subplots(4)
  +   for (kk in 1:4) plot(kk, main=kk)
  + })
  > 
  > 
  > local({
  +   dev.new()
  +   on.exit(dev.off())
  +   subplots(1:4)
  +   for (kk in 1:4) plot(kk, main=kk)
  + })
  dev.new(): using pdf(file="Rplots1.pdf")
  > 
  > local({
  +   dev.new()
  +   on.exit(dev.off())
  +   subplots(4, nrow=2)
  +   for (kk in 1:4) plot(kk, main=kk)
  + })
  dev.new(): using pdf(file="Rplots2.pdf")
  > 
  > local({
  +   dev.new()
  +   on.exit(dev.off())
  +   subplots(nrow=2, ncol=4)
  +   for (kk in 1:4) plot(kk, main=kk)
  + })
  dev.new(): using pdf(file="Rplots3.pdf")
  > 
  > proc.time()
     user  system elapsed 
     0.39    0.17    0.54 
Running the tests in 'tests/symlinks,dirs.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > verbose <- Arguments$getVerbose(TRUE, timestamp=TRUE)
  > 
  > # Run only tests if this platform/client supports symbolic file links
  > canSymlink <- tryCatch({
  +   res <- file.symlink(".", "test-symlink-dir")
  +   if (isDirectory("test-symlink-dir")) removeDirectory("test-symlink-dir")
  +   res
  + }, error = function(ex) FALSE)
  Warning message:
  In file.symlink(".", "test-symlink-dir") :
    cannot symlink '.' to 'test-symlink-dir', reason 'Dem Client fehlt ein erforderliches Recht'
  > 
  > 
  > # Test only if symlinks are supported
  > if (canSymlink) {
  + 
  + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  + # Local functions
  + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  + fileAccessT <- function(pathname, modes=c(exist=0, exec=1, write=2, read=4)) {
  +   sapply(modes, FUN=function(mode) fileAccess(pathname, mode=mode))
  + }
  + 
  + 
  + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  + # DIRECTORIES
  + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  + verbose && enter(verbose, "Symbolic links to directories")
  + 
  + # Create a target
  + path <- file.path(tempdir(), "foo")
  + mkdirs(path)
  + stopifnot(isDirectory(path))
  + 
  + # Create a symbolic link
  + pathL <- "link-to-tempdir"
  + file.symlink(path, pathL)
  + stopifnot(isDirectory(pathL))
  + 
  + # File information (directly and via link)
  + fi <- file.info(path)
  + fiL <- file.info2(pathL)
  + stopifnot(all.equal(fiL, fi, check.attributes=FALSE))
  + 
  + # Add a file (via link)
  + pathnameL <- file.path(pathL, "target2.txt")
  + cat("Hello", file=pathnameL)
  + 
  + # Assert that it exists (via direct pathname)
  + pathname <- file.path(path, "target2.txt")
  + stopifnot(isFile(pathname))
  + 
  + # Remove file (via direct pathname)
  + file.remove(pathname)
  + stopifnot(!isFile(pathname))
  + stopifnot(!isFile(pathnameL))
  + 
  + verbose && enter(verbose, "Renaming")
  + pathL2 <- sprintf("%s-new", pathL)
  + renameFile(pathL, pathL2)
  + stopifnot(isDirectory(pathL2))
  + renameFile(pathL2, pathL)
  + stopifnot(isDirectory(pathL))
  + verbose && exit(verbose)
  + 
  + # File access
  + verbose && enter(verbose, "Testing file permissions & access information")
  + fa <- fileAccessT(path)
  + faL <- fileAccessT(pathL)
  + stopifnot(identical(faL, fa))
  + # Disable write permission on target
  + Sys.chmod(path, mode="0077")
  + fa <- fileAccessT(path)
  + faL <- fileAccessT(pathL)
  + stopifnot(identical(faL, fa))
  + # Reset
  + Sys.chmod(path, mode="0777")
  + verbose && exit(verbose)
  + 
  + # Removing & cleanup
  + verbose && enter(verbose, "Cleanup")
  + # (Neither file.remove() nor unlink() can remove symbolic directory links)
  + removeDirectory(pathL)
  + stopifnot(!isDirectory(pathL))
  + stopifnot(isDirectory(path))
  + removeDirectory(path)
  + stopifnot(!isDirectory(path))
  + verbose && exit(verbose)
  + 
  + verbose && exit(verbose)
  + 
  + } # if (canSymlink)
  > 
  > proc.time()
     user  system elapsed 
     0.23    0.14    0.35 
Running the tests in 'tests/tmpfile.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > ## Assert that auto delete works
  > ## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > 
  > ## Temporary files before
  > tfiles <- dir(path=tempdir(), full.names=TRUE)
  > 
  > ## Create temporary file on the fly without any references to it
  > bfr <- readLines(tmpfile("Hello world!\n"))
  > print(bfr)
  [1] "Hello world!"
  > 
  > ## Find new temporary file
  > tfile <- setdiff(dir(path=tempdir(), full.names=TRUE), tfiles)
  > print(tfile)
  [1] "D:\\temp\\RtmpUJsF1M/file164c87d0e3466"
  > stopifnot(file.exists(tfile))
  > 
  > ## The on-the-fly temporary file is removed
  > ## whenever the garbage collector runs
  > gc()
           used (Mb) gc trigger (Mb) max used (Mb)
  Ncells 343502 18.4     633894 33.9   633894 33.9
  Vcells 584838  4.5    8388608 64.0  2004060 15.3
  > stopifnot(!file.exists(tfile))
  > 
  > proc.time()
     user  system elapsed 
     0.29    0.06    0.34 
Running the tests in 'tests/toCamelCase.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > strings <- list(
  +   "",
  +   "hello world"   = c("helloWorld", "HelloWorld", "helloWorld", "HelloWorld"),
  +   "tcn start"     = c("tcnStart", "TcnStart", "tcnStart", "TcnStart"),
  +   "GEO Accession" = c("gEOAccession", "GEOAccession", "geoAccession", "GEOAccession")
  + )
  > 
  > for (s in names(strings)) {
  +   printf("Original: %s\n", sQuote(s))
  + 
  +   y <- toCamelCase(s)
  +   printf("Camel case: %s\n", sQuote(y))
  +   stopifnot(y == strings[[s]][1L])
  + 
  +   y <- toCamelCase(s, capitalize=TRUE)
  +   printf("Capitalized camel case: %s\n", sQuote(y))
  +   stopifnot(y == strings[[s]][2L])
  + 
  +   y <- toCamelCase(s, preserveSameCase=TRUE)
  +   printf("Capitalized camel case without same case preserved: %s\n", sQuote(y))
  +   stopifnot(y == strings[[s]][3L])
  + 
  +   y <- toCamelCase(s, capitalize=TRUE, preserveSameCase=TRUE)
  +   printf("Capitalized camel case with same case preserved: %s\n", sQuote(y))
  +   stopifnot(y == strings[[s]][4L])
  + 
  +   cat("\n")
  + }
  Original: ''
  Camel case: ''
  Capitalized camel case: ''
  Capitalized camel case without same case preserved: ''
  Capitalized camel case with same case preserved: ''
  
  Original: 'hello world'
  Camel case: 'helloWorld'
  Capitalized camel case: 'HelloWorld'
  Capitalized camel case without same case preserved: 'helloWorld'
  Capitalized camel case with same case preserved: 'HelloWorld'
  
  Original: 'tcn start'
  Camel case: 'tcnStart'
  Capitalized camel case: 'TcnStart'
  Capitalized camel case without same case preserved: 'tcnStart'
  Capitalized camel case with same case preserved: 'TcnStart'
  
  Original: 'GEO Accession'
  Camel case: 'gEOAccession'
  Capitalized camel case: 'GEOAccession'
  Capitalized camel case without same case preserved: 'geoAccession'
  Capitalized camel case with same case preserved: 'GEOAccession'
  
  > 
  > # Vectorized
  > s <- names(strings)
  > y <- toCamelCase(s)
  > stopifnot(length(y) == length(s))
  > y0 <- sapply(strings, FUN=function(s) s[1L])
  > stopifnot(all(y == y0))
  > 
  > # Empty vector
  > y <- toCamelCase(character(0L))
  > stopifnot(length(y) == 0L)
  > y <- toCamelCase(NULL)
  > stopifnot(length(y) == 0L)
  > 
  > # Missing values
  > for (preserveSameCase in c(FALSE, TRUE)) {
  +   y <- toCamelCase(NA_character_, preserveSameCase=preserveSameCase)
  +   stopifnot(is.na(y))
  + 
  +   y <- toCamelCase(c(NA_character_, NA_character_), preserveSameCase=preserveSameCase)
  +   stopifnot(all(is.na(y)))
  + 
  +   y <- toCamelCase(c(NA_character_, "hello world", NA_character_), preserveSameCase=preserveSameCase)
  +   stopifnot(identical(y, c(NA_character_, "helloWorld", NA_character_)))
  + }
  > 
  > 
  > proc.time()
     user  system elapsed 
     0.32    0.12    0.37 
Running the tests in 'tests/use.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > # Use with one package
  > use("tools", how="load")
  > 
  > # Use with one package
  > use("tools")
  > 
  > # Use with multiple packages
  > use(c("tools", "graphics"))
  > use("tools, graphics")
  > use(c("tools, graphics", "grDevices"))
  > 
  > # Use with version constraint
  > use("tools", version="(>= 2.5.0)")
  > use("tools (>= 2.5.0)")
  > 
  > # Use with multiple packages and version constraints
  > use(c("tools", "graphics"), version=c("(>= 2.5.0)", "(>= 2.5.0)"))
  > use("tools, graphics", version="(>= 2.5.0), (>= 2.5.0)")
  > use("tools (>= 2.5.0), graphics (>= 2.5.0)")
  > 
  > # Exception should be visible
  > tryCatch({
  +   use("NonExistingPackage", install=FALSE)
  + }, error = function(ex) {
  +   print(ex)
  + })
  [2024-03-23 10:35:22.79196] Exception: Failed to attach package:NonExistingPackage
  
    at #06. use.default("NonExistingPackage", install = FALSE)
            - use.default() is in environment 'R.utils'
  
    at #05. use("NonExistingPackage", install = FALSE)
            - use() is in environment 'R.utils'
  
  > 
  > proc.time()
     user  system elapsed 
     0.39    0.10    0.48 
Running the tests in 'tests/withLocale.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Basic tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # The current set of locales
  > old <- Sys.getlocale("LC_ALL")
  > 
  > # Vector
  > cat("Original vector:\n")
  Original vector:
  > x <- c(letters[1:8], LETTERS[1:8])
  > print(x)
   [1] "a" "b" "c" "d" "e" "f" "g" "h" "A" "B" "C" "D" "E" "F" "G" "H"
  > 
  > cat("Sorting with 'C' locale:\n")
  Sorting with 'C' locale:
  > y1 <- withLocale(sort(x), "LC_COLLATE", "C")
  > print(y1)
   [1] "A" "B" "C" "D" "E" "F" "G" "H" "a" "b" "c" "d" "e" "f" "g" "h"
  > 
  > cat("Sorting with an 'English' locale:\n")
  Sorting with an 'English' locale:
  > y2 <- withLocale(sort(x), "LC_COLLATE", c("en_US", "en_US.UTF8", "English_United States.1252"))
  > print(y2)
   [1] "a" "A" "b" "B" "c" "C" "d" "D" "e" "E" "f" "F" "g" "G" "h" "H"
  > 
  > # Sanity check
  > curr <- Sys.getlocale("LC_ALL")
  > if (!identical(curr, old)) {
  +   throw("Locale settings have changed: ", old, " != ", curr)
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Nested calls
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > cat("Sorting with 'C' locale (nested inside a English one):\n")
  Sorting with 'C' locale (nested inside a English one):
  > y3 <- withLocale({
  +   withLocale({
  +     sort(x)
  +   }, "LC_COLLATE", "C")
  + }, "LC_COLLATE", c("en_US", "en_US.UTF8", "English_United States.1252"))
  > print(y3)
   [1] "A" "B" "C" "D" "E" "F" "G" "H" "a" "b" "c" "d" "e" "f" "g" "h"
  > stopifnot(identical(y3, y1))
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Visibility
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > res <- withVisible({
  +   withLocale({ 1 }, "LC_COLLATE", "C")
  + })
  > str(res)
  List of 2
   $ value  : num 1
   $ visible: logi TRUE
  > stopifnot(all.equal(res$value, 1))
  > stopifnot(res$visible)
  > 
  > x <- 0
  > res <- withVisible({
  +   withLocale({ x <- 1 }, "LC_COLLATE", "C")
  + })
  > str(res)
  List of 2
   $ value  : num 1
   $ visible: logi FALSE
  > stopifnot(all.equal(res$value, 1))
  > stopifnot(!res$visible)
  > stopifnot(all.equal(x, 1))
  > 
  > proc.time()
     user  system elapsed 
     0.32    0.07    0.34 
Running the tests in 'tests/withOptions.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > oopts <- options()
  > 
  > digits <- getOption("digits")
  > print(pi)
  [1] 3.141593
  > 
  > # Same, i.e. using default
  > withOptions({
  +   print(pi)
  +   stopifnot(getOption("digits") == digits)
  + })
  [1] 3.141593
  > 
  > # Printing with two digits
  > withOptions({
  +   print(pi)
  +   stopifnot(getOption("digits") == 2)
  + }, digits=2)
  [1] 3.1
  > 
  > # Printing with two digits then with three more
  > withOptions({
  +   print(pi)
  +   withOptions({
  +     print(pi)
  +     stopifnot(getOption("digits") == 5)
  +   }, digits=getOption("digits")+3)
  +   stopifnot(getOption("digits")+3 == 5)
  + }, digits=2)
  [1] 3.1
  [1] 3.1416
  > 
  > 
  > # Still printing with the default
  > print(pi)
  [1] 3.141593
  > stopifnot(getOption("digits") == digits)
  > 
  > # Reset also options set inside call
  > options(dummy=NULL)
  > withOptions({
  +   print(pi)
  +   options(digits=1L)
  +   print(pi)
  +   stopifnot(getOption("digits") == 1L)
  +   options(dummy="Hello")
  +   print(getOption("dummy"))
  + })
  [1] 3.141593
  [1] 3
  [1] "Hello"
  > stopifnot(is.null(getOption("dummy")))
  > 
  > # Any modified or added option is undone
  > stopifnot(all.equal(options(), oopts))
  > 
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Visibility
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > digits <- getOption("digits")+1L
  > res <- withVisible({
  +   withOptions({ 1 }, digits=digits)
  + })
  > str(res)
  List of 2
   $ value  : num 1
   $ visible: logi TRUE
  > stopifnot(all.equal(res$value, 1))
  > stopifnot(res$visible)
  > 
  > x <- 0
  > res <- withVisible({
  +   withOptions({ x <- 1 }, digits=digits)
  + })
  > str(res)
  List of 2
   $ value  : num 1
   $ visible: logi FALSE
  > stopifnot(all.equal(res$value, 1))
  > stopifnot(!res$visible)
  > stopifnot(all.equal(x, 1))
  > 
  > proc.time()
     user  system elapsed 
     0.25    0.09    0.32 
Running the tests in 'tests/withRepos.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > # Set new default repositories for this test
  > orepos <- options(repos=c(
  +   CRAN="http://cran.r-project.org",
  +   EXAMPLE="http://example.org"
  + ))
  > 
  > message("Current repositories:")
  Current repositories:
  > str(as.list(getOption("repos")))
  List of 2
   $ CRAN   : chr "http://cran.r-project.org"
   $ EXAMPLE: chr "http://example.org"
  > 
  > message("All current repositories:")
  All current repositories:
  > withRepos({
  +   str(as.list(getOption("repos")))
  + })
  List of 5
   $ CRAN     : chr "http://cran.r-project.org"
   $ CRANextra: chr "https://www.stats.ox.ac.uk/pub/RWin"
   $ BioCsoft : chr "https://bioconductor.org/packages/3.19/bioc"
   $ BioCann  : chr "https://bioconductor.org/packages/3.19/data/annotation"
   $ BioCexp  : chr "https://bioconductor.org/packages/3.19/data/experiment"
  > 
  > message("All current repositories (explicit):")
  All current repositories (explicit):
  > withRepos({
  +   str(as.list(getOption("repos")))
  + }, repos="[[current]]")
  List of 2
   $ CRAN   : chr "http://cran.r-project.org"
   $ EXAMPLE: chr "http://example.org"
  > 
  > message("CRAN (only):")
  CRAN (only):
  > withRepos({
  +   str(as.list(getOption("repos")))
  + }, repos="CRAN")
  List of 1
   $ CRAN: chr "http://cran.r-project.org"
  > 
  > 
  > message("braju.com (only):")
  braju.com (only):
  > withRepos({
  +   str(as.list(getOption("repos")))
  + }, repos="braju.com")
  List of 1
   $ braju.com: chr "https://braju.com/R"
  > 
  > message("CRAN and braju.com (only):")
  CRAN and braju.com (only):
  > withRepos({
  +   str(as.list(getOption("repos")))
  + }, repos=c("CRAN", "braju.com"))
  List of 2
   $ CRAN     : chr "http://cran.r-project.org"
   $ braju.com: chr "https://braju.com/R"
  > 
  > message("braju.com and CRAN (only):")
  braju.com and CRAN (only):
  > withRepos({
  +   str(as.list(getOption("repos")))
  + }, repos=c("braju.com", "CRAN"))
  List of 2
   $ braju.com: chr "https://braju.com/R"
   $ CRAN     : chr "http://cran.r-project.org"
  > 
  > 
  > message("All CRAN replated repositories (only):")
  All CRAN replated repositories (only):
  > withRepos({
  +   str(as.list(getOption("repos")))
  + }, repos="[[CRAN]]")
  List of 2
   $ CRAN     : chr "http://cran.r-project.org"
   $ CRANextra: chr "https://www.stats.ox.ac.uk/pub/RWin"
  > 
  > message("Mainstream (CRAN and BioC related) repositories (only):")
  Mainstream (CRAN and BioC related) repositories (only):
  > withRepos({
  +   str(as.list(getOption("repos")))
  + }, repos="[[mainstream]]")
  List of 5
   $ CRAN     : chr "http://cran.r-project.org"
   $ CRANextra: chr "https://www.stats.ox.ac.uk/pub/RWin"
   $ BioCsoft : chr "https://bioconductor.org/packages/3.19/bioc"
   $ BioCann  : chr "https://bioconductor.org/packages/3.19/data/annotation"
   $ BioCexp  : chr "https://bioconductor.org/packages/3.19/data/experiment"
  > 
  > message("braju.com and mainstream (only):")
  braju.com and mainstream (only):
  > withRepos({
  +   str(as.list(getOption("repos")))
  + }, repos="[[braju.com]]")
  List of 6
   $ braju.com: chr "https://braju.com/R"
   $ CRAN     : chr "http://cran.r-project.org"
   $ CRANextra: chr "https://www.stats.ox.ac.uk/pub/RWin"
   $ BioCsoft : chr "https://bioconductor.org/packages/3.19/bioc"
   $ BioCann  : chr "https://bioconductor.org/packages/3.19/data/annotation"
   $ BioCexp  : chr "https://bioconductor.org/packages/3.19/data/experiment"
  > 
  > message("R-Forge and mainstream (only):")
  R-Forge and mainstream (only):
  > withRepos({
  +   str(as.list(getOption("repos")))
  + }, repos="[[R-Forge]]")
  List of 6
   $ R-Forge  : chr "https://R-Forge.R-project.org"
   $ CRAN     : chr "http://cran.r-project.org"
   $ CRANextra: chr "https://www.stats.ox.ac.uk/pub/RWin"
   $ BioCsoft : chr "https://bioconductor.org/packages/3.19/bioc"
   $ BioCann  : chr "https://bioconductor.org/packages/3.19/data/annotation"
   $ BioCexp  : chr "https://bioconductor.org/packages/3.19/data/experiment"
  > 
  > message("An explicit repository URL:")
  An explicit repository URL:
  > withRepos({
  +   str(as.list(getOption("repos")))
  + }, repos="http://r-forge.r-project.org")
  List of 1
   $ : chr "http://r-forge.r-project.org"
  > 
  > message("An explicit repository URL + mainstream:")
  An explicit repository URL + mainstream:
  > withRepos({
  +   str(as.list(getOption("repos")))
  + }, repos=c("http://r-forge.r-project.org", "[[mainstream]]"))
  List of 6
   $          : chr "http://r-forge.r-project.org"
   $ CRAN     : chr "http://cran.r-project.org"
   $ CRANextra: chr "https://www.stats.ox.ac.uk/pub/RWin"
   $ BioCsoft : chr "https://bioconductor.org/packages/3.19/bioc"
   $ BioCann  : chr "https://bioconductor.org/packages/3.19/data/annotation"
   $ BioCexp  : chr "https://bioconductor.org/packages/3.19/data/experiment"
  > 
  > message("All known:")
  All known:
  > withRepos({
  +   str(as.list(getOption("repos")))
  + }, repos="[[all]]")
  List of 9
   $ CRAN      : chr "http://cran.r-project.org"
   $ BioCsoft  : chr "https://bioconductor.org/packages/3.19/bioc"
   $ BioCann   : chr "https://bioconductor.org/packages/3.19/data/annotation"
   $ BioCexp   : chr "https://bioconductor.org/packages/3.19/data/experiment"
   $ CRANextra : chr "https://www.stats.ox.ac.uk/pub/RWin"
   $ R-Forge   : chr "https://R-Forge.R-project.org"
   $ rforge.net: chr "https://www.rforge.net"
   $ braju.com : chr "https://braju.com/R"
   $ EXAMPLE   : chr "http://example.org"
  > 
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Visibility
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > res <- withVisible({
  +   withRepos({ 1 })
  + })
  > str(res)
  List of 2
   $ value  : num 1
   $ visible: logi TRUE
  > stopifnot(all.equal(res$value, 1))
  > stopifnot(res$visible)
  > 
  > x <- 0
  > res <- withVisible({
  +   withRepos({ x <- 1 })
  + })
  > str(res)
  List of 2
   $ value  : num 1
   $ visible: logi FALSE
  > stopifnot(all.equal(res$value, 1))
  > stopifnot(!res$visible)
  > stopifnot(all.equal(x, 1))
  > 
  > 
  > # Undo
  > options(orepos)
  > 
  > proc.time()
     user  system elapsed 
     0.40    0.04    0.43 
Running the tests in 'tests/withSink.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > mfile <- function(file, ...) {
  +   mprintf("\n%s:\n", file)
  +   mcat("-------------------------------------------------\n")
  +   mcat(readLines(pathname), sep="\n")
  +   mcat("-------------------------------------------------\n")
  + } # mfile()
  > 
  > 
  > # Display warnings as they occur
  > oopts <- options(warn=1L)
  > 
  > cons0 <- showConnections()
  > 
  > # Divert standard output
  > pathname <- tempfile(fileext=".output.txt")
  > mprint(pathname)
  [1] "D:\\temp\\Rtmp6BOL0W\\fileba7c330b12c4.output.txt"
  > res <- withSink(file=pathname, {
  +   print(letters)
  +   NULL
  + })
  > mfile(pathname)
  
  D:\temp\Rtmp6BOL0W\fileba7c330b12c4.output.txt:
  -------------------------------------------------
   [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s"
  [20] "t" "u" "v" "w" "x" "y" "z"
  -------------------------------------------------
  > mprint(warnings())
  > 
  > 
  > # Divert standard error/messages
  > pathname <- tempfile(fileext=".message.txt")
  > mprint(pathname)
  [1] "D:\\temp\\Rtmp6BOL0W\\fileba7c48ce2108.message.txt"
  > res <- withSink(file=pathname, type="message", {
  +   mprint(letters)
  +   NULL
  + })
  > mfile(pathname)
  
  D:\temp\Rtmp6BOL0W\fileba7c48ce2108.message.txt:
  -------------------------------------------------
   [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s"
  [20] "t" "u" "v" "w" "x" "y" "z"
  -------------------------------------------------
  > mprint(warnings())
  > 
  > 
  > # Divert standard output (and make sure to close any other sinks opened)
  > pathname <- tempfile(fileext=".output2.txt")
  > mprint(pathname)
  [1] "D:\\temp\\Rtmp6BOL0W\\fileba7c6da83af3.output2.txt"
  > res <- withSink(file=pathname, {
  +   print(letters)
  +   pathnameT <- tempfile(fileext=".output3.txt")
  +   sink(pathnameT, type="output")
  +   print(LETTERS)
  +   mstr(1:10)
  + }, append=TRUE)
   int [1:10] 1 2 3 4 5 6 7 8 9 10
  Warning in withSink(file = pathname, { :
    Closing unclosed sink #2 of type 'output' that was opened during evaluation.
  > mfile(pathname)
  
  D:\temp\Rtmp6BOL0W\fileba7c6da83af3.output2.txt:
  -------------------------------------------------
   [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s"
  [20] "t" "u" "v" "w" "x" "y" "z"
  -------------------------------------------------
  > mprint(warnings())
  > 
  > 
  > # Assert that all connections opened were closed
  > cons1 <- showConnections()
  > mprint(cons0)
       description class mode text isopen can read can write
  > mprint(cons1)
       description class mode text isopen can read can write
  > stopifnot(all.equal(cons1, cons0))
  > 
  > # Reset how warnings are displayed
  > options(oopts)
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Visibility
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > pathname <- tempfile(fileext=".output.txt")
  > res <- withVisible({
  +   withSink({ print(1); 1 }, file=pathname)
  + })
  > str(res)
  List of 2
   $ value  : num 1
   $ visible: logi TRUE
  > stopifnot(all.equal(res$value, 1))
  > stopifnot(res$visible)
  > 
  > x <- 0
  > res <- withVisible({
  +   withSink({ print(1); x <- 1 }, file=pathname)
  + })
  > str(res)
  List of 2
   $ value  : num 1
   $ visible: logi FALSE
  > stopifnot(all.equal(res$value, 1))
  > stopifnot(!res$visible)
  > stopifnot(all.equal(x, 1))
  > 
  > proc.time()
     user  system elapsed 
     4.81   42.81   48.57 
Running the tests in 'tests/wrap.array.R' failed.
Complete output:
  > library("R.utils")
  Loading required package: R.oo
  Loading required package: R.methodsS3
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.
  
  Attaching package: 'R.oo'
  
  The following object is masked from 'package:R.methodsS3':
  
      throw
  
  The following objects are masked from 'package:methods':
  
      getClasses, getMethods
  
  The following objects are masked from 'package:base':
  
      attach, detach, load, save
  
  R.utils v2.12.3 (2023-11-18 01:00:02 UTC) successfully loaded. See ?R.utils for help.
  
  Attaching package: 'R.utils'
  
  The following object is masked from 'package:utils':
  
      timestamp
  
  The following objects are masked from 'package:base':
  
      cat, commandArgs, getOption, isOpen, nullfile, parse, use, warnings
  
  > 
  > 
  > 
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # A matrix
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > cat("\nWrap a matrix 'y' to a vector and back again:\n")
  
  Wrap a matrix 'y' to a vector and back again:
  > x <- matrix(1:8, nrow=2, dimnames=list(letters[1:2], 1:4))
  > y <- wrap(x)
  > z <- unwrap(y)
  > print(z)
    1 2 3 4
  a 1 3 5 7
  b 2 4 6 8
  > stopifnot(identical(z,x))
  > 
  > # Drop dimensions, iff applicable
  > z <- unwrap(y, drop=TRUE)
  > print(z)
    1 2 3 4
  a 1 3 5 7
  b 2 4 6 8
  > 
  > 
  > # Argument 'split' can also be a list of functions
  > split <- list(function(names, ...) strsplit(names, split="[.]", ...))
  > z2 <- unwrap(y, split=split)
  > print(z2)
    1 2 3 4
  a 1 3 5 7
  b 2 4 6 8
  > stopifnot(identical(z2, z))
  > 
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # A matrix and a data frame
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > x3 <- matrix(1:27, nrow=3L, ncol=9L)
  > rownames(x3) <- LETTERS[1:3]
  > colnames(x3) <- letters[1:9]
  > x3b <- as.data.frame(x3, stringsAsFactors=FALSE)
  > 
  > y3 <- wrap(x3)
  > print(y3)
  A.a B.a C.a A.b B.b C.b A.c B.c C.c A.d B.d C.d A.e B.e C.e A.f B.f C.f A.g B.g 
    1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20 
  C.g A.h B.h C.h A.i B.i C.i 
   21  22  23  24  25  26  27 
  > 
  > y3b <- wrap(x3b)
  > print(y3b)
  A.a B.a C.a A.b B.b C.b A.c B.c C.c A.d B.d C.d A.e B.e C.e A.f B.f C.f A.g B.g 
    1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20 
  C.g A.h B.h C.h A.i B.i C.i 
   21  22  23  24  25  26  27 
  > 
  > stopifnot(identical(y3b,y3))
  > 
  > z3 <- unwrap(y3)
  > stopifnot(identical(z3,x3))
  > 
  > y3b <- as.data.frame(y3, stringsAsFactors=FALSE)
  > z3b <- unwrap(y3b)
  > stopifnot(identical(z3b,x3))
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # A 3x2x3 array
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > dim <- c(3,2,3)
  > ndim <- length(dim)
  > dimnames <- list()
  > for (kk in 1:ndim)
  +   dimnames[[kk]] <- sprintf("%s%d", letters[kk], 1:dim[kk])
  > x <- 1:prod(dim)
  > x <- array(x, dim=dim, dimnames=dimnames)
  > 
  > 
  > cat("Array 'x':\n")
  Array 'x':
  > print(x)
  , , c1
  
     b1 b2
  a1  1  4
  a2  2  5
  a3  3  6
  
  , , c2
  
     b1 b2
  a1  7 10
  a2  8 11
  a3  9 12
  
  , , c3
  
     b1 b2
  a1 13 16
  a2 14 17
  a3 15 18
  
  > 
  > 
  > cat("\nReshape 'x' to its identity:\n")
  
  Reshape 'x' to its identity:
  > y <- wrap(x, map=list(1, 2, 3))
  > print(y)
  , , c1
  
     b1 b2
  a1  1  4
  a2  2  5
  a3  3  6
  
  , , c2
  
     b1 b2
  a1  7 10
  a2  8 11
  a3  9 12
  
  , , c3
  
     b1 b2
  a1 13 16
  a2 14 17
  a3 15 18
  
  > # Assert correctness of reshaping
  > stopifnot(identical(y, x))
  > 
  > 
  > cat("\nReshape 'x' by swapping dimensions 2 and 3, i.e. aperm(x, perm=c(1,3,2)):\n")
  
  Reshape 'x' by swapping dimensions 2 and 3, i.e. aperm(x, perm=c(1,3,2)):
  > y <- wrap(x, map=list(1, 3, 2))
  > print(y)
  , , b1
  
     c1 c2 c3
  a1  1  7 13
  a2  2  8 14
  a3  3  9 15
  
  , , b2
  
     c1 c2 c3
  a1  4 10 16
  a2  5 11 17
  a3  6 12 18
  
  > # Assert correctness of reshaping
  > stopifnot(identical(y, aperm(x, perm=c(1,3,2))))
  > 
  > 
  > cat("\nWrap 'x' to a matrix 'y' by keeping dimension 1 and joining the others:\n")
  
  Wrap 'x' to a matrix 'y' by keeping dimension 1 and joining the others:
  > y <- wrap(x, map=list(1, NA))
  > print(y)
     b1.c1 b2.c1 b1.c2 b2.c2 b1.c3 b2.c3
  a1     1     4     7    10    13    16
  a2     2     5     8    11    14    17
  a3     3     6     9    12    15    18
  > # Assert correctness of reshaping
  > for (aa in dimnames(x)[[1]]) {
  +   for (bb in dimnames(x)[[2]]) {
  +     for (cc in dimnames(x)[[3]]) {
  +       tt <- paste(bb, cc, sep=".")
  +       stopifnot(identical(y[aa,tt], x[aa,bb,cc]))
  +     }
  +   }
  + }
  > 
  > 
  > cat("\nUnwrap matrix 'y' back to array 'x':\n")
  
  Unwrap matrix 'y' back to array 'x':
  > z <- unwrap(y)
  > print(z)
  , , c1
  
     b1 b2
  a1  1  4
  a2  2  5
  a3  3  6
  
  , , c2
  
     b1 b2
  a1  7 10
  a2  8 11
  a3  9 12
  
  , , c3
  
     b1 b2
  a1 13 16
  a2 14 17
  a3 15 18
  
  > stopifnot(identical(z,x))
  > 
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # An array with a random number of dimensions
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > cat("\nWrap and unwrap a randomly sized and shaped array 'x2':\n")
  
  Wrap and unwrap a randomly sized and shaped array 'x2':
  > maxdim <- 5
  > dim <- sample(1:maxdim, size=sample(2:maxdim, size=1))
  > ndim <- length(dim)
  > dimnames <- list()
  > for (kk in 1:ndim)
  +   dimnames[[kk]] <- sprintf("%s%d", letters[kk], 1:dim[kk])
  > x2 <- 1:prod(dim)
  > x2 <- array(x, dim=dim, dimnames=dimnames)
  > 
  > cat("\nArray 'x2':\n")
  
  Array 'x2':
  > print(x)
  , , c1
  
     b1 b2
  a1  1  4
  a2  2  5
  a3  3  6
  
  , , c2
  
     b1 b2
  a1  7 10
  a2  8 11
  a3  9 12
  
  , , c3
  
     b1 b2
  a1 13 16
  a2 14 17
  a3 15 18
  
  > 
  > # Number of dimensions of wrapped array
  > ndim2 <- sample(1:(ndim-1), size=1)
  > 
  > # Create a random map for joining dimensions
  > splits <- NULL
  > if (ndim > 2)
  +   splits <- sort(sample(2:(ndim-1), size=ndim2-1))
  > splits <- c(0, splits, ndim)
  > map <- list()
  > for (kk in 1:ndim2)
  +   map[[kk]] <- (splits[kk]+1):splits[kk+1]
  > 
  > cat("\nRandom 'map':\n")
  
  Random 'map':
  > print(map)
  [[1]]
  [1] 1 2
  
  > 
  > cat("\nArray 'y2':\n")
  
  Array 'y2':
  > y2 <- wrap(x2, map=map)
  > print(y2)
  a1.b1 a1.b2 
      1     2 
  > 
  > cat("\nArray 'x2':\n")
  
  Array 'x2':
  > z2 <- unwrap(y2)
  > print(z2)
     b1 b2
  a1  1  2
  > 
  > stopifnot(identical(z2,x2))
  > 
  > 
  > 
  > proc.time()
     user  system elapsed 
     0.26    0.15    0.36 
Running the tests in 'tests/zzz_finalizer_crash.R' failed.
Complete output:
  > # This script crashes in ~40s on R 2.15.3 patched and R 3.0.2 with
  > # R.oo (< 1.18.0).  It only does so when 'methods' is attached.  It
  > # does not crash on R 3.0.2 patched (2014-02-21 r65057) and beyond.
  > # It appears to not crash with 'R CMD check' on 2.15.3 but if run
  > # via 'Rscript' or similar. /HB 2014-02-22
  > library("methods")
  > library("R.methodsS3")
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  > loadNamespace("R.utils")
  <environment: namespace:R.utils>
  > 
  > # Remove all existing variables
  > rm(list=ls(all.names=TRUE))
  > gc()
           used (Mb) gc trigger (Mb) max used (Mb)
  Ncells 330060 17.7     633894 33.9   633894 33.9
  Vcells 558206  4.3    8388608 64.0  2004062 15.3
  > 
  > R.oo::setConstructorS3("Verbose2", function(con=stderr(), ...) {
  +   R.oo::extend(R.oo::Object(), "Verbose",
  +     .con = con
  +   )
  + })
  > 
  > print(sessionInfo())
  R Under development (unstable) (2024-03-22 r86169 ucrt)
  Platform: x86_64-w64-mingw32/x64
  Running under: Windows Server 2022 x64 (build 20348)
  
  Matrix products: default
  
  
  locale:
  [1] LC_COLLATE=C                 LC_CTYPE=German_Germany.utf8
  [3] LC_MONETARY=C                LC_NUMERIC=C                
  [5] LC_TIME=C                   
  
  time zone: Europe/Berlin
  tzcode source: internal
  
  attached base packages:
  [1] stats     graphics  grDevices utils     datasets  methods   base     
  
  other attached packages:
  [1] R.methodsS3_1.8.2
  
  loaded via a namespace (and not attached):
  [1] compiler_4.4.0 R.utils_2.12.3 R.oo_1.26.0   
  > message(Sys.time())
  2024-03-23 10:53:33.872303
  > local({
  +   Verbose2(file())
  +   gctorture(TRUE)
  +   unloadNamespace("R.utils")
  +   unloadNamespace("R.oo")
  +   NULL
  + })
  NULL
  Warning message:
  In for (n in loadedNamespaces()) { : closing unused connection 3 ()
  > gctorture(FALSE)
  > message(Sys.time())
  2024-03-23 10:53:37.279839
  > print(sessionInfo())
  R Under development (unstable) (2024-03-22 r86169 ucrt)
  Platform: x86_64-w64-mingw32/x64
  Running under: Windows Server 2022 x64 (build 20348)
  
  Matrix products: default
  
  
  locale:
  [1] LC_COLLATE=C                 LC_CTYPE=German_Germany.utf8
  [3] LC_MONETARY=C                LC_NUMERIC=C                
  [5] LC_TIME=C                   
  
  time zone: Europe/Berlin
  tzcode source: internal
  
  attached base packages:
  [1] stats     graphics  grDevices utils     datasets  methods   base     
  
  other attached packages:
  [1] R.methodsS3_1.8.2
  
  loaded via a namespace (and not attached):
  [1] compiler_4.4.0
  > 
  > proc.time()
     user  system elapsed 
     3.70    0.06    3.75