Skip to content

Commit d9a42c0

Browse files
initial sweep + implementation
1 parent c8bbb58 commit d9a42c0

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed

R/test.data.table.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,10 @@ gc_mem = function() {
323323
# nocov end
324324
}
325325

326-
test = function(num,x,y=TRUE,error=NULL,warning=NULL,message=NULL,output=NULL,notOutput=NULL,ignore.warning=NULL,options=NULL,env=NULL) {
326+
test = function(num, x, y=TRUE,
327+
error=NULL, warning=NULL, message=NULL, output=NULL, notOutput=NULL, ignore.warning=NULL,
328+
options=NULL, env=NULL,
329+
context=NULL) {
327330
if (!is.null(env)) {
328331
old = Sys.getenv(names(env), names=TRUE, unset=NA)
329332
to_unset = !lengths(env)
@@ -570,6 +573,9 @@ test = function(num,x,y=TRUE,error=NULL,warning=NULL,message=NULL,output=NULL,no
570573
}
571574
# nocov end
572575
}
576+
if (fail && !is.null(context)) {
577+
catf("Test context: %s\n", context)
578+
}
573579
if (fail && .test.data.table && num>0.0) {
574580
# nocov start
575581
assign("nfail", nfail+1L, parent.frame(), inherits=TRUE)

inst/tests/froll.Rraw

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -878,12 +878,10 @@ base_compare = function(x, n, funs=c("mean","sum"), algos=c("fast","exact")) {
878878
for (fill in c(NA_real_, 0)) {
879879
for (algo in algos) {
880880
num <<- num + num.step
881-
eval(substitute( # so we can have values displayed in output/log rather than variables
882-
test(.num,
883-
froll(.fun, x, n, fill=.fill, na.rm=.na.rm, algo=.algo),
884-
rollfun(x, n, FUN=.fun, fill=.fill, na.rm=.na.rm, nf.rm=.nf.rm)),
885-
list(.num=num, .fun=fun, .fill=fill, .na.rm=na.rm, .algo=algo, .nf.rm=algo!="exact")
886-
))
881+
test(num,
882+
froll(fun, x, n, fill=fill, na.rm=na.rm, algo=algo),
883+
rollfun(x, n, FUN=fun, fill=fill, na.rm=na.rm, nf.rm=algo != "exact"),
884+
context=sprintf("fun=%s\tfill=%s\tna.rm=%s\talgo=%s", fun, fill, na.rm, algo))
887885
}
888886
}
889887
}
@@ -911,12 +909,10 @@ if (requireNamespace("zoo", quietly=TRUE)) {
911909
for (fill in c(NA_real_, 0)) {
912910
for (algo in algos) {
913911
num <<- num + num.step
914-
eval(substitute( # so we can have values displayed in output/log rather than variables
915-
test(.num,
916-
froll(.fun, x, n, align=.align, fill=.fill, na.rm=.na.rm, algo=.algo),
917-
drollapply(x, n, FUN=.fun, fill=.fill, align=.align, na.rm=.na.rm)),
918-
list(.num=num, .fun=fun, .align=align, .fill=fill, .na.rm=na.rm, .algo=algo)
919-
))
912+
test(num,
913+
froll(fun, x, n, align=align, fill=fill, na.rm=na.rm, algo=algo),
914+
drollapply(x, n, FUN=fun, fill=fill, align=align, na.rm=na.rm),
915+
context=sprintf("fun=%s\talign=%s\tfill=%s\tna.rm=%s\talgo=%s", fun, align, fill, na.rm, algo))
920916
}
921917
}
922918
}
@@ -974,12 +970,10 @@ afun_compare = function(x, n, funs=c("mean","sum"), algos=c("fast","exact")) {
974970
for (fill in c(NA_real_, 0)) {
975971
for (algo in algos) {
976972
num <<- num + num.step
977-
eval(substitute(
978-
test(.num,
979-
froll(.fun, x, n, fill=.fill, na.rm=.na.rm, algo=.algo, adaptive=TRUE),
980-
arollfun(.fun, x, n, fill=.fill, na.rm=.na.rm, nf.rm=.nf.rm)),
981-
list(.num=num, .fun=fun, .fill=fill, .na.rm=na.rm, .algo=algo, .nf.rm=algo!="exact")
982-
))
973+
test(num,
974+
froll(fun, x, n, fill=fill, na.rm=na.rm, algo=algo, adaptive=TRUE),
975+
arollfun(fun, x, n, fill=fill, na.rm=na.rm, nf.rm=algo != "exact"),
976+
context=sprintf("fun=%s\tfill=%s\tna.rm=%s\talgo=%s", fun, fill, na.rm, algo))
983977
}
984978
}
985979
}

inst/tests/tests.Rraw

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9861,11 +9861,10 @@ nqjoin_test <- function(x, y, k=1L, test_no, mult="all") {
98619861
for (i in seq_along(runcmb)) {
98629862
thiscols = runcmb[[i]]
98639863
thisops = runops[[i]]
9864-
# cat("k = ", k, "\ti = ", i, "\t thiscols = [", paste0(thiscols,collapse=","), "]\t thisops = [", paste0(thisops,collapse=","), "]\t ", sep="")
98659864
ans1 = nq(x, y, thiscols, thisops, 0L, mult=mult)
98669865
ans2 = check(x, y, thiscols, thisops, mult=mult)
98679866
test_no = test_no + .001
9868-
test(test_no, ans1, ans2) # nolint: dt_test_literal_linter.
9867+
test(test_no, ans1, ans2, context=sprintf("k = %d\ti = %d\tthiscols = [%s]\tthisops = [%s]", k, i, paste(thiscols, collapse=","), paste(thisops, collapse=",")))
98699868
}
98709869
gc() # no longer needed but left in place just in case, no harm
98719870
}

0 commit comments

Comments
 (0)