R {realtest} | R Documentation |
Create a Result Descriptor by Recording Effects of an Expression Evaluation
Description
Evaluates an expression and records its direct and indirect effects:
the resulting value as well as the information whether any errors,
warnings, or messages are generated and if anything is printed on
stdout
or stderr
.
Usage
R(expr, ..., envir = parent.frame())
Arguments
expr |
expression to be evaluated |
... |
further arguments to be passed to |
envir |
environment where |
Details
Note that messages, warnings, and errors are typically written to
stderr
, but these are considered separately here.
In other words, when testing expectations with E
,
e.g., the reference stderr
should not include the anticipated
diagnostic messages.
There may be other side effects, such as changing the state of the random number generator, modifying options or environment variables, modifying the calling or global environment (e.g., creating new global variables), attaching objects onto the search part (e.g., loading package namespaces), or plotting, but these will not be captured, at least, not by the current version of the realtest package.
Value
A list of class realtest_descriptor
,
see P
, which this function calls.
The additional named component expr
gives the
expression that generated the value
.
Moreover, args
gives a named list of objects
that appeared in expr
(not including functions called).
If an effect of particular kind does not occur,
it is not included in the resulting list.
stdout
, stderr
, and error
are at most single strings.
When an error occurs, value
is NULL
.
Author(s)
See Also
The official online manual of realtest at https://realtest.gagolewski.com/
Examples
y <- 1:10; R(sum(y^2))
R(cat("a bit talkative, innit?"))
R(sqrt(c(-1, 0, 1, 2, 4)))
R(log("aaaargh"))
R({
cat("STDOUT"); cat("STDERR", file=stderr()); message("MESSAGE");
warning("WARNING"); warning("WARNING AGAIN"); cat("MORE STDOUT");
message("ANOTHER MESSAGE"); stop("ERROR"); y; "NO RETURN VALUE"
})