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
20 changes: 11 additions & 9 deletions inst/tests/benchmark.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,17 @@ test(655, abs(tt1["user.self"] - tt2["user.self"])<2.0) # unoptimized tt2 takes
# Test for optimisation of 'order' to 'forder'.
set.seed(45L)
DT <- data.table(x=sample(1e2, 1e6,TRUE), y=sample(1e2, 1e6,TRUE))
old = options(datatable.optimize=Inf)
t1 = system.time(ans1 <- DT[order(x,-y)])[['elapsed']] # optimized to forder()
t2 = system.time(ans2 <- DT[base_order(x,-y)])[['elapsed']] # not optimized
test(1241.1, ans1, ans2)
if (.devtesting) test(1241.2, t1 < t2+0.1)
# 0.2 < 3.8 on Matt's laptop seems safe enough to test.
# Even so, 1241.2 has been known to fail, perhaps if system swaps and this R sessions pauses or something?
# We shouldn't have timing tests here that run on CRAN for this reason. Hence wrapping with .devtesting
options(old)
local({
old = options(datatable.optimize=Inf)
on.exit(options(old))
t1 = system.time(ans1 <- DT[order(x,-y)])[['elapsed']] # optimized to forder()
t2 = system.time(ans2 <- DT[base_order(x,-y)])[['elapsed']] # not optimized
test(1241.1, ans1, ans2)
if (.devtesting) test(1241.2, t1 < t2+0.1)
# 0.2 < 3.8 on Matt's laptop seems safe enough to test.
# Even so, 1241.2 has been known to fail, perhaps if system swaps and this R sessions pauses or something?
# We shouldn't have timing tests here that run on CRAN for this reason. Hence wrapping with .devtesting
})


# fwrite showProgress test 1735. Turned off as too long/big for CRAN.
Expand Down
15 changes: 8 additions & 7 deletions inst/tests/programming.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -195,37 +195,38 @@ test(5.10, list2lang(list("a", 1L, c(1L, 2L))), list(as.name("a"), 1L, c(1L,2L))
test(5.11, list2lang(list("a", 1L, call("c", 1L, 2L))), list(as.name("a"), 1L, quote(c(1L, 2L))))

# datatable.enlist
op = options(datatable.enlist=NULL)
test(6.01,
options = c(datatable.enlist=NULL),
substitute2(list(v1 = v2, v3 = v4), list(v1 = "int", v2 = 1L, v3 = "lst", v4 = list("a", "b", list("c", "d")))),
quote(list(int = 1L, lst = list(a, b, list(c, d)))))
options(datatable.enlist=FALSE)
test(6.02,
options = c(datatable.enlist=FALSE),
substitute2(list(v1 = v2, v3 = v4), list(v1 = "int", v2 = 1L, v3 = "lst", v4 = list("a", "b", list("c", "d")))),
substitute(list(int = 1L, lst = lst), list(lst = list("a", "b", list("c", "d")))))
options(datatable.enlist=NULL)
test(6.03,
options = c(datatable.enlist=NULL),
enlist(list(v1 = 1L, v2 = list(v3 = "b", v4 = list(v5 = "c")))),
quote(list(v1 = 1L, v2 = list(v3 = b, v4 = list(v5 = c)))))
options(datatable.enlist=FALSE)
test(6.04,
options = c(datatable.enlist=FALSE),
enlist(list(v1 = 1L, v2 = list(v3 = "b", v4 = list(v5 = "c")))),
substitute(list(v1 = 1L, v2 = lst), list(lst=list(v3 = "b", v4 = list(v5 = "c")))))
options(datatable.enlist=NULL)
test(6.05,
options = c(datatable.enlist=NULL),
substitute2(list(v1, v2, v3), list(v1="V1", v2="V2", v3=enlist(list("V4","V5")))),
quote(list(V1, V2, list(V4, V5))))
options(datatable.enlist=FALSE)
test(6.06,
options = c(datatable.enlist=FALSE),
substitute2(list(v1, v2, v3), list(v1="V1", v2="V2", v3=enlist(list("V4","V5")))),
quote(list(V1, V2, list(V4, V5))))
test(6.07,
options = c(datatable.enlist=FALSE),
substitute2(list(v1, v2, v3), list(v1="V1", v2="V2", v3=enlist(list("V4","V5", list("V6"))))),
substitute(list(V1, V2, list(V4, V5, lst)), list(lst=list("V6"))))
test(6.08,
options = c(datatable.enlist=FALSE),
substitute2(list(v1, v2, v3), list(v1="V1", v2="V2", v3=enlist(list("V4","V5", enlist(list("V6")))))),
quote(list(V1, V2, list(V4, V5, list(V6)))))
options(op)

# documentation examples
test(7.01, substitute2(list(var1 = var2), list(var1 = "c1", var2 = 5L)), quote(list(c1 = 5L))) ## works also on names
Expand Down
10 changes: 4 additions & 6 deletions inst/tests/types.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ test(2.05, testMsg(3, 2, 1), error=err)
test(2.06, testMsg(23, 2, 1), warning=wrn[1L], error=err)
##test(2.07, testMsg(123, 2, 1), message=msg[1L], warning=wrn[1L], error=err)
# test all messages
op = options(datatable.verbose=TRUE)
test(3.01, testMsg(0, 2, 1), as.list(rep(0L, 2L)), output=out)
test(3.01, options = c(datatable.verbose=TRUE), testMsg(0, 2, 1), as.list(rep(0L, 2L)), output=out)
##test(3.02, testMsg(1, 2, 1), as.list(rep(1L, 2L)), output=out, message=msg)
test(3.03, testMsg(2, 2, 1), as.list(rep(2L, 2L)), output=out, warning=wrn)
test(3.03, options = c(datatable.verbose=TRUE), testMsg(2, 2, 1), as.list(rep(2L, 2L)), output=out, warning=wrn)
##test(3.04, testMsg(12, 2, 1), as.list(rep(2L, 2L)), output=out, message=msg, warning=wrn)
test(3.05, testMsg(3, 2, 1), output=out[1L], error=err)
test(3.06, testMsg(23, 2, 1), output=out[1L], warning=wrn[1L], error=err)
test(3.05, options = c(datatable.verbose=TRUE), testMsg(3, 2, 1), output=out[1L], error=err)
test(3.06, options = c(datatable.verbose=TRUE), testMsg(23, 2, 1), output=out[1L], warning=wrn[1L], error=err)
##test(3.07, testMsg(123, 2, 1), output=out[1L], message=msg[1L], warning=wrn[1L], error=err)
options(op)