expect_lint | R Documentation |
These are expectation functions to test specified linters on sample code in the testthat
testing framework.
expect_lint
asserts that specified lints are generated.
expect_no_lint
asserts that no lints are generated.
expect_lint(content, checks, ..., file = NULL, language = "en")
expect_no_lint(content, ..., file = NULL, language = "en")
content |
a character vector for the file content to be linted, each vector element representing a line of text. |
checks |
checks to be performed:
Named vectors are also accepted instead of named lists, but this is a compatibility feature that is not recommended for new code. |
... |
arguments passed to |
file |
if not |
language |
temporarily override Rs |
NULL
, invisibly.
# no expected lint
expect_no_lint("a", trailing_blank_lines_linter())
# one expected lint
expect_lint("a\n", "trailing blank", trailing_blank_lines_linter())
expect_lint("a\n", list(message = "trailing blank", line_number = 2), trailing_blank_lines_linter())
# several expected lints
expect_lint("a\n\n", list("trailing blank", "trailing blank"), trailing_blank_lines_linter())
expect_lint(
"a\n\n",
list(
list(message = "trailing blank", line_number = 2),
list(message = "trailing blank", line_number = 3)
),
trailing_blank_lines_linter()
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.