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 R/test.data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,10 @@ gc_mem = function() {
# nocov end
}

test = function(num,x,y=TRUE,error=NULL,warning=NULL,message=NULL,output=NULL,notOutput=NULL,ignore.warning=NULL,options=NULL,env=NULL) {
test = function(num, x, y=TRUE,
error=NULL, warning=NULL, message=NULL, output=NULL, notOutput=NULL, ignore.warning=NULL,
options=NULL, env=NULL,
context=NULL) {
if (!is.null(env)) {
old = Sys.getenv(names(env), names=TRUE, unset=NA)
to_unset = !lengths(env)
Expand Down Expand Up @@ -570,6 +573,9 @@ test = function(num,x,y=TRUE,error=NULL,warning=NULL,message=NULL,output=NULL,no
}
# nocov end
}
if (fail && !is.null(context)) {
catf("Test context: %s\n", context) # nocov
}
if (fail && .test.data.table && num>0.0) {
# nocov start
assign("nfail", nfail+1L, parent.frame(), inherits=TRUE)
Expand Down
30 changes: 12 additions & 18 deletions inst/tests/froll.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -878,12 +878,10 @@ base_compare = function(x, n, funs=c("mean","sum"), algos=c("fast","exact")) {
for (fill in c(NA_real_, 0)) {
for (algo in algos) {
num <<- num + num.step
eval(substitute( # so we can have values displayed in output/log rather than variables
test(.num,
froll(.fun, x, n, fill=.fill, na.rm=.na.rm, algo=.algo),
rollfun(x, n, FUN=.fun, fill=.fill, na.rm=.na.rm, nf.rm=.nf.rm)),
list(.num=num, .fun=fun, .fill=fill, .na.rm=na.rm, .algo=algo, .nf.rm=algo!="exact")
))
test(num,
froll(fun, x, n, fill=fill, na.rm=na.rm, algo=algo),
rollfun(x, n, FUN=fun, fill=fill, na.rm=na.rm, nf.rm=algo != "exact"),
context=sprintf("fun=%s\tfill=%s\tna.rm=%s\talgo=%s", fun, fill, na.rm, algo))
}
}
}
Expand Down Expand Up @@ -911,12 +909,10 @@ if (requireNamespace("zoo", quietly=TRUE)) {
for (fill in c(NA_real_, 0)) {
for (algo in algos) {
num <<- num + num.step
eval(substitute( # so we can have values displayed in output/log rather than variables
test(.num,
froll(.fun, x, n, align=.align, fill=.fill, na.rm=.na.rm, algo=.algo),
drollapply(x, n, FUN=.fun, fill=.fill, align=.align, na.rm=.na.rm)),
list(.num=num, .fun=fun, .align=align, .fill=fill, .na.rm=na.rm, .algo=algo)
))
test(num,
froll(fun, x, n, align=align, fill=fill, na.rm=na.rm, algo=algo),
drollapply(x, n, FUN=fun, fill=fill, align=align, na.rm=na.rm),
context=sprintf("fun=%s\talign=%s\tfill=%s\tna.rm=%s\talgo=%s", fun, align, fill, na.rm, algo))
}
}
}
Expand Down Expand Up @@ -974,12 +970,10 @@ afun_compare = function(x, n, funs=c("mean","sum"), algos=c("fast","exact")) {
for (fill in c(NA_real_, 0)) {
for (algo in algos) {
num <<- num + num.step
eval(substitute(
test(.num,
froll(.fun, x, n, fill=.fill, na.rm=.na.rm, algo=.algo, adaptive=TRUE),
arollfun(.fun, x, n, fill=.fill, na.rm=.na.rm, nf.rm=.nf.rm)),
list(.num=num, .fun=fun, .fill=fill, .na.rm=na.rm, .algo=algo, .nf.rm=algo!="exact")
))
test(num,
froll(fun, x, n, fill=fill, na.rm=na.rm, algo=algo, adaptive=TRUE),
arollfun(fun, x, n, fill=fill, na.rm=na.rm, nf.rm=algo != "exact"),
context=sprintf("fun=%s\tfill=%s\tna.rm=%s\talgo=%s", fun, fill, na.rm, algo))
}
}
}
Expand Down
Loading
Loading