| count_tests | R Documentation |
Count the number of calls to stopifnot at the top level of an
R script file.
count_tests(file, encoding, keep.source = getOption("keep.source"))
file |
a connection object or a character. |
encoding |
encoding to be assumed for input strings. |
keep.source |
a logical value; if |
A test is an R expression included in either of these forms of
stopifnot usage: stopifnot(A, B), or
stopifnot(exprs= {A ; B}). Usage as stopifnot(exprObject
= Obj) is not supported.
Calls to stopifnot in functions are ignored. Calls inside a
group are also currently omitted.
A number of tests.
## Keep parse data in non interactive sessions.
if (!interactive())
op <- options(keep.source = TRUE)
fil <- tempfile(fileext = ".R")
cat("stopifnot(1 == 1)",
"stopifnot(2 == 2, 3 == 3)",
"stopifnot(exprs = {",
" 4 == 4",
" 5 == 5",
" 6 == 6",
"})",
"## 'stopifnot' in a function is ignored",
"f <- function() stopifnot(6 == 6)",
file = fil, sep = "\n")
count_tests(fil)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.