Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .devcontainer/r-350/.Rprofile
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,17 @@ expect_no_warning <- function(object, ...) {
}

expect_error = function(expr, msg, ...) {
val = tryCatch(expr, error = identity)
val = tryCatch(expr, error=identity)
stopifnot(inherits(val, "error") && grepl(msg, conditionMessage(val), ...))
cat(".")
}

expect_no_error = function(expr) {
val = tryCatch(expr, error=identity)
stopifnot(!inherits(val, "error"))
cat(".")
}

expect_s3_class = function(x, kls) { stopifnot(inherits(x, kls)); cat(".") }
expect_length = function(x, l) expect_identical(length(x), l)

Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ S3method(ordertie,integer64)
S3method(orderuni,integer64)
S3method(orderupo,integer64)
S3method(prank,integer64)
S3method(print,bitstring)
S3method(print,cache)
S3method(print,integer64)
S3method(prod,integer64)
Expand Down
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
## NOTES

1. {bit64} no longer prints any start-up messages through an `.onAttach()` hook (#106). Thanks @hadley for the request.
2. The R version dependency has been bumped from 3.4.0 (2017) to 3.5.0 (2018).
1. The R version dependency has been bumped from 3.4.0 (2017) to 3.5.0 (2018).
1. From R 4.6.0, R's {utils} package has its own 'bitstring' class which is basically compatible with that shipped by {bit64} for many years. `as.bitstring()` only makes a simple adjustment, namely, for `as.bitstring()` to add two new attributes (`nbits` and `type`). Everything else should continue to work as before.

## BUG FIXES

Expand Down
9 changes: 2 additions & 7 deletions R/integer64.R
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,8 @@ as.character.integer64 = function(x, ...)
as.bitstring.integer64 = function(x, ...) {
ret = .Call(C_as_bitstring_integer64, x, rep(NA_character_, length(x)))
oldClass(ret) = 'bitstring'
attr(ret, 'nbits') = c(1L, 63L)
attr(ret, 'type') = "int64"
ret
}

Expand Down Expand Up @@ -780,13 +782,6 @@ factor = function(x=character(), levels, labels=levels, exclude=NA, ordered=is.o
#' @export
ordered = function(x=character(), ...) factor(x, ..., ordered=TRUE)

#' @rdname as.character.integer64
#' @export
print.bitstring = function(x, ...) {
oldClass(x) = minusclass(class(x), 'bitstring')
NextMethod(x)
}

#' @rdname as.integer64.character
#' @export
as.integer64.bitstring = function(x, ...) {
Expand Down
14 changes: 13 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,26 @@ if (getRversion() < "3.6.0") {
class(obj) = c(class, "error", "condition")
obj
}

warningCondition = function(message, ..., class = NULL, call = NULL) {
obj <- list(message = as.character(message), call = call, ...)
class(obj) = c(class, "warning", "condition")
obj
}
}

.onLoad = function(libname, pkgname) {
# TODO(R >= 4.6.0): remove this.
if (!utils::isS3method("print.bitstring")) {
registerS3method("print", "bitstring", function(x, ...) {
reset_class = minusclass(class(x), 'bitstring')
attributes(x) = NULL
oldClass(x) = reset_class
NextMethod(x)
})
}
}

.onAttach = function(libname, pkgname) {
packageStartupMessage( # in **bold**
"\033[1mThe assignment of character values to integer64 vectors and ",
Expand Down
3 changes: 0 additions & 3 deletions man/as.character.integer64.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/testthat/test-integer64.R
Original file line number Diff line number Diff line change
Expand Up @@ -1573,3 +1573,7 @@ test_that("back-compatible keep.names=TRUE is supported for limited input classe
y = c(a = 1.0)
expect_named(as.integer64(y, keep.names=TRUE), "a")
})

test_that("bitstring class meshes with R's own (from 4.6.0)", {
expect_no_error(print(as.bitstring(lim.integer64())))
})
Loading