line_where: Identify an individual line in a sequence of commands

Description Usage Arguments Details Value Examples

Description

The tests are written in terms of pronouns

Usage

1
line_where(ex, ..., message = "No such line found.")

Arguments

ex

a "checkr_test" object for instance as made by for_checkr()

...

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.

Details

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.

Value

A "checkr_test" result which is either a pass, fail, or OK.

Examples

1
2
ex <- for_checkr(quote({x <- 2; y <- x^3; z <- y + x}))
line_where(ex, insist(F == "^"), message = "Didn't find exponentiation")

dtkaplan/checkr documentation built on May 15, 2019, 4:59 p.m.