register_tinytest_extension | R Documentation |
Functions to use in .onLoad
and .onUnload
by packages that
extend tinytest.
register_tinytest_extension(pkg, functions)
pkg |
|
functions |
|
Packages can extend tinytest with expectation functions if and only if the following requirements are satisfied.
The extending functions return a tinytest
object. This
can be created by calling tinytest()
with the arguments (defaults,
if any, are in brackets):
result
: A logical
scalar: TRUE
or FALSE
(not
NA
)
call
: The call
to the expectation function. Usually the
result of sys.call(sys.parent(1))
diff
(NA_character_
): A character
scalar, with a long description of the
difference. Sentences may be separated by "\n"
.
short
(NA_character_
): Either "data"
, if the difference is in the
data. "attr"
when attributes differ or "xcpt"
when
an expectation about an exception is not met. If there are
differences in data and in attributes, the attributes take
precedence.
info
(NA_character_
): A user-defined message.
Observe that this requires the extending package to add tinytest to
the Imports
field in the package's DESCRIPTION
file (this
also holds for the following requirement).
Functions are registered in .onLoad()
using
register_tinytest_extension()
. Functions that are already
registered, including tinytest functions will be overwritten.
It is recommended to:
Follow the syntax conventions of tinytest so expectation
functions start with expect_
.
Explain to users of the extension package how to use the extension
(see using
).
include an info
argument to expect_
functions that
is passed to tinytest()
.
Extending tinytest: tinytest.extension.
Using a tinytest extension: using.tinytest.extension.
Other extensions:
tinytest()
,
using()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.