Building on the tinytest functions for testing equality with optional enhanced object diffing and additional test feedback through addtional attributes.
expect_equal_xl(
current,
target,
useDiffObj = TRUE,
tol = sqrt(.Machine$double.eps),
info = NA_character_,
mode = getOption("diffobj.mode", "unified"),
format = getOption("diffobj.format", "ansi256"),
...
)expect_identical_xl(
current,
target,
useDiffObj = TRUE,
info = NA_character_,
mode = getOption("diffobj.mode", "unified"),
format = getOption("diffobj.format", "ansi256"),
...
)
expect_equivalent_xl(
current,
target,
useDiffObj = TRUE,
tol = sqrt(.Machine$double.eps),
info = NA_character_,
mode = getOption("diffobj.mode", "unified"),
format = getOption("diffobj.format", "ansi256"),
...
)
A tinytest object. A tinytest object is a
logical with attributes holding information about the
test that was run
[R object or expression] Outcome or expression under scrutiny.
[R object or expression] Expected outcome
[logical] Whether you should use diffPrint for the diff field
in the resulting tinytest object
[numeric] Test equality to machine rounding. Passed
to all.equal (tolerance)
An additional attribute to pass around with the tinytest object
[character] Comparison mode passed to diffPrint,
defaults to using the “diffobj.mode” global option value with
“unified” as fallback if no such option is set
[character] Comparison mode passed to diffPrint,
defaults to to using the “diffobj.format” global option value with
“ansi256” as fallback if no such option is set
Passed to all.equal and returned as a test attributes
While tinytest does now support the passing of additional information with the info
field in its tests, they are not yet supported in the as.data.frame.tinytests
method.
library(tinytest)
using(ttdo)
expect_equal_xl(1 + 1, 2, score = 3) # TRUE
expect_equal_xl(1 - 1, 2, name = "check 1-1==2", score = 1, totalpts = 2) # FALSE
Run the code above in your browser using DataLab