Description Usage Arguments Details Value Examples
The tests are written in terms of pronouns
F the function at the highest level (but with assignment removed)
Z the name being bound to the line's value by assignment. ("" if no assignment.)
V the value produced by the line.
E the expression itself (but with assignment removed)
1 | line_where(ex, ..., message = "No such line found.")
|
ex |
a |
... |
passif/failif/insist tests specifying the kind of line we want. The messages associated with each test can have moustaches written in terms of F, Z, V, or E. |
message |
A character string message to give if no acceptable line is found. |
Testing starts with the first test in ...
. Each test, in turn, can produce a definitive pass or fail result, at which point
testing is complete. But tests can also produce indefinite results, in which case testing moves on to the next test (if any).
If there is not a definitive result from the tests, the return
If passif()
or failif()
are used and the test is TRUE
, no further testing is performed. Similarly,
if insist()
is used and the test is FALSE
, no further testing is performed. If none of these conditions
applies, line_where()
progresses to the next of the tests in ...
. If none of the tests produce a definitive
result, line_where()
will return an OK result.
The ex
argument is a "checkr_test"
object. If that input object is a fail, line_where()
immediately returns
that input: none of the tests are performed. This allows test results to be cascaded.
Some important details about what types of objects F, Z, V, and E will be. V and E are straightforward: V will always be the kinds of thing computed by the line, e.g. a vector, dataframe, and so on. E will always be a language expression (minus the assignment, if any), and F will always be a character string. But Z is a name and character strings respectively.
A "checkr_test"
result which is either a pass, fail, or OK.
1 2 | ex <- for_checkr(quote({x <- 2; y <- x^3; z <- y + x}))
line_where(ex, insist(F == "^"), message = "Didn't find exponentiation")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.