diff --git a/R/integer64.R b/R/integer64.R index 7a1715e..4b771ea 100644 --- a/R/integer64.R +++ b/R/integer64.R @@ -2251,7 +2251,7 @@ function (..., recursive = FALSE) K <- length(l) for (k in 1:K){ if (recursive && is.list(l[[k]])){ - l[[k]] <- do.call("c.integer64", c(l[[k]], list(recursive = TRUE))) + l[[k]] <- do.call(c.integer64, c(l[[k]], list(recursive = TRUE))) }else{ if (!is.integer64(l[[k]])) { nam <- names(l[[k]]) @@ -2261,7 +2261,7 @@ function (..., recursive = FALSE) oldClass(l[[k]]) <- NULL } } - ret <- do.call("c", l) + ret <- do.call(c, l) oldClass(ret) <- "integer64" ret } @@ -2278,7 +2278,7 @@ cbind.integer64 <- function(...){ } oldClass(l[[k]]) <- NULL } - ret <- do.call("cbind", l) + ret <- do.call(cbind, l) oldClass(ret) <- "integer64" ret } @@ -2294,7 +2294,7 @@ rbind.integer64 <- function(...){ } oldClass(l[[k]]) <- NULL } - ret <- do.call("rbind", l) + ret <- do.call(rbind, l) oldClass(ret) <- "integer64" ret } diff --git a/R/zzz.R b/R/zzz.R index a280de2..0e880a7 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -53,7 +53,10 @@ packageStartupMessage("WARNING semantics differ from integer") packageStartupMessage("for more help type ?bit64") } + +# nocov start .onUnload <- function(libpath){ packageStartupMessage("Unloading package bit64") library.dynam.unload("bit64", libpath) } +# nocov end diff --git a/tests/testthat/test-integer64.R b/tests/testthat/test-integer64.R index bd6572b..7d76997 100644 --- a/tests/testthat/test-integer64.R +++ b/tests/testthat/test-integer64.R @@ -52,6 +52,10 @@ test_that("indexing works", { expect_identical(x[3L], as.integer64(3L)) expect_identical(x[[4L]], as.integer64(4L)) + + names(x) = letters[1:10] + expect_identical(x[c("b", "c")], x[2:3]) + expect_identical(x[["d"]], x[[4L]]) }) test_that("arithmetic & basic math works", { @@ -64,6 +68,7 @@ test_that("arithmetic & basic math works", { # output is double even though it fits in integer [and integer64] expect_identical(x[seq(2L, 10L, by=2L)] / 2L, as.double(1:5)) expect_identical(x ^ 2L, as.integer64((1:10)^2L)) + expect_identical(-x, as.integer64(-(1:10))) expect_identical(x %/% 2L, as.integer64(c(0L, 1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L))) expect_identical(x %% 2L, as.integer64(rep_len(c(1L, 0L), 10L))) @@ -85,18 +90,35 @@ test_that("arithmetic & basic math works", { expect_identical(round(x), x) expect_identical(round(x, -1L), as.integer64(rep(c(0L, 10L), each=5L))) +}) + +test_that("basic statistics work", { + x = as.integer64(1:10) expect_identical(sum(x), as.integer64(55L)) + expect_identical(sum(x, x), as.integer64(110L)) expect_identical(prod(x), as.integer64(factorial(10L))) + expect_identical(prod(x[1:5], x[6:10]), as.integer64(factorial(10L))) expect_identical(min(x), x[1L]) + expect_identical(min(x, as.integer64(0L)), as.integer64(0L)) expect_identical(max(x), x[10L]) + expect_identical(max(x, as.integer64(11L)), as.integer64(11L)) + expect_identical(range(x), x[c(1L, 10L)]) + expect_identical(range(x, x+1L), c(x[1L], x[10L]+1L)) + expect_identical(diff(x), as.integer64(rep(1L, 9L))) + + expect_identical(cummin(x), as.integer64(rep(1L, 10L))) + expect_identical(cummax(x), x) + expect_identical(cumsum(x), as.integer64(choose(2:11, 2L))) + expect_identical(cumprod(x), as.integer64(factorial(1:10))) }) test_that("display methods work", { x = as.integer64(1:3) expect_identical(format(x), as.character(1:3)) expect_output(print(x), "integer64.*\\s*1\\s*2\\s*3") + expect_output(print(x[0L]), "integer64(0)", fixed=TRUE) expect_output(str(x), "integer64 [1:3] 1 2 3", fixed=TRUE) }) diff --git a/tests/testthat/test-patch64.R b/tests/testthat/test-patch64.R new file mode 100644 index 0000000..9524b48 --- /dev/null +++ b/tests/testthat/test-patch64.R @@ -0,0 +1,5 @@ +test_that("base generic overwrites work", { + x = c(2L, 4L, 3L) + expect_identical(rank(x), c(1.0, 3.0, 2.0)) + expect_identical(order(x), c(1L, 3L, 2L)) +}) diff --git a/tests/testthat/test-sort64.R b/tests/testthat/test-sort64.R new file mode 100644 index 0000000..0eda6f1 --- /dev/null +++ b/tests/testthat/test-sort64.R @@ -0,0 +1,3 @@ +test_that("order basics work", { + expect_identical(order(as.integer64(c(2L, 4L, 3L))), c(1L, 3L, 2L)) +})