Skip to content
Merged
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
2 changes: 1 addition & 1 deletion R/highlevel64.R
Original file line number Diff line number Diff line change
Expand Up @@ -2132,7 +2132,7 @@ table = function(..., exclude=if (useNA == "no") c(NA, NaN), useNA=c("no", "ifan
}
names(sys_call) = n
}
for (ii in seq_along(dots))
for (ii in which(vapply(dots, Negate(is.null), logical(1L))))
sys_call[[ii + 1L]] = dots[[ii]]
if (!missing(useNA)) sys_call$useNA = useNA
if (!missing(exclude)) sys_call$exclude = exclude
Expand Down
11 changes: 10 additions & 1 deletion tests/testthat/test-highlevel64.R
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,16 @@ test_that("exclude, useNA arguments work for integer64 method of table", {
)
})

test_that("function evaluation in arguments of table is consistent to R", {
test_that("our overwrite of table() is consistent with base::table", {
expect_identical(table(NULL), base::table(NULL))
expect_identical(table(a=NULL), base::table(a=NULL))
expect_identical(table(NULL, NULL), base::table(NULL, NULL))
expect_identical(table(a=NULL, b=NULL), base::table(a=NULL, b=NULL))
expect_identical(table(integer(), NULL), base::table(integer(), NULL))
expect_identical(table(a=integer(), b=NULL), base::table(a=integer(), b=NULL))
expect_same_error(table(1L, NULL), base::table(1L, NULL))
expect_same_error(table(a=1L, b=NULL), base::table(a=1L, b=NULL))

skip_unless_r("> 3.5.0") # unclear what's going on
expected_result = withr::with_seed(1L, base::table(exclude=sample(1:10, 1), useNA=sample(c("no", "ifany", "always"), 1), deparse.level=sample(1:2, 1), sample(1:10)))
expect_identical(
Expand Down