@@ -8286,8 +8286,8 @@ test(1579.03, dt[, lapply(.SD, median), keyby=x],
82868286 dt[, lapply(.SD, function(x) median(as.numeric(x))), keyby=x])
82878287test(1579.04, dt[, lapply(.SD, median, na.rm=TRUE), keyby=x],
82888288 dt[, lapply(.SD, function(x) median(as.numeric(x), na.rm=TRUE)), keyby=x])
8289- ans = capture.output( dt[, lapply(.SD, median), by=x, verbose=TRUE])
8290- test(1579.05, any(grepl( "GForce optimized", ans)), TRUE )
8289+ test(1579.05, dt[, lapply(.SD, median), by=x, verbose=TRUE],
8290+ output = "GForce optimized")
82918291
82928292# testing gforce::ghead and gforce::gtail
82938293# head(.SD, 1) and tail(.SD, 1) optimisation
@@ -9280,11 +9280,9 @@ test(1633.4, dt[, .SD, by=1:nrow(dt)], data.table(nrow=1:nrow(dt), dt)) # make s
92809280
92819281# reuse secondary indices
92829282dt = data.table(x=sample(3, 10, TRUE), y=1:10)
9283- v1 = capture.output(ans1 <- dt[.(3:2), on="x", verbose=TRUE])
9283+ test(1634.1, dt[.(3:2), on="x", verbose=TRUE], output = "ad hoc" )
92849284setindex(dt, x)
9285- v2 = capture.output(ans2 <- dt[.(3:2), on="x", verbose=TRUE])
9286- test(1634.1, any(grepl("ad hoc", v1)), TRUE)
9287- test(1634.2, any(grepl("existing index", v2)), TRUE)
9285+ test(1634.2, dt[.(3:2), on="x", verbose=TRUE], output = "existing index")
92889286
92899287# fread's fill argument detects separator better in complex cases as well, #1573
92909288# if pasted to the console, these tests won't work. But do work when sourced as these are tabs not spaces in text
@@ -11653,8 +11651,8 @@ test(1765.4, {warning("foobar1"); warning("foobar2"); warning("FOO"); 4L}, 4L, i
1165311651test(1765.5, {warning("foobar1"); warning("foobar2"); warning("FOO"); 4L}, 4L, ignore.warning="2", warning=c("foobar1","FOO"))
1165411652
1165511653# print(null.data.table()) should not output NULL as well, #1852
11656- # use capture.output() in this case rather than output= to ensure NULL is not output
11657- test(1766, capture.output(print( data.table(NULL))), " Null data.table (0 rows and 0 cols) ")
11654+ # the ^, $ specifiers don't match embedded newlines (if any) so match will fail if NULL is also printed
11655+ test(1766, data.table(NULL), output = "^ Null data\\ .table \\ (0 rows and 0 cols\\)$ ")
1165811656
1165911657# Bug on subset of 1-row data.table when expr returns a named logical vector #2152
1166011658options(datatable.auto.index=FALSE)
@@ -11888,8 +11886,8 @@ test(1774.17, as.data.table(x, na.rm='a'), error="'na.rm' must be scalar")
1188811886
1188911887# verify print.keys works
1189011888DT1 <- data.table(a = 1:3, key = "a")
11891- test(1775.1, capture.output(print( DT1, print.keys = TRUE) ),
11892- c("Key: <a>", " a", "1: 1", "2: 2", "3: 3"))
11889+ test(1775.1, DT1, options = c(datatable. print.keys = TRUE),
11890+ output = c("Key: <a>", " a", "1: 1", "2: 2", "3: 3"))
1189311891DT2 <- data.table(a = 1:3, b = 4:6)
1189411892setindexv(DT2, c("b","a"))
1189511893test(1775.2, print(DT2, print.keys = TRUE),
@@ -13675,7 +13673,7 @@ test(1962.034, setkeyv(DT, c('a', '')),
1367513673setkey(DT, a)
1367613674test(1962.035, {setkeyv(DT, character(0L)); key(DT)}, NULL,
1367713675 warning = 'cols is a character vector of zero length')
13678- test(1962.036, any(grepl('already ordered', capture.output( setkey(DT, a, verbose = TRUE)))) )
13676+ test(1962.036, setkey(DT, a, verbose = TRUE), output = 'already ordered' )
1367913677setnames(DT, '.xi')
1368013678setkey(DT, NULL)
1368113679test(1962.037, setkey(DT, .xi),
0 commit comments