Running 'ASCII.R' [168s]
  Running 'BasicObject.R' [0s]
  Running 'Class.R' [162s]
  Running 'Exception.R' [167s]
  Running 'Interface.R' [0s]
  Running 'InternalErrorException.reportBug.R' [0s]
  Running 'Object.R' [162s]
  Running 'Object.finalize,noattach.R' [0s]
  Running 'Object.finalize,onoff.R' [1s]
  Running 'Object.finalize.R' [0s]
  Running 'Package.R' [157s]
  Running 'Package.unload.R' [0s]
  Running 'StaticMethodsAndNamespaces.R' [0s]
  Running 'abort.R' [0s]
  Running 'attachLocally.Object.R' [163s]
  Running 'equals.R' [0s]
  Running 'extend.default.R' [165s]
  Running 'getConstructorS3.R' [0s]
  Running 'hashCode.R' [161s]
  Running 'isBeingCreated.Class.R' [0s]
  Running 'll.R' [1s]
  Running 'local.R' [0s]
  Running 'objectSize.R' [172s]
  Running 'throw.R' [165s]
  Running 'trim.R' [157s]
  Running 'typeOfClass.R' [0s]
  Running 'zzz.Object.finalize,reentrant.R' [160s]
Running the tests in 'tests/ASCII.R' failed.
Complete output:
  > message("TESTING: ASCII...")
  TESTING: ASCII...
  > 
  > library("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
  
  > 
  > ## Display ASCII table
  > print(R.oo::ASCII)
    [1] ""     "\001" "\002" "\003" "\004" "\005" "\006" "\a"   "\b"   "\t"  
   [11] "\n"   "\v"   "\f"   "\r"   "\016" "\017" "\020" "\021" "\022" "\023"
   [21] "\024" "\025" "\026" "\027" "\030" "\031" "\032" "\033" "\034" "\035"
   [31] "\036" "\037" " "    "!"    "\""   "#"    "$"    "%"    "&"    "'"   
   [41] "("    ")"    "*"    "+"    ","    "-"    "."    "/"    "0"    "1"   
   [51] "2"    "3"    "4"    "5"    "6"    "7"    "8"    "9"    ":"    ";"   
   [61] "<"    "="    ">"    "?"    "@"    "A"    "B"    "C"    "D"    "E"   
   [71] "F"    "G"    "H"    "I"    "J"    "K"    "L"    "M"    "N"    "O"   
   [81] "P"    "Q"    "R"    "S"    "T"    "U"    "V"    "W"    "X"    "Y"   
   [91] "Z"    "["    "\\"   "]"    "^"    "_"    "`"    "a"    "b"    "c"   
  [101] "d"    "e"    "f"    "g"    "h"    "i"    "j"    "k"    "l"    "m"   
  [111] "n"    "o"    "p"    "q"    "r"    "s"    "t"    "u"    "v"    "w"   
  [121] "x"    "y"    "z"    "{"    "|"    "}"    "~"    "\177" "\x80" "\x81"
  [131] "\x82" "\x83" "\x84" "\x85" "\x86" "\x87" "\x88" "\x89" "\x8a" "\x8b"
  [141] "\x8c" "\x8d" "\x8e" "\x8f" "\x90" "\x91" "\x92" "\x93" "\x94" "\x95"
  [151] "\x96" "\x97" "\x98" "\x99" "\x9a" "\x9b" "\x9c" "\x9d" "\x9e" "\x9f"
  [161] "\xa0" "\xa1" "\xa2" "\xa3" "\xa4" "\xa5" "\xa6" "\xa7" "\xa8" "\xa9"
  [171] "\xaa" "\xab" "\xac" "\xad" "\xae" "\xaf" "\xb0" "\xb1" "\xb2" "\xb3"
  [181] "\xb4" "\xb5" "\xb6" "\xb7" "\xb8" "\xb9" "\xba" "\xbb" "\xbc" "\xbd"
  [191] "\xbe" "\xbf" "\xc0" "\xc1" "\xc2" "\xc3" "\xc4" "\xc5" "\xc6" "\xc7"
  [201] "\xc8" "\xc9" "\xca" "\xcb" "\xcc" "\xcd" "\xce" "\xcf" "\xd0" "\xd1"
  [211] "\xd2" "\xd3" "\xd4" "\xd5" "\xd6" "\xd7" "\xd8" "\xd9" "\xda" "\xdb"
  [221] "\xdc" "\xdd" "\xde" "\xdf" "\xe0" "\xe1" "\xe2" "\xe3" "\xe4" "\xe5"
  [231] "\xe6" "\xe7" "\xe8" "\xe9" "\xea" "\xeb" "\xec" "\xed" "\xee" "\xef"
  [241] "\xf0" "\xf1" "\xf2" "\xf3" "\xf4" "\xf5" "\xf6" "\xf7" "\xf8" "\xf9"
  [251] "\xfa" "\xfb" "\xfc" "\xfd" "\xfe" "\xff"
  > 
  > idxs <- 1:255
  > str(idxs)
   int [1:255] 1 2 3 4 5 6 7 8 9 10 ...
  > 
  > chars <- intToChar(idxs)
  > print(chars)
    [1] "\001" "\002" "\003" "\004" "\005" "\006" "\a"   "\b"   "\t"   "\n"  
   [11] "\v"   "\f"   "\r"   "\016" "\017" "\020" "\021" "\022" "\023" "\024"
   [21] "\025" "\026" "\027" "\030" "\031" "\032" "\033" "\034" "\035" "\036"
   [31] "\037" " "    "!"    "\""   "#"    "$"    "%"    "&"    "'"    "("   
   [41] ")"    "*"    "+"    ","    "-"    "."    "/"    "0"    "1"    "2"   
   [51] "3"    "4"    "5"    "6"    "7"    "8"    "9"    ":"    ";"    "<"   
   [61] "="    ">"    "?"    "@"    "A"    "B"    "C"    "D"    "E"    "F"   
   [71] "G"    "H"    "I"    "J"    "K"    "L"    "M"    "N"    "O"    "P"   
   [81] "Q"    "R"    "S"    "T"    "U"    "V"    "W"    "X"    "Y"    "Z"   
   [91] "["    "\\"   "]"    "^"    "_"    "`"    "a"    "b"    "c"    "d"   
  [101] "e"    "f"    "g"    "h"    "i"    "j"    "k"    "l"    "m"    "n"   
  [111] "o"    "p"    "q"    "r"    "s"    "t"    "u"    "v"    "w"    "x"   
  [121] "y"    "z"    "{"    "|"    "}"    "~"    "\177" "\x80" "\x81" "\x82"
  [131] "\x83" "\x84" "\x85" "\x86" "\x87" "\x88" "\x89" "\x8a" "\x8b" "\x8c"
  [141] "\x8d" "\x8e" "\x8f" "\x90" "\x91" "\x92" "\x93" "\x94" "\x95" "\x96"
  [151] "\x97" "\x98" "\x99" "\x9a" "\x9b" "\x9c" "\x9d" "\x9e" "\x9f" "\xa0"
  [161] "\xa1" "\xa2" "\xa3" "\xa4" "\xa5" "\xa6" "\xa7" "\xa8" "\xa9" "\xaa"
  [171] "\xab" "\xac" "\xad" "\xae" "\xaf" "\xb0" "\xb1" "\xb2" "\xb3" "\xb4"
  [181] "\xb5" "\xb6" "\xb7" "\xb8" "\xb9" "\xba" "\xbb" "\xbc" "\xbd" "\xbe"
  [191] "\xbf" "\xc0" "\xc1" "\xc2" "\xc3" "\xc4" "\xc5" "\xc6" "\xc7" "\xc8"
  [201] "\xc9" "\xca" "\xcb" "\xcc" "\xcd" "\xce" "\xcf" "\xd0" "\xd1" "\xd2"
  [211] "\xd3" "\xd4" "\xd5" "\xd6" "\xd7" "\xd8" "\xd9" "\xda" "\xdb" "\xdc"
  [221] "\xdd" "\xde" "\xdf" "\xe0" "\xe1" "\xe2" "\xe3" "\xe4" "\xe5" "\xe6"
  [231] "\xe7" "\xe8" "\xe9" "\xea" "\xeb" "\xec" "\xed" "\xee" "\xef" "\xf0"
  [241] "\xf1" "\xf2" "\xf3" "\xf4" "\xf5" "\xf6" "\xf7" "\xf8" "\xf9" "\xfa"
  [251] "\xfb" "\xfc" "\xfd" "\xfe" "\xff"
  > stopifnot(length(chars) == length(idxs))
  > 
  > idxs2 <- charToInt(chars)
  > str(idxs2)
   int [1:255] 1 2 3 4 5 6 7 8 9 10 ...
  > stopifnot(length(idxs2) == length(chars))
  > 
  > stopifnot(identical(idxs2, idxs))
  > 
  > 
  > message("TESTING: ASCII...DONE")
  TESTING: ASCII...DONE
  > 
  > proc.time()
     user  system elapsed 
     0.28    0.09    0.31 
Running the tests in 'tests/Class.R' failed.
Complete output:
  > message("TESTING: Class...")
  TESTING: Class...
  > 
  > library("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
  
  > 
  > clazz <- Object
  > print(clazz)
  Object
    public attach(private=FALSE, pos=2, ...)
    public attachLocally(private=FALSE, fields=NULL, excludeFields=NULL, overwrite=TRUE, envir=parent.frame(), ...)
    public clearCache(recursive=TRUE, gc=FALSE, ...)
    public detach(...)
    public equals(other, ...)
    public finalize(...)
    public getFields(private=FALSE, ...)
    public getInstantiationTime(...)
    public hasField(field, ...)
    public hashCode(...)
    public static load(file, path=NULL, ...)
    public save(file=NULL, path=NULL, compress=TRUE, ..., safe=TRUE)
  }
  > print(as.character(clazz))
  [1] "Class Object has 0 fields and 28 methods."
  > 
  > 
  > message(" - instantiation ...")
   - instantiation ...
  > obj <- Object()
  > print(obj)
  [1] "Object: 0x000002115781b490"
  > obj <- newInstance(clazz)
  > print(obj)
  [1] "Object: 0x00000211577b8f40"
  > stopifnot(inherits(obj, "Object"))
  > obj <- clazz[["newInstance"]]()
  > print(obj)
  [1] "Object: 0x0000021157404fb8"
  > stopifnot(inherits(obj, "Object"))
  > message(" - instantiation ... DONE")
   - instantiation ... DONE
  > 
  > 
  > message(" - reflection ...")
   - reflection ...
  > clazz <- Class$forName("Object")
  > print(clazz)
  Object
    public attach(private=FALSE, pos=2, ...)
    public attachLocally(private=FALSE, fields=NULL, excludeFields=NULL, overwrite=TRUE, envir=parent.frame(), ...)
    public clearCache(recursive=TRUE, gc=FALSE, ...)
    public detach(...)
    public equals(other, ...)
    public finalize(...)
    public getFields(private=FALSE, ...)
    public getInstantiationTime(...)
    public hasField(field, ...)
    public hashCode(...)
    public static load(file, path=NULL, ...)
    public save(file=NULL, path=NULL, compress=TRUE, ..., safe=TRUE)
  }
  > print(getKnownSubclasses(clazz))
  [1] "Class"                  "Exception"              "InternalErrorException"
  [4] "Package"                "RccViolationException"  "Rdoc"                  
  [7] "RdocException"         
  > static <- getStaticInstance(clazz)
  > print(static)
  [1] "Object: 0x0000021159c3c458"
  > pkg <- getPackage(clazz)
  > print(pkg)
  [1] "R.oo"
  > stopifnot(pkg == "R.oo")
  > 
  > ## Odds and ends
  > print(isBeingCreated(clazz))
  [1] FALSE
  > 
  > ## FIXME: Case should never occur but code allows for it
  > print(isBeingCreated.Class(obj))
  [1] FALSE
  > message(" - reflection ... DONE")
   - reflection ... DONE
  > 
  > 
  > message(" - modifiers ...")
   - modifiers ...
  > print(isAbstract(clazz))
  [1] FALSE
  > print(isPrivate(clazz))
  [1] FALSE
  > print(isProtected(clazz))
  [1] FALSE
  > print(isPublic(clazz))
  [1] TRUE
  > print(isDeprecated(clazz))
  [1] FALSE
  > print(isStatic(clazz))  ## TRUE because of Object$load()
  [1] TRUE
  > message(" - modifiers ... DONE")
   - modifiers ... DONE
  > 
  > 
  > message(" - inheritance ...")
   - inheritance ...
  > setConstructorS3("MyClass", function(...) {
  +   extend(Object(), "MyClass", ...)
  + })
  > 
  > obj <- MyClass(a=1, b=2, c=3)
  > print(obj)
  [1] "MyClass: 0x000002115e1920a0"
  > stopifnot(all(c("a", "b", "c") %in% names(obj)))
  > 
  > obj <- newInstance(MyClass, a=1, b=2, c=3)
  > print(obj)
  [1] "MyClass: 0x000002115e83d4c0"
  > stopifnot(all(c("a", "b", "c") %in% names(obj)))
  > 
  > message(" - inheritance ... DONE")
   - inheritance ... DONE
  > 
  > 
  > 
  > message("TESTING: Class...DONE")
  TESTING: Class...DONE
  > 
  > proc.time()
     user  system elapsed 
     0.70    0.14    0.82 
Running the tests in 'tests/Exception.R' failed.
Complete output:
  > message("TESTING: Exception...")
  TESTING: Exception...
  > 
  > library("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
  
  > oopts <- options(warn=1)
  > 
  > ######################################################################
  > # 1. To catch a regular "error" exception thrown by e.g. stop().
  > ######################################################################
  > x <- NA
  > y <- NA
  > tryCatch({
  +   x <- log(123)
  +   y <- log("a")
  + }, error = function(ex) {
  +   print(ex)
  + })
  <simpleError in log("a"): non-numeric argument to mathematical function>
  > print(x)
  [1] 4.812184
  > print(y)
  [1] NA
  > 
  > 
  > 
  > ######################################################################
  > # 2. Always run a "final" expression regardless or error or not.
  > ######################################################################
  > filename <- tempfile("R.methodsS3.example")
  > con <- file(filename)
  > tryCatch({
  +   open(con, "r")
  + }, error = function(ex) {
  +   cat("Could not open ", filename, " for reading.\n", sep="")
  + }, finally = {
  +   close(con)
  +   cat("The id of the connection is ",
  +        ifelse(is.null(con), "NULL", con), ".\n", sep="")
  + })
  Warning in open.connection(con, "r") :
    cannot open file 'D:\temp\RtmpcPemkw\R.methodsS3.example317c023d955ad': No such file or directory
  Could not open D:\temp\RtmpcPemkw\R.methodsS3.example317c023d955ad for reading.
  The id of the connection is 3.
  > 
  > 
  > ######################################################################
  > # 3. Creating your own Exception class
  > ######################################################################
  > setConstructorS3("NegativeLogValueException", function(
  +   msg="Trying to calculate the logarithm of a negative value", value=NULL) {
  +   extend(Exception(msg=msg), "NegativeLogValueException",
  +     .value = value
  +   )
  + })
  > 
  > setMethodS3("as.character", "NegativeLogValueException", function(this, ...) {
  +   paste(as.character.Exception(this), ": ", getValue(this), sep="")
  + })
  NULL
  > 
  > setMethodS3("getValue", "NegativeLogValueException", function(this, ...) {
  +   this$.value
  + })
  > 
  > 
  > mylog <- function(x, base=exp(1)) {
  +   if (x < 0)
  +     throw(NegativeLogValueException(value=x))
  +   else
  +     log(x, base=base)
  + }
  > 
  > 
  > # Note that the order of the catch list is important:
  > l <- NA
  > x <- 123
  > tryCatch({
  +   l <- mylog(x)
  + }, NegativeLogValueException = function(ex) {
  +   cat(as.character(ex), "\n")
  + }, "try-error" = function(ex) {
  +   cat("try-error: Could not calculate the logarithm of ", x, ".\n", sep="")
  + }, error = function(ex) {
  +   cat("error: Could not calculate the logarithm of ", x, ".\n", sep="")
  + })
  > cat("The logarithm of ", x, " is ", l, ".\n\n", sep="")
  The logarithm of 123 is 4.812184.
  
  > 
  > options(oopts)
  > 
  > message("TESTING: Exception...DONE")
  TESTING: Exception...DONE
  > 
  > proc.time()
     user  system elapsed 
     0.17    0.14    0.28 
Running the tests in 'tests/Object.R' failed.
Complete output:
  > message("TESTING: Object...")
  TESTING: Object...
  > 
  > library("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
  
  > 
  > obj <- Object()
  > print(obj)
  [1] "Object: 0x0000025f10c31c30"
  > 
  > obj <- Object(42L)
  > print(obj)
  [1] "Object: 0x0000025f10c65ff0"
  > stopifnot(obj == 42L)
  > 
  > obj$a <- 1:99
  > print(obj)
  [1] "Object: 0x0000025f10c65ff0"
  > 
  > fields <- getFields(obj)
  > print(fields)
  [1] "a"
  > 
  > hasA <- hasField(obj, "a")
  > print(hasA)
  [1] TRUE
  > stopifnot(hasA)
  > 
  > value <- obj$a
  > str(value)
   int [1:99] 1 2 3 4 5 6 7 8 9 10 ...
  > stopifnot(identical(value, 1:99))
  > 
  > obj$a <- 1:100
  > print(obj)
  [1] "Object: 0x0000025f10c65ff0"
  > 
  > value <- obj[["a"]]
  > str(value)
   int [1:100] 1 2 3 4 5 6 7 8 9 10 ...
  > stopifnot(identical(value, 1:100))
  > 
  > obj[["a"]] <- 1:101
  > print(obj)
  [1] "Object: 0x0000025f10c65ff0"
  > 
  > value <- obj[["a"]]
  > str(value)
   int [1:101] 1 2 3 4 5 6 7 8 9 10 ...
  > stopifnot(identical(value, 1:101))
  > 
  > size <- objectSize(obj)
  > print(size)
  760 bytes
  > 
  > ref <- isReferable(obj)
  > print(ref)
  [1] TRUE
  > stopifnot(isTRUE(ref))
  > 
  > time <- getInstantiationTime(obj)
  > print(time)
  NULL
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Attach and detach
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > res <- attach(obj)
  > print(res)
  [1] TRUE
  > stopifnot(exists("a", mode="integer"))
  > str(a)
   int [1:101] 1 2 3 4 5 6 7 8 9 10 ...
  > 
  > ## Object already attached
  > res <- tryCatch(attach(obj), warning=function(w) w)
  > stopifnot(inherits(res, "warning"))
  > 
  > res <- detach(obj)
  > print(res)
  [1] TRUE
  > 
  > ## Object already detached
  > res <- tryCatch(detach(obj), warning=function(w) w)
  > stopifnot(inherits(res, "warning"))
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Save and load
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > obj <- Object()
  > obj$a <- 1
  > obj$b <- 2
  > pathnameT <- tempfile()
  > save(obj, file=pathnameT)
  > 
  > obj2 <- Object$load(pathnameT)
  > stopifnot(all.equal(getFields(obj2), getFields(obj)))
  > for (key in getFields(obj)) {
  +   stopifnot(identical(obj2[[key]], obj[[key]]))
  + }
  > 
  > file.remove(pathnameT)
  [1] TRUE
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Class
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > obj2 <- newInstance(obj, 43L)
  > print(obj2)
  [1] "Object: 0x0000025f0fabfcd8"
  > stopifnot(obj2 == 43L)
  > 
  > 
  > hash <- hashCode(obj)
  > print(hash)
  [1] 2.607287e+12
  > stopifnot(length(hash) == 1L)
  > 
  > neq <- equals(obj, 1)
  > print(neq)
  [1] FALSE
  > stopifnot(!neq)
  > 
  > eq <- equals(obj, obj)
  > print(eq)
  [1] TRUE
  > stopifnot(eq)
  > 
  > obj3 <- clone(obj)
  > print(obj3)
  [1] "Object: 0x0000025f0fb76990"
  > stopifnot(!identical(obj3, obj))
  > stopifnot(all.equal(obj3, obj))
  > 
  > 
  > message("TESTING: Object...DONE")
  TESTING: Object...DONE
  > 
  > proc.time()
     user  system elapsed 
     0.26    0.09    0.34 
Running the tests in 'tests/Package.R' failed.
Complete output:
  > message("TESTING: Package...")
  TESTING: Package...
  > 
  > library("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
  
  > 
  > # By defining .onAttach() as follows in zzz.R for a package, an
  > # instance of class Package with the same name as the package will
  > # be made available on the search path. More over, the code below
  > # will also inform the user that the package has been loaded:
  > #
  > #  > library(R.oo)
  > #  R.oo v0.52 (2003/04/13) was successfully loaded.
  > #
  > .onAttach <- function(libname, pkgname) {
  +   pkg <- Package(pkgname)
  +   assign(pkgname, pkg, pos=getPosition(pkg))
  +   cat(getName(pkg), " v", getVersion(pkg), " (", getDate(pkg), ")",
  +     " was successfully loaded.\n", sep="")
  + }
  > 
  > # The Package class works for any packages, loaded or not.
  > 
  > # Some information about the base package
  > pkg <- Package("base")
  > print(pkg)
  [1] "Package: base v4.4.0 is loaded (pos=11).  Title: The R Base Package.  The official webpage is NA and the maintainer is R Core Team <do-use-Contact-address@r-project.org>.  The package is installed in D:/RCompile/recent/R/library/base.  License: Part of R 4.4.0.  Description: Base R functions.  Type showNews(base) for package history, and ?base for help."
  > # [1] "Package: base v3.6.2 is loaded (pos=14).  Title: The R Base Package.
  > # The official webpage is NA and the maintainer is R Core Team <R-core@
  > # r-project.org>.  The package is installed in /usr/lib/R/library/base/.
  > # License: Part of R 3.6.2.  Description: Base R functions.  Type 
  > # showNews(base) for package history, and ?base for help."
  > print(list.files(Package("base")$dataPath))
  character(0)
  > 
  > # Some information about the R.oo package
  > print(R.oo::R.oo)
  [1] "Package: R.oo v1.26.0 (2024-01-24 05:12:50 UTC) is loaded (pos=2).  Title: R Object-Oriented Programming with or without References.  The official webpage is https://github.com/HenrikBengtsson/R.oo and the maintainer is Henrik Bengtsson.  The package is installed in D:/RCompile/CRANpkg/lib/4.4/R.oo.  License: LGPL (>= 2.1).  Description: Methods and classes for object-oriented programming in R with or without references.  Large effort has been made on making definition of methods as simple as possible with a minimum of maintenance for package developers.  The package has been developed since 2001 and is now considered very stable.  This is a cross-platform package implemented in pure R that defines standard S3 classes without any tricks.  Type showNews(R.oo) for package history, and ?R.oo for help."
  > # [1] "Package: R.oo v1.23.0-9000 .  Title: R Object-Oriented Programming 
  > # with or without References.  The official webpage is https://github.com/
  > # HenrikBengtsson/R.oo and the maintainer is Henrik Bengtsson.  The package
  > # is installed in /home/alice/R/x86_64-pc-linux-gnu-library/3.6/R.oo/.
  > # License: LGPL (>= 2.1).  Description: Methods and classes for object-
  > # oriented programming in R with or without references.  Large effort has
  > # been made on making definition of methods as simple as possible with a 
  > # minimum of maintenance for package developers.  The package has been 
  > # developed since 2001 and is now considered very stable.  This is a 
  > # cross-platform package implemented in pure R that defines standard S3
  > # classes without any tricks.  Type showNews(R.oo) for package history,
  > # and ?R.oo for help."
  > 
  > pkg <- Package("R.oo")
  > classes <- getClasses(pkg)
  > print(classes)
   [1] "BasicObject"            "Class"                  "Exception"             
   [4] "Interface"              "InternalErrorException" "Object"                
   [7] "Package"                "RccViolationException"  "Rdoc"                  
  [10] "RdocException"         
  > stopifnot(all(c("Object", "Class", "Interface", "Exception", "Package") %in% classes))
  > 
  > pkg <- Package("R.oo")
  > res <- showDescriptionFile(pkg, pager=function(...) TRUE)
  > stopifnot(isTRUE(res))
  > res <- showNews(pkg, pager=function(...) TRUE)
  > stopifnot(isTRUE(res))
  > res <- showChangeLog(pkg, pager=function(...) TRUE)
  > stopifnot(isTRUE(res))
  > res <- showHistory(pkg, pager=function(...) TRUE)
  > stopifnot(isTRUE(res))
  > 
  > 
  > res <- try(Package("Non-Existing-Package"), silent=TRUE)
  > stopifnot(inherits(res, "try-error"))
  > 
  > message("TESTING: Package...DONE")
  TESTING: Package...DONE
  > 
  > proc.time()
     user  system elapsed 
     0.26    0.10    0.35 
Running the tests in 'tests/attachLocally.Object.R' failed.
Complete output:
  > message("TESTING: attachLocally()...")
  TESTING: attachLocally()...
  > 
  > library("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
  
  > 
  > foo <- function(object, arg1="some value", ...) {
  +   cat("Local objects in foo():\n")
  +   print(ls())
  + 
  +   attachLocally(object)
  + 
  +   cat("\nLocal objects in foo():\n")
  +   print(ls())
  + 
  +   for (name in ls()) {
  +     cat("\nObject '", name, "':\n", sep="")
  +     print(get(name, inherits=FALSE))
  +   }
  + }
  > 
  > a <- "A string"
  > obj <- Object()
  > obj$a <- "Another string"
  > obj$b <- NA
  > foo(obj)
  Local objects in foo():
  [1] "arg1"   "object"
  
  Local objects in foo():
  [1] "a"      "arg1"   "b"      "object"
  
  Object 'a':
  [1] "Another string"
  
  Object 'arg1':
  [1] "some value"
  
  Object 'b':
  [1] NA
  
  Object 'object':
  [1] "Object: 0x00000247210325e0"
  > print(a)
  [1] "A string"
  > 
  > message("TESTING: attachLocally()...DONE")
  TESTING: attachLocally()...DONE
  > 
  > proc.time()
     user  system elapsed 
     0.20    0.09    0.28 
Running the tests in 'tests/extend.default.R' failed.
Complete output:
  > message("TESTING: extend()...")
  TESTING: extend()...
  > 
  > library("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
  
  > 
  > setConstructorS3("MyDouble", function(value=0, ...) {
  +   extend(as.double(value), "MyDouble", ...)
  + })
  > 
  > setMethodS3("as.character", "MyDouble", function(object, ...) {
  +   fmtstr <- attr(object, "fmtstr")
  +   if (is.null(fmtstr))
  +     fmtstr <- "%.6f"
  +   sprintf(fmtstr, object)
  + })
  NULL
  > 
  > setMethodS3("print", "MyDouble", function(object, ...) {
  +   print(as.character(object), ...)
  + })
  NULL
  > 
  > x <- MyDouble(3.1415926)
  > print(x)
  [1] "3.141593"
  > 
  > x <- MyDouble(3.1415926, fmtstr="%3.2f")
  > print(x)
  [1] "3.14"
  > attr(x, "fmtstr") <- "%e"
  > print(x)
  [1] "3.141593e+00"
  > 
  > 
  > 
  > 
  > 
  > 
  > setConstructorS3("MyList", function(value=0, ...) {
  +   extend(list(value=value, ...), "MyList")
  + })
  > 
  > setMethodS3("as.character", "MyList", function(object, ...) {
  +   fmtstr <- object$fmtstr
  +   if (is.null(fmtstr))
  +     fmtstr <- "%.6f"
  +   sprintf(fmtstr, object$value)
  + })
  NULL
  > 
  > setMethodS3("print", "MyList", function(object, ...) {
  +   print(as.character(object), ...)
  + })
  NULL
  > 
  > x <- MyList(3.1415926)
  > print(x)
  [1] "3.141593"
  > x <- MyList(3.1415926, fmtstr="%3.2f")
  > print(x)
  [1] "3.14"
  > x$fmtstr <- "%e"
  > print(x)
  [1] "3.141593e+00"
  > 
  > message("TESTING: extend()...DONE")
  TESTING: extend()...DONE
  > 
  > proc.time()
     user  system elapsed 
     0.20    0.10    0.29 
Running the tests in 'tests/hashCode.R' failed.
Complete output:
  > library(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
  
  > 
  > message("hashCode() ...")
  hashCode() ...
  > 
  > message("- NULL")
  - NULL
  > 
  > y <- hashCode(NULL)
  > print(y)
  NULL
  > stopifnot(is.null(y))
  > 
  > 
  > message("- empty vectors")
  - empty vectors
  > 
  > y <- hashCode(character(0L))
  > print(y)
  NULL
  > stopifnot(is.null(y))
  > 
  > y <- hashCode(integer(0L))
  > print(y)
  NULL
  > stopifnot(is.null(y))
  > 
  > y <- hashCode(double(0L))
  > print(y)
  NULL
  > stopifnot(is.null(y))
  > 
  > y <- hashCode(list())
  > print(y)
  NULL
  > stopifnot(is.null(y))
  > 
  > 
  > message("- strings")
  - strings
  > 
  > x <- ""
  > y <- hashCode(x)
  > print(y)
  [1] 0
  > stopifnot(
  +   is.integer(y),
  +   length(y) == length(x),
  +   !anyNA(y),
  +   y == 0L
  + )
  > 
  > x <- base::letters
  > y <- hashCode(x)
  > print(y)
   [1]  97  98  99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
  [20] 116 117 118 119 120 121 122
  > stopifnot(
  +   is.integer(y),
  +   length(y) == length(x),
  +   !anyNA(y),
  +   all(y == charToInt(base::letters))
  + )
  > 
  > x <- "abcdefghij"
  > y <- hashCode(x)
  > print(y)
  [1] -634317659
  > stopifnot(
  +   is.integer(y),
  +   length(y) == length(x),
  +   !anyNA(y),
  +   y == -634317659L
  + )
  > 
  > x <- "abcdefghijklmno"
  > y <- hashCode(x)
  > print(y)
  [1] 486644840
  > stopifnot(
  +   is.integer(y),
  +   length(y) == length(x),
  +   !anyNA(y),
  +   y == 486644840L
  + )
  > 
  > 
  > ## Assert no integer overflow => NA
  > for (n in seq_along(base::letters)) {
  +   x <- paste(base::letters[seq_len(n)], collapse = "")
  +   y <- hashCode(x)
  +   cat(sprintf("%s => %d\n", x, y))
  +   stopifnot(
  +     is.integer(y),
  +     length(y) == length(x),
  +     !anyNA(y)
  +   )
  + }
  a => 97
  ab => 3105
  abc => 96354
  abcd => 2987074
  abcde => 92599395
  abcdef => -1424385949
  abcdefg => -1206291356
  abcdefgh => 1259673732
  abcdefghi => 395180133
  abcdefghij => -634317659
  abcdefghijk => 1810989158
  abcdefghijkl => 306089158
  abcdefghijklm => 898829415
  abcdefghijklmn => 2093908199
  abcdefghijklmno => 486644840
  abcdefghijklmnop => -2093879032
  abcdefghijklmnopq => -485740439
  abcdefghijklmnopqr => 2121915689
  abcdefghijklmnopqrs => 1354877034
  abcdefghijklmnopqrst => -948484790
  abcdefghijklmnopqrstu => 661742699
  abcdefghijklmnopqrstuv => -960812693
  abcdefghijklmnopqrstuvw => 279577708
  abcdefghijklmnopqrstuvwx => 76974476
  abcdefghijklmnopqrstuvwxy => -1908758419
  abcdefghijklmnopqrstuvwxyz => 958031277
  > 
  > message("- integers")
  - integers
  > 
  > x <- 1:10
  > y <- hashCode(x)
  > print(y)
   [1]  1  2  3  4  5  6  7  8  9 10
  > stopifnot(
  +   is.integer(y),
  +   length(y) == length(x),
  +   !anyNA(y),
  +   all(y == x)
  + )
  > 
  > message("- doubles")
  - doubles
  > 
  > x <- as.numeric(1:10)
  > y <- hashCode(x)
  > print(y)
   [1]  1  2  3  4  5  6  7  8  9 10
  > stopifnot(
  +   is.integer(y),
  +   length(y) == length(x),
  +   !anyNA(y),
  +   all(y == as.integer(x))
  + )
  > 
  > 
  > message("- complex")
  - complex
  > 
  > x <- 1:10 + 0.1
  > y <- hashCode(x)
  > print(y)
   [1]  1  2  3  4  5  6  7  8  9 10
  > stopifnot(
  +   is.integer(y),
  +   length(y) == length(x),
  +   !anyNA(y),
  +   all(y == 1:10)
  + )
  > 
  > message("- miscellaneous types")
  - miscellaneous types
  > 
  > x <- list(0L)
  > y <- hashCode(x)
  > print(y)
  [1] 0
  > stopifnot(
  +   is.integer(y),
  +   length(y) == length(x),
  +   !anyNA(y),
  +   y == 0L
  + )
  > 
  > x <- as.list(1:10)
  > y <- hashCode(x)
  > print(y)
   [1]  1  2  3  4  5  6  7  8  9 10
  > stopifnot(
  +   is.integer(y),
  +   length(y) == length(x),
  +   !anyNA(y),
  +   all(y == 1:10)
  + )
  > 
  > 
  > message("hashCode() ... DONE")
  hashCode() ... DONE
  > 
  > proc.time()
     user  system elapsed 
     0.29    0.06    0.34 
Running the tests in 'tests/objectSize.R' failed.
Complete output:
  > message("TESTING: objectSize()...")
  TESTING: objectSize()...
  > 
  > library("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
  
  > 
  > ## Simple object
  > x <- 1:100
  > y0 <- object.size(x)
  > y <- objectSize(x)
  > print(y)
  448 bytes
  > stopifnot(y == y0)
  > 
  > ## A list
  > x <- as.list(1:100)
  > y0 <- object.size(x)
  > y <- objectSize(x)
  > print(y)
  6448 bytes
  > stopifnot(y == y0)
  > 
  > ## An environment
  > env <- new.env()
  > env$a <- 1:100
  > env$b <- as.list(1:100)
  > env$c <- new.env()
  > y0 <- object.size(env)
  > print(y0)
  56 bytes
  > y <- objectSize(env)
  > print(y)
  6896 bytes
  > 
  > ## An environment with circular dependencies
  > env <- new.env()
  > env$a <- 1:100
  > env$env <- env
  > y0 <- object.size(env)
  > print(y0)
  56 bytes
  > y <- objectSize(env)
  > print(y)
  448 bytes
  > 
  > message("TESTING: objectSize()...DONE")
  TESTING: objectSize()...DONE
  > 
  > proc.time()
     user  system elapsed 
     0.23    0.04    0.25 
Running the tests in 'tests/throw.R' failed.
Complete output:
  > message("TESTING: throw()...")
  TESTING: throw()...
  > 
  > library("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
  
  > 
  > ## Generate an error
  > ex <- tryCatch({
  +   stop("An error")
  + }, error = function(ex) {
  +   ex
  + })
  > print(ex)
  <simpleError in doTryCatch(return(expr), name, parentenv, handler): An error>
  > 
  > ## Re-throw the error
  > ex2 <- tryCatch({
  +   throw(ex)
  + }, error = function(ex) {
  +   ex
  + })
  > print(ex2)
  <simpleError in doTryCatch(return(expr), name, parentenv, handler): An error>
  > 
  > stopifnot(identical(ex2, ex))
  > 
  > 
  > ## Generate an Exception
  > ex <- tryCatch({
  +   throw("An error")
  + }, error = function(ex) {
  +   ex
  + })
  > print(ex)
  [2024-03-23 09:27:33.584313] Exception: An error
  > 
  > ## Re-throw the Exception
  > ex2 <- tryCatch({
  +   throw(ex)
  + }, error = function(ex) {
  +   ex
  + })
  > print(ex2)
  [2024-03-23 09:27:33.584313] Exception: An error
  > 
  > stopifnot(identical(ex2, ex))
  > 
  > 
  > message("TESTING: throw()...DONE")
  TESTING: throw()...DONE
  > 
  > proc.time()
     user  system elapsed 
     0.26    0.09    0.34 
Running the tests in 'tests/trim.R' failed.
Complete output:
  > message("TESTING: trim()...")
  TESTING: trim()...
  > 
  > library("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
  
  > 
  > x <- character(0L)
  > y <- trim(x)
  > print(y)
  character(0)
  > stopifnot(identical(y, x))
  > 
  > x <- "Hello world!"
  > y <- trim(x)
  > print(y)
  [1] "Hello world!"
  > stopifnot(identical(y, x))
  > 
  > x <- " \tHello world!\n "
  > y <- trim(x)
  > print(y)
  [1] "Hello world!"
  > stopifnot(identical(y, "Hello world!"))
  > 
  > x <- c(" \tHello",  "world!")
  > y <- trim(x)
  > print(y)
  [1] "Hello"  "world!"
  > stopifnot(identical(y, c("Hello", "world!")))
  > 
  > 
  > message("TESTING: trim()...DONE")
  TESTING: trim()...DONE
  > 
  > proc.time()
     user  system elapsed 
     0.17    0.14    0.26 
Running the tests in 'tests/zzz.Object.finalize,reentrant.R' failed.
Complete output:
  > message("TESTING: finalize() reentrant...")
  TESTING: finalize() reentrant...
  > 
  > ## FIXME: 'covr' does not play well with tests
  > ## detaching/unloading packages
  > if ("covr" %in% loadedNamespaces()) {
  +   detach <- function(...) NULL
  + }
  > 
  > 
  > library("R.methodsS3")
  R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
  > library("R.oo")
  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
  
  > 
  > lotsOfParsing <- function(code="y <- 1:3") {
  +   parse(text=rep(code, times=10000))
  + }
  > 
  > setConstructorS3("MyClass", function(a=1:10) {
  +   extend(Object(), "MyClass", a=a)
  + })
  > 
  > setMethodS3("finalize", "MyClass", function(this, ...) {
  +   cat("finalize...\n")
  +   utils::str(sys.calls())
  +   cat("finalize...done\n")
  + })
  NULL
  > 
  > # Parse and eval expression (works)
  > expr <- lotsOfParsing()
  > eval(expr)
  > print(y)
  [1] 1 2 3
  > ## [1] 1 2 3
  > stopifnot(identical(y, 1:3))
  > 
  > # Create an object with a finalizer
  > x <- MyClass()
  > 
  > # Detach R.oo so that the finalizer will try to reload it
  > detach("package:R.oo")
  > 
  > # Remove 'x' so that it will be finalized below
  > rm(x)
  > 
  > 
  > # This may trigger garbage collection via parse()
  > # If so, it is important that parse() is not called
  > # (indirectly via library()) by the finalizer.
  > # Because otherwise R may crash.
  > expr2 <- lotsOfParsing(code="y <- 1:4")
  > ## finalize...
  > ## Dotted pair list of 9
  > ##  $ : ...
  > ##  ...
  > ##  $ : language function (env)  { ...
  > ##  $ : language finalize(this)
  > ##  $ : language finalize.MyClass(this)
  > ## Parse called: TRUE
  > ## finalize...done
  > eval(expr2)
  finalize...
  Dotted pair list of 4
   $ : language eval(expr2)
   $ : language (function (env)  { ...
   $ : language R.oo::finalize(this)
   $ : language finalize.MyClass(this)
  finalize...done
  > print(y)
  [1] 1 2 3 4
  > ## [1] 1 2 3 4
  > stopifnot(identical(y, 1:4))
  > 
  > print(warnings())
  > 
  > message("TESTING: finalize() reentrant...DONE")
  TESTING: finalize() reentrant...DONE
  > 
  > proc.time()
     user  system elapsed 
     0.31    0.04    0.34