Skip to content

Commit 3ddef1a

Browse files
aitapMichaelChirico
andcommitted
Apply fixes from code review
* conditionMessage() instead of toString() * apply names earlier * don't check for zero-length calls in sys.calls() * be careful not to over-translate an already-translated message Co-Authored-By: Michael Chirico <[email protected]>
1 parent 69d9555 commit 3ddef1a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

R/test.data.table.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ test.data.table = function(script="tests.Rraw", verbose=FALSE, pkg=".", silent=F
213213
# nocov start
214214
if (!silent && showProgress) print(w)
215215
env$warnings = c(env$warnings, list(list(
216-
env$prevtest, toString(w),
217-
paste(
216+
"after test"=env$prevtest, warning=conditionMessage(w),
217+
calls=paste(
218218
vapply_1c(sys.calls(), function(call) {
219-
if (length(call) && is.name(call[[1]])) {
219+
if (is.name(call[[1]])) {
220220
as.character(call[[1]])
221221
} else "..."
222222
}),
@@ -288,15 +288,15 @@ test.data.table = function(script="tests.Rraw", verbose=FALSE, pkg=".", silent=F
288288
if (length(env$warnings)) {
289289
# nocov start
290290
warnings = rbindlist(env$warnings)
291-
setnames(warnings, c("after test", "warning", "calls"))
292291
catf(
293292
ngettext(nrow(warnings),
294293
"Caught %d warning outside the test() calls:\n",
295294
"Caught %d warnings outside the test() calls:\n"
296295
),
297-
nrow(warnings)
296+
nrow(warnings),
297+
domain=NA
298298
)
299-
print(warnings)
299+
print(warnings, nrows = nrow(warnings))
300300
stopf("Tests succeeded, but non-test code caused warnings. Search %s for tests shown above.", names(fn))
301301
# nocov end
302302
}

0 commit comments

Comments
 (0)